![]() |
Web Development »
Web Services »
General
Advanced
License: The Code Project Open License (CPOL)
Developing wireless workflow automation client on Pocket PC/PDAs with web service in C# 2003.By Zenab_ZenabThis article focuses on developing a workflow client device application for pocket pc. |
SQL, C# 1.0, .NET CF, .NET, Win2K, WinXP, Win2003, VistaSQL 2000, SQL 2005, VS.NET2003, VS2005, Architect, DBA, Dev
|
||||||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Workflows automation clients are often web based, an easy approach to implement business process flows and deploy workflow client over a large scale in an organization and companies.
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 smart phones.
To access such heavy sites on smart phones /pocket pc is not ideal and firewall security can also prevent user to access site.
For pocket pc we will develop a device based application which will query from a web service and then web service in turns
implements all kind of business rule and also implementing .Net Assemblies or Dlls Methods and Properties. This web service(s) give back results to device application using xml interface/soap over http protocol.
The pocket pc application gets data and displays it to user.
Similarly user can submit a task which will update the database status and another user sitting in a organization /company working ordinary desktop will view it on web based workflow client.
we will first develop a web service which have logic of connection to database and quering from database.
NOTE:I ve used sample databases.Remember database that contains tracking id of a workflow should be Workflow databases that comes with any workflow,BPM softwares.It is also a good practice to wrap up all data access code uing workflow databases in APIs.If APIs come with Workflow software as SDK, its better to use them.
Go to VS 2003->New projcect->Visual C# Projects.
select ASP.net web service template.
In location field, write projectname.

Add two New Classes to project .Give them names DatabaseCS.cs and DataAccess.cs
DatabaseCS.cs has function
public short OpenConnection(string strServername, string struser,
string strpwd , string strDatabase)
it receives paramters of databse name,servvername etc from Web method.
DataAccess.cs has Overloaded Execute_Dataset function
public short Execute_Dataset(DatabaseCS DBcs,string StrQueryl)
//overloaded function
it receives acitive open connection object in DataBASEcs.CS CLASS ,Querystring from Web method(asmx file), Query database and populate a dataset.
Now to use these functions in Web method
we write code in .asmx file as
[WebMethod]
public DataSet Select(string strQuery,ArrayList DBParm)
{
strServername= DBParm[0].ToString();
struser= DBParm[1].ToString();
strpwd= DBParm[2].ToString();
strDatabase= DBParm[3].ToString();
DataSet dsselect=new DataSet();
DatabaseCS DBcs=new DatabaseCS();
dsselect.Clear();
short iretval=0;
iretval=DBcs.OpenConnection( strServername,
struser, strpwd , strDatabase);
if(iretval> 0)
{
DataAccess DBAccess=new DataAccess(strQuery);
short ierror= DBAccess.Execute_Dataset(DBcs,strQuery);
dsselect=DBAccess.GetDataeset();
}
DBcs.CloseConnection();
return dsselect;
}
DBParam is an arrayList which contains the database name, server name, user ID, and the password.
Build the projct.
access web service on Internt exploer.
Yes we can see our web method.
Next step is to develop a client application for pocket pc which will acess this web service methods.
Start New project->Visual C# projcect->Smart Device Application.
Type Wirelessworkflowclient in Name field.
Select Drive/Folder in Location field.
in Smart device application wizard , select Pocket PC from list marked as "What platform do you want to target" and select Windows Application from list marked as "What project type do you want to create".

Click/press OK.
Add MainMenu, Inputpanel and a context menu componnts on Main Form (also marked as mainform).
drag Datagrid Control on Mainform.
Now we will add our developed web reference to this project.
Go to->Soultion explorer->Right Click and select Add Web Reference.

Type Address of Web service in URL Field and click "Go".
Note:Do not write "Localhost" in the URL in this step.Use Ip .Address if you are on LAN or domainname of your server.
If you are testing your application on emulator(that is sure) and your PC is on LAN ,use IP address. If your PC is not on LAN and not connected to internt, use hostname of your PC.
However, before luanching application on emulator , install Microsoft Loopback adapter LAN.
see further configuration at the end of this article.

Type Name of Web refrence in "Web Referrence name " field.Click "Add Reference"
Now write code to access data from database and display in the datagrid. we are concerned about two databases here. so one fetch from a Orders/Products databse(e.g assume Northwind) and other is of course your Major workflow database. Define Variables for two databses and arraylist which accomodates these variables so to pass them to web service. Inititalize ArrayList in MainScreen() (Constructor of your Form) constructor. create instance of web service.
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
namespace Wirelessworkflowclient
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class MainScreen : System.Windows.Forms.Form
{
//WebReference11.MobMService serv =
new WebReference11.MobMService();
WbService.Wireless serv =
new Wirelessworkflowclient.WbService.Wireless();
string currentlogeduser;
ArrayList DBParam=new ArrayList(4);
ArrayList DBParam2=new ArrayList(4);
string strServername="myserverSQL";
string struser="sa";
string strpwd ="";
string strDatabase="ProcessesDB";
string strServernameM="myserverSQL";
string struserM="sa";
string strpwdM ="";
string strDatabaseM="NORTHWind";
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 MainScreen()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//initrilize arraylist with database parms
DBParam.Add(strServername);
DBParam.Add(struser );
DBParam.Add(strpwd);
DBParam.Add(strDatabase);
DBParam2.Add(strServernameM);
DBParam2.Add(struserM );
DBParam2.Add(strpwdM );
DBParam2.Add(strDatabaseM );
//
// TODO: Add any constructor code after InitializeComponent call
//
}
public void FetchRemoteData(string login)
{
Cursor.Current =Cursors.WaitCursor;
string Msg="";
ID.Text ="User ID:"+login;
MessageBox.Show(serv.Url);
//try this to check if your web service
//url in reference.cs is updated to right url.
try
{
DataSet dsnew =new DataSet();
DataSet dsname=new DataSet();
dsname=serv.Select("select * from Tables1 where name='" +
login.Trim() + "'",DBParam.ToArray());
if(dsname.Tables.Count>0)
{
if(dsname.Tables[0].Rows.Count>0)
{
Name.Text =dsname.Tables[0].Rows[0]["Fullname"].ToString();
}
}
else
{
}
try
{
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());
if(dsnew.Tables.Count>0)
{
if(dsnew.Tables[0].Rows.Count>0)
{
DGTasks.DataSource =dsnew.Tables[0];
}
else
{
Msg ="No New data in your workflow client";
}
}
else
{
Msg ="Server Unavaialable!";
}
}
catch(Exception ex2)
{
MessageBox.Show (ex2.Message);
Msg =ex2.Message;
return;
}
}
catch(Exception exx)
{
MessageBox.Show ("2" + exx.Message);
Msg =exx.Message;
}
Cursor.Current =Cursors.Default;
}
on Form Load Event write this code.
FetchRemoteData(currentloggeduser);
NOte: You can use a another form for login and access authority . write a method in web service which accepts username, password, verifies from database sneds true, false value to the client.
If your code finished here, time to build project and deploy it on Emulator.
Select Build->Build solution from Menu.

in the next step select "Pocket PC 2002 emulator" from list and click Deploy.

Here we go...


Configuration of Loop back adapter
Control panel->add Hardware->add Microsoft Loopback adapter
After Installation
in the properties of Microsoft Loopback adapter , selct TCP/IP->enter IP address
192.168.0.1 and subnet mask 255.255.255.0
similary on emulator selct network adapter->select N2000 Enternet driver

Click proprties
enter IP address 192.168.0.2
and subnet mask 255.255.255.0
If there is problem in connction with web service from emulator ,change Device ID of emulator in setting of emulator.
Summary:we designed and develop a web service which is generic and used for the purpse of databse connection and manupulation. however BPM software provides additional features and provide dll for users access and other manipulation. you can also embed that functionality into web service.
purpose of pocket pc device is to get all workflow tasks data for a authorized users.
happy programming!
| You must Sign In to use this message board. | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 3 Mar 2009 Editor: |
Copyright 2006 by Zenab_Zenab Everything else Copyright © CodeProject, 1999-2009 Web18 | Advertise on the Code Project |