CAB QuickStarts BankTeller

This is the last post of a series that covers the basic ground of CAB QuickStarts from a simple point of view.

Other posts in this series

BankTeller QS

BankQS

This is a list of the procedures in this post

Startup

  1. The shell defines the root WorkItem as the default WorkItem provided by CAB, and the starting view as BankShellForm.
  2. The shell executes the Run() method. This method calls the LoadModules() method in the CabApplication class.
  3. The LoadModules() method obtains the modules (.dll) by using the FileCatalogModuleEnumerator.EnumerateModules() method. What it does is search for Assembly file names in the ProfileCatalog.xml.
  4. The shell then overrides the AfterShellCreated() method registering ExtensionSites by using the hardcoded strings in the UIExtensionConstants class.
    1. mainMenuStrip
    2. mainStatusStrip
    3. file menu item
    4. file menu drop-down section

clip_image001

UIExtensionSiteCollection Class

5. Then the LoadFromConfig() method from the UIElementBuilder class is called.

    1. Gets the “shellitems” section from App.config file.
    2. Exeutes a foreach (statement) MenuItemElement in the section, convert it to a ToolStripMenuItem (uiMenuItem).
    3. Adds the ToolStripMenuItem to the ExtensionSite collection in the WorkItem. clip_image002
    4. If the menuItem has a CommandName, add a Command to the WorkItem registering the click event.

clip_image003

6. The BankTellerModuleInit (ModuleInitializer) is executed.

BankTellerModuleInit

  1. Uses the [Injection Constructor] which makes it the constructor to be used for Dependency Injection. It gets the WorkItem by using [Service Dependency].
  2. The Load() method adds the “Customer” ToolStripMenuItem by adding it to the UIExtensionSites Collection in the WorkItem.
  3. Then retrieves the Content and Sidebar WorkSpaces (with names harcoded in WorkSpacesConstants class).
  4. Adds a CHILD WorkItem named BankTellerWorkItem and calls its Show() method.

clip_image004

BankTellerWorkItem Show

  1. Creates a new object UserInfoView and adds it to the WorkItem.Items collection, giving it an ID (“UserInfo”) because it will be used in a place holder. (Remember that: The SmartPartPlaceHolder placeholder control has the SmartPartName property that automatically displays a SmartPart with that name if it is found within the current WorkItem.)
  2. The Constructor gets the CurrentPrincipal property of the current Thread and displays the name of the user.
  3. Creates a SideBarView and adds it to the WorkItem.Items collection. Then assigns it to a SideBarView instance named sideBarView.
  4. Then calls the AddMenuItems() method.
    1. Creates a new ToolStripMenuItem (“Queue”)==> queueItem
    2. Adds the queueItem to the WorkItem.ExtensionSites[“File”] collection.
    3. Then registers a new site [“Queue”] in the queueItem.DropDownItems collection.
    4. Creates a new ToolStripMenuItem (“AcceptCustomer”) ==> acceptCustomer.
    5. Sets shortcut keys for acceptCustomer.
    6. Adds the acceptCustomer ToolStripMenuItem to the [“Queue”] extension site.
    7. Adds a new CommandInvoker to the Command[“QueueAcceptCustomer”] using acceptCustomer as the Invoker and “Click” as the EventName. clip_image006 Father WorkItem
  5. Calls sideBar(IWorkSpace).Show method, passing sideBarView as a SmartPart parameter.
  6. Activates the WorkItem (this.Activate()).
  7. The BankTellerWorkItem overrides the OnActivated method, setting the bool ShowQueueMenu = true; which uses set{} to make the ToolStripMenuItem queueItem.Visible = true;
  8. The SideBarView DESIGNER has a design time (redundant) addition of the CustomerQueueView SmartPart. clip_image007
  9. The CustomerQueueView uses dependency injection [CreateNew] to initialize the CustomerQueueController.
  10. Also registers the CommandHandler for the [“QueueAcceptCustomer”] command.

Accept Customer

(Event Handler)

  1. Registers the (“QueueAcceptCustomer”) [CommandHandler], which is referenced by acceptCustomer ToolStripMenuItem. The Event Handler is also subscribed to by the btnNextCustomer Click Event.clip_image009clip_image010
  2. Calls the GetNextCustomerInQueue() method from the CustomerQueueController.
  3. The GetNextCustomerInQueue() method calls the CustomerQueueService(which was initiated with [ServiceDependency] attribute) GetNext() method.
  4. The GetNext() method returns a new Customer.
  5. The view adds the Customer to the ListItem.Item Collection.

Customer List SelectedIndexChanged

  1. Retrieves the selected Customer from the list.
  2. Calls the CustomerQueueController.WorkWithCustomer(customer) method.
  3. This method calls the BankTellerWorkItem.WorkWithCustomer (customer) method.
  4. Creates a string keyè “Customer#” & {customer.ID}
  5. If the CustomerWorkItem for that customer has been created it gets it. Else it adds a new one.
    1. Assigns the CustomerWorkItem with the KEY to workItem object and adds it to father WorkItems collection.
    2. Sets the CustomerWorkItem ID, and .State[“Customer2”] = customer.
    3. If the BankTeller PersistanceService ! null & contains the WorkItem.ID, load() the workItem.
    4. This method uses the Services<Collection>.Get() method, to get the FileStatePersistance service, in order to be able to get a previously saved customer state.
  6. Calls the CustomerWorkItem.Show() method.

Customer WorkItem Show

  1. Assigns to CustomerSummaryView object the previously existing one if !null (?? operator), or adds a new view to the CustomerWorkItem.Items (Collection).
  2. The calls the WorkSpace(father).Show() method using CustomerSummaryView object as a parameter.
  3. Calls the AddMenuItems() method.
    1. Creates a new instance ToolStripMenuItem named editCustomerMenuItem.
    2. Adds the ToolStripMenuItem to the CustomerWorkItem UIExtenstionSites[“BankTellerModule.CustomerMenu”] Collection.
    3. In the WorkItem’s Commands[“EditCustomer”] adds an invoker from the editCustomerMenuItem Click Event handler.
    4. In the WorkItem’s Commands[“CustomerMouseOver”] adds an invoker from the customerSummaryView (CustomerSummaryView instance) MouseHover Event handler.
  4. Gets the customer from the WorkItem’s state.
  5. Calls OnStatusTextUpdate() method, passing as parameter the first and last name of the customer in a string.
    1. Raises the UpdateStatusTextEvent which is published [EventPublication] in the begginnig of the WorkItem.clip_image011
    2. The BankShellForm has an EventSubscription, OnStatusUpdate().
    3. Changes the label.Text to (“Editing {FirstName} {LastName}”)
  6. Calls the UpdateUserAddressLabel() method.
    1. Instances a new ToolStripStatusLabel named addressLabel.
    2. Adds to the UIExtensionSites (collection)[“MainStatus”] the addressLabel.
    3. Sets the text property of the label to the customer.Address1.
  7. Activates the WorkItem.
  8. Calls the SmartPart CustomerSummaryView.FocusFirstTab(), which sets the SelectedTab to [0].

CustomerSummaryView

  1. The CustomerSummaryView has a TabWorkSpace which inside has:

clip_image013 CustomerSummaryView.Designer.Cs

Customer Header View

  1. The CustomerHeaderView uses the [State] attribute to get the current customer from the Parent WorkItem.
  2. The load event binds the customer to the CustomerHeaderView.BindingSource.

CustomerDetailView

  1. The CustomerDetailView uses [ServiceDependency] to get a reference to the parent WorkItem.
  2. It also uses the [State] attribute to get the current customer from the Parent WorkItem.
  3. Then uses the [CreateNew] attribute to instantiate the CustomerDetailController.
  4. The overridden OnLoad() method sets the customer to the CustomerDetailView.BindingSource.

CustomerAccountsView

  1. The CustomerAccountsView uses the [State] attribute to get the current customer from the Parent WorkItem.
  2. Uses [ServiceDependency] to get a reference to CustomerAccountService.
  3. Overrides the OnLoad() method to call the accountService.GetByCustomerID (Customer.ID), which gets a ListDictionary<> of accounts and sets it as the datasource for the DataGrid.

Customer Map

  1. The Customer Map (third tab) is loaded from the CustomerMapExtensionModule.dll when the application starts because it is in the ProfileCatalog.xml. It contains a [SmartPart] (CustomerMap) and a CustomerWorkItemExtension.
  2. The CustomerWorkItemExtension overrides the OnActivated() method.
    1. Adds a CustomerMap smartpart to the WorkItemExtension.Items collection, and assigns the smartpart to mapView (CustomerMap instance).
    2. Creates a TabSmartPartInfo (A SmartPartInfo that shows how a specific SmartPart will be shown in a tab Workspace) named info.
    3. Assigns valus to title and description properties:clip_image014
    4. Calls the WorkItem.WorkSpaces[“tabbedWorkSpace1”].Show() method, passing as parameters the CustomerMap Smartpart and the SmartPartInfo.
  3. The CustomerMap SmartPart gets a Customer instance using [State(“Customer 2”)]

Customer Summary Controller

The OnCustomerEdit event handler is declared as a [CommandHandler(“EditCustomer”)]

  1. Assigns to a tabWorkSpace tabWS the WorkItem.WorkSpaces[“tabbedWorkSpace1”] using as cast (if it is not able to do it return null)
  2. Sets the tabWorkSpace.SelectedIndex to 0, allowing customer Editing.

CustomerWorkItem

  1. The OnCustomerEdit event handler is declared as a [CommandHandler(“CustomerMouseOver”)] and executes when the user moves the mouse over the CustomerSummaryView SmartPart.
  2. If the WorkItem.Status is active, displays a ToolTipText indicating the ID of the customer being edited.

BankShellForm

  1. Registers the OnStatusUpdate event handler [EventSubscription] using the topic (“topic://BankShell/statusupdate”). This event is published in the CustomerWorkItem. clip_image015
  2. Updates the toolStripStatusLabel1.Text with the data from the customer.

ShowCommentButton Click

  1. Calls the OnShowCustomers event handler.
  2. Calls the Controller.ShowCustomerComments() method.
  3. The Controller.ShowCustomerComments() method calls the WorkItem.ShowCustomerComments() method.
  4. Calls the CreateCommentsView() method.
    1. Assigns to commentsView (CustomerCommentsView instance) the previously existing one if !null (?? operator), or adds a new view to the CustomerWorkItem.Items collection.
    2. Declares info as a new tabSmartPartInfo. Assigns info.Title = “Comments”.
    3. Calls the WorkItem.RegisterSmartPartInfo() method passing as parameters (commentsView, info)
  5. Assigns to ws (which implements IWorkSpace Interface) WorkItem.WorkSpaces[“tabbedWorkSpace1”].
  6. ws.Show(commentsView);

SaveButton Click

  1. Calls the Controller.Save() method
  2. The Controller.Save() method calls WorkItem.Save() method.
  3. Declares an IStatePersistanceService service and gets the Services.Get <IStatePersistanceService>
  4. Saves the changes using the service and calls the state.AcceptChanges() method to reset the HasChanges “flag”.

clip_image016

Technorati Profile