After completing this chapter, you will learn:
1. Understanding the concept and theory of workflow
2. Compare WF and BizTalk with WCF
3. Start using WF for programming
4. Know how to use Visual Studio Workflow support. Here is a small section of code to verify the ZIP code
string USCode = @"^(\d{5}$)|(\d{5}$\-\d{4}$)";
string CanadianCode = @"[ABCEGHJKLMNPRSTVXY]\D[A-Z]\d[A-Z]\d";
public static bool ValidatePostalCode(string str)
{
return (Regex.IsMatch(str,USCode)||Regex.IsMatch(str,CanadianCode));
}
This is nothing special: "Test a string of input, return True if it is a US zip code or Canadian zip code, or false". This is a very useful piece of code, in fact, if you do not want to use other validation controls in ASP.net, you can use this validation logic in your asp.net. We are now creating an workflow application that will perform the same validation and return information that validates whether it passed.
Create a workflow project based on the console
1. Start Visual Studio 2008
2. Create sequential Workflow Console Application project
3. Enter Pcodeflow in Project name
4. Click OK, will automatically generate the following initial interface
Before you edit the code or insert the workflow item, pause for a moment to see the two files generated by the workflow project:
Program.cs: This is a typical console application source file, as you can see in many ways. However, this template adds a lot of code to support workflow operations. Understanding the code is one of the main goals of the book, but this chapter simply understands what it does.
Workflow1.cs: This is a workflow component, we will modify it to verify the ZIP code, the first time you can put a lot of things, but now we still use this simple workflow start work.