Workflow automation clients are often web based, an easy approach to implement business process flows and deploy workflow clients over a large scale in an organization. These workflow clients and processes are mostly developed with components (DLLs, SDKs) that come with BPM software. These DLLs (or .NET assemblies) embed most of the workflow functionalities and routing mechanism. However, such workflow automation clients have not been designed for devices like Pocket PC/Palm and SmartPhones.
To access such heavy sites on SmartPhones/Pocket PC is not ideal, and firewall security can also prevent the user from accessing a site. For Pocket PC, we will develop a device based application which will query from a Web Service and then the Web Service will, in turn, implements all kinds of business rules and also implements .NET assemblies or DLL methods and properties. This Web Service(s) give back results to the device application using XML interfaces/SOAP over HTTP protocol. That is, the Pocket PC application gets data and displays it to the user. Similarly, the user can submit a task which will update the database status, and another user sitting in an organization/company working on an ordinary desktop PC will view it on a web based workflow client.
We will first develop a Web Service which has the logic for the connection to the database and does the querying from the database.
Note: I've used sample databases. Remember, the database that contains the tracking ID of a workflow should be a workflow database that comes with a workflow BPM software. It is also a good practice to wrap up all data access code using workflow databases in APIs. If APIs come with workflow software as SDK, it's better to use them.
Go to VS 2003->New Project->Visual C# Projects. Select the ASP.NET Web Service template. In the Location field, specify the project name.
Add two new classes to the project. Name them DatabaseCS.cs and DataAccess.cs.
DatabaseCS.cs will define the function below:
public short OpenConnection(string strServername, string struser,
string strpwd , string strDatabase)
It receives parameters for the database name, server name etc., from the Web Method.
DataAccess.cs will have the overloaded
public short Execute_Dataset(DatabaseCS DBcs,string StrQueryl)
It receives the active open connection object in the
DatabaseCS class, query string from the Web Method (ASMX file), and queries the database and populates a
To use these functions in the Web Method, we write code in the .asmx file as:
public DataSet Select(string strQuery,ArrayList DBParm)
DataSet dsselect=new DataSet();
DatabaseCS DBcs=new DatabaseCS();
struser, strpwd , strDatabase);
DataAccess DBAccess=new DataAccess(strQuery);
short ierror= DBAccess.Execute_Dataset(DBcs,strQuery);
DBParam is an
ArrayList which contains the database name, server name, user ID, and the password.
Build the project. Access the Web Service on Internet Explorer.
Yes, we can see our Web Method.
The next step is to develop a client application for Pocket PC which will access these Web Service methods.
Start New Project->Visual C# Project->Smart Device Application. Enter Wirelessworkflowclient in the Name field. Select Drive/Folder in the Location field.
In the Smart Device application Wizard, select Pocket PC from the list marked "What platform do you want to target" and select Windows Application from the list marked "What project type do you want to create".
InputPanel, and a
ContextMenu on the main form. Now drag a
DataGrid control on the main form.
Now we will add our web reference to this project. Go to Solution Explorer, right click and select Add Web Reference.
Type the address of the Web Service in the URL field and click "Go".
Note: Do not write "Localhost" for the URL in this step. Use the IP address if you are on a LAN, or the domain name of your server. If you are testing your application on an emulator (that is sure) and your PC is on a LAN, use the IP address. If your PC is not on LAN and not connected to the Internet, use the hostname of your PC. However, before launching the application on the emulator, install the Microsoft Loopback Adapter LAN. See further configuration tips at the end of this article.
Type the name of the Web Reference in the "Web Reference name" field. Click "Add Reference".
Now write code to access data from the database and display it in the
DataGrid. We are concerned about two databases here. So one fetch from the Orders/Products database (e.g., assume Northwind), and the other is, of course, your major workflow database. Define the variables for the two databases and an
ArrayList which accommodates these variables to pass them to the Web Service. Initialize the
MainScreen() (the constructor of your form). Create an instance of the Web Service.
public class MainScreen : System.Windows.Forms.Form
WbService.Wireless serv =
ArrayList DBParam=new ArrayList(4);
ArrayList DBParam2=new ArrayList(4);
string strpwd ="";
string strpwdM ="";
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.Label Name;
private System.Windows.Forms.Label ID;
private System.Windows.Forms.DataGrid DGTasks;
private Microsoft.WindowsCE.Forms.InputPanel inputPanelT;
private System.Windows.Forms.MainMenu mnuM;
private System.Windows.Forms.Label HD;
public void FetchRemoteData(string login)
ID.Text ="User ID:"+login;
DataSet dsnew =new DataSet();
DataSet dsname=new DataSet();
dsname=serv.Select("select * from Tables1 where name='" +
login.Trim() + "'",DBParam.ToArray());
string strq="select Northwind..Products.Productname" +
" Product , ProcessesDB..Process.Agenda ," +
"from ProcessesDB ,Northwind..Products " +
"where ProcessesDB..Process." +
"ActiveLoginClient ='" + login +
"' and Northwind..Products.ProductID=incno " +
"order by Northwind..[Products].ProductID desc";
dsnew = serv.Select(strq ,DBParam2.ToArray());
Msg ="No New data in your workflow client";
Msg ="Server Unavaialable!";
MessageBox.Show ("2" + exx.Message);
In the Form Load event, write this code:
Note: You can use another form for login and access authority. Write a method in the Web Service which accepts the username, password, and verifies them from database to send a true/false value to the client.
If your code finished here, it is time to build the project and deploy it on the emulator.
Select Build->Build Solution from the menu.
In the next step, select "Pocket PC 2002 emulator" from the list and click Deploy.
Here we go...
Configuration of the Loopback Adapter: Control Panel->Add Hardware->Add Microsoft Loopback Adapter.
After installation, in the properties of the Microsoft Loopback Adapter, select TCP/IP, and enter the IP address 192.168.0.1 and the subnet mask 255.255.255.0. Similary, on the emulator, select Network Adapters->N2000 Ethernet Driver.
Click Properties. Enter IP address 192.168.0.2 and subnet mask 255.255.255.0.
If there is problem in the connection with the Web Service from the emulator, change the device ID of the emulator in the Settings for the emulator.
We designed and developed a Web Service which is generic and used for the purpose of database connections and manipulations. However, BPM software provide additional features and provide DLLs for user access and other manipulation. You can also embed that functionality into a Web Service.
The purpose of the Pocket PC device is to get all workflow task data for authorized users.