Thursday, June 14, 2007

Create a distributable workflow enabled smart client

We want to develop a windows application with workflow enabled. The easiest and fastest way is to use Microsoft Workflow Foundation which give you a complete API for designing any workflow application that you can think of.

We wanted to develop a windows application which has to be distributed to multiple computers and having multiple users. Here we have one challenge, we need to host the Workflow. The most simple implementation is to host workflow in a dedicated server where many clients can access to it. Next we have to expose the workflow as webservice, this is important because workflow as webservice can give you the maximum flexibility in connectivity and interoperability. For example, connect a mobile device that runs java application. Sound interesting?

I will post the tutorial on building your first smart client workflow enabled application here for your reference.

Wednesday, June 6, 2007

Short hand using if else for ADO.NET

SqlCeCommand command = new SqlCeCommand(queryString, connection);
command.Connection.Open();
ccommand.Parameters.Add("@AddressID", (object)AddressID?? DBNull.Value );

SQL Compact return new insertion identity

Try this code it will help.


public Int64 AddCustomer(string LastName, string FirstName, int?
AddressID, string MembershipUsername, string PhoneNumber, string
MobilePhoneNumber)
{
SQLCeHelper sqlce = new
SQLCeHelper(Properties.Settings.Default.CarServ3DB4ConnectionString);
string
queryString =
"INSERT INTO Customer" +
"(LastName, FirstName, AddressID,
MembershipUsername, PhoneNumber, MobilePhoneNumber)" +
"VALUES
(@LastName,@FirstName,@AddressID,@MembershipUsername,@PhoneNumber,@MobilePhoneNumber)";
Int64
newIdentity = 0;
using (SqlCeConnection connection = new
SqlCeConnection(
Properties.Settings.Default.CarServ3DB4ConnectionString))
{
SqlCeCommand
command = new SqlCeCommand(queryString,
connection);
command.Connection.Open();
command.Parameters.Add("@LastName",
LastName);
command.Parameters.Add("@FirstName",
FirstName);
command.Parameters.Add("@AddressID", (object)AddressID??
DBNull.Value );
command.Parameters.Add("@MembershipUsername",
MembershipUsername);
command.Parameters.Add("@PhoneNumber",
PhoneNumber);
command.Parameters.Add("@MobilePhoneNumber",
MobilePhoneNumber);
command.ExecuteNonQuery();
SqlCeCommand command1 = new
SqlCeCommand("select @@identity ", connection);
newIdentity =
Convert.ToInt32(command1.ExecuteScalar());
}
return
newIdentity;
}