CAB QuickStarts: Event Broker

This is the first post of a series that will cover the basic ground of CAB QuickStarts from a simple point of view.

Other posts in this series

For more information about CAB see:

Event Broker QS

This is a list of the procedures in this post:

Add Customer Button

  1. View uses button event to communicate with controller.
  2. Controller adds customer in controller logic, and raises State Changed Event.
  3. The view which is suscribed to this event updates the list data source.

Show List Button

  1. View uses button Event to call method.
  2. Calls Controller method: ShowCustomerList.
  3. Creates a new workitem and adds it as a child for the one being used.
  4. Passes the current workitem’s State to the child workitem (Using a List, Empty)
  5. Adds a form as a View (to the Item Collection) to the child workitem.
  6. The view’s constructor creates a new list [Create New] & gets the state using the State attribute.
  7. The OnLoad Event Handler suscribes to both the State change event in the workitem, as well as a event raised by a change of State in the parent workitem.
  8. Displays the new View.

Add Local Button

  1. Calls Event for the button.
  2. If there’s something in the text box it calls the controller’s add local customer method passing id.
  3. Adds customer to list
  4. Raises event StateChanged.
  5. The event handler referred to the State Changed in the view is executed.
  6. The data source for the list is re-assigned.

Add Global Button

  1. Calls event for the button.
  2. If there is text calls Controller’s addGlobal Method passing id.
  3. Raises the GlobalCustomerAdded Event, passing customer ID as event args.
  4. The [EventPublication("topic://EventBrokerQuickStart/CustomerAdded")] in the controller “publicates” the event
  5. This calls the method OnCustomerAdded in the LaunchPadController, because it is suscribed to the topic.
  6. The OnCustomerAdded calls the AddCustomer Method from the LaunchPadController.
  7. The method adds the customer to the customer List
  8. The State Changed Event is raised.
  9. Both Views (CustomerListView & LaunchPadForm) update their list’s datasources because they are suscribed to the event.

Proccess Local Button (Makes Local customers be Global)

  1. Calls the event for the button.
  2. Calls CustomerListController ProcessLocalCustomer Method.
  3. If nothing is being processed assign the local customer list to DictionaryEventArgs.
  4. Fire the "topic://EventBrokerQuickStart/StartProcess" topic.
  5. CustomerListController has an EventSubscription to that topic, calling the StartProcessHandler (Thread = Background, runs on a separate thread).
  6. Gets the list of customers to process from the dictionary.
  7. Calls the OnProgressChanged Method that raises the ProgressChanged event.
  8. The "topic://EventBrokerQuickStart/ProgressChanged" topic is suscribed to by the ProgressChangeHandler. The ProgressView updates its value by suscribing to this event.
  9. Calls the AddGlobalCustomer Method that fires the GlobalCustomerAdded event.
  10. The LaunchPadController suscribes to the GlobalCustomerAdded event, calling the add customer method, thus adding a customer to the customer list.
  11. Raising the StateChangedEvent so the list updates its data source (The CustomerListController Clears the customers list, then raises the State Changed and Creates a progress view ).
  12. The on process completed method is called in the StartProcessHandler, firing the ProcessCompleted event.
  13. The ProcessCompleted eventhandler updates the processing status to false.

The next post will be about the Module Loader Quickstart, stay tuned.