To get the task started there are different ways which depends on the navigation model we used. They have the UserControlNavigation within windows forms. You can now force a user to go in a particular sequence when contained with complex controls within the form. It is not available presently for the web application but may be for the subsequent version they may release it. So in case if you are working with the graphnavigation which is the sequential type of navigation then you need to call StartNavigationTask on UIPManager which has multiple overload.
You create a custom class which derive from the ControllerBase and number of controller depends on number of tasks you have. This ControllerBase class is available in Microsoft.ApplicationBlocks.UIProcess. Best way is to choose one controller per tasks but in case your application is fairly small, you can have one controller per application. State is maintained on behalf of tasks. Well another thing we do is we implement navigation method which specify which view to demonstrate next based on the contents of Config class. State is accessible in controller as it inherits from ControllerBaseClass and ControllerBaseClass have the property called state through which we can directly access the state.
Views are derived from their base class: WebFormView or WindowFormView. These base classes are available in Microsoft.ApplicationBlocks.UIProcess It access the state from the controller to initialize itself and to present itself , if necessary take the feeback from the user, modify it and then when you need to navigate to another view, you can save the state back. State is saved in a hash table which is a key value pair. If you need to access strongly type state objects, you can also create your own state. One things that is important is that as soon as we closes the view, we need to store state back. One things is to be kept in mind is that when we need to first change the base class and the layout. Sometimes if we changes the layout and then changes the base class, VS.NET got unhappy and makes some problems in displaying the UI controls.
Plays a very important role in UIPAB and all sort of configuration information is stored in the configuration file. Its web.config for web applications and <applications>.exe.config for windows applications.
If we talk about the configuration files , there have the following schema.
First of the things is the configSection which tells how application block is plugged into the applications.
type="Microsoft.ApplicationBlocks.UIProcess.UIPConfigHandler, Microsoft.ApplicationBlocks.UIProcess" />
In this we are specifying that we have .NET UIPAB information will be stored in the uipConfiguration section. We can change it to any other section, if necessary and this section is been handle by a class called uipConfigHandler which resides in Microsoft.ApplicationBlocks.UIProcess namespace. Now UIPConfighandler expect the some standard schema which consist of three elements.
each of these elements also have the sub elements.
Now as far as objectTypes is concerned, it contains the type information about various pieces of architecture. So it contains information about viewManager, state , controller and statePersistenceProvider that we should use,
type="Microsoft.ApplicationBlocks.UIProcess.WinFormViewManager, Microsoft.ApplicationBlocks.UIProcess, Version=188.8.131.52,Culture=neutral,PublicKeyToken=null"/>
type="UIProcessQuickstarts_MultiNavGraph.State1, UIProcessQuickstarts_MultiNavGraph, Version=184.108.40.206, Culture=neutral, PublicKeyToken=null"/>
type="UIProcessQuickstarts_MultiNavGraph.DemoController1, UIProcessQuickstarts_MultiNavGraph, Version=220.127.116.11,Culture=neutral,PublicKeyToken=null" />
type="Microsoft.ApplicationBlocks.UIProcess.SqlServerPersistState, Microsoft.ApplicationBlocks.UIProcess, Version=18.104.22.168,Culture=neutral,PublicKeyToken=null"
connectionString="Data Source=localhost;Initial Catalog=UIPState;user id=UIP;password=U1Pr0c3ss"/>
So each sub element of the ObjectTypes have the name and type, where type specify which implementation we are using. For e.g. we are using the IViewManager we will see that we are implementing the winFormViewManager, in case, if we want to make our own base type, we have to specify here. Most of the time we are happy with the default type. So ObjectType identifies the core pieces of architecture and its implementation.
After that, it comes the Views elements.
<view name=”start” type=”start.aspx” controller=”OnlineController” />
<view name=”first” type=”first.aspx” controller=”OnlineController” />
<view name=”second” type=”second.aspx” controller=”OnlineController” />
In the view section, we specify all the views that are in the application. Now it contains three attributes.
Name attribute specify the name we would refer the view in the controller. So from the actual views, we would call the navigation method of the controller and the controller then refer to view with this logical name and the physical name of the file is specified in the type attribute. Apart from this, we also specify the controller with which this element is expect to work with in the controller attribute.
Now comes the navigation graph
<navigateTo navigateValue="next" view='Form2'/>
<navigateTo navigateValue="previous" view='Form1' />
<navigateTo navigateValue="next" view="Form3"/>
<navigateTo navigateValue="previous" view='Form2' />
<navigateTo navigateValue="showPreviousNavState" view='IAmModal' />
Now in navigation graph there are many attributes. Name attribute is used to specify the name of the navigation graph so when we call the StartNavigationGraph then we need to specify this name. so when UIPManager calls the startnavigationGraph method, engine checks the configuration file to check the name and also check which should be the view we should display first which is specified in the startView attribute where we give the logical name of the view,
Apart from that, it contains the node section for each view, where we specify two things. navigateValue and View. Navigatevalue specifies the command that controller specifies it to and then after receiving the command, where should he go to is specified in the view attribute which again specify the logical name of the view. So there is a slight performance impact but it provides a lot of flexibility in our application.
Ok now see the functionality.
We have the view and we need to move to another view. So what we do is that we should first save the state of this view. This is done by accessing the state property of the controller which is again the key-value pair so we will do something like this.
Controller.State["someState"] = txtState.Text;
After this we specify the navigationmethod of the controller. Something like this:
Where we need to call the Form1btnNext method of the controller called DemoController1. we need to cast it into appropriate type
Now if we look in the controller class for our application, it is derived from the controllerBase class of the application and in the form1btnNext
public void Form1btnNext()
// Navigate to the next view
State.NavigateValue = "next";
We are specify the navigate value and then calling the Navigate method else we would have done this
Both gives the same result. In the Controller class, we would have to create a constructor that takes the navigation object. By this. We ensure a way to loosely couple our view and each view is able to know its own state. This is where the advantage of UIPAB comes into the scene. Now Through this article I tried to make sure that configuration of UIPAB in web.config file is very easy to use. Through this series of articles, I tried to make sure that it is really easy to work on UIPAB. Full web.config file is available with the zip file that I am attaching with this article.
This series of article was meant to explain all about configuration of UIPAB , why is it used and How to use it.