MSDN Archive Home
Help and FAQs
All Resource Updates
Change History (all pages)
Windows Workflow Foudation (WF) Samples
Windows Workflow Foundation is a part of the .NET Framework 3.0 (and 3.5) that enables developers to create workflow enabled applications. This section contains articles, samples and presentations on this technology.
Essential Windows Workflow Foundation chapter 3
This is chapter 3, focusing on activities.
Essential Windows Workflow Foundation
by Dharma Shukla, Bob Schmidt
Published by Addison-Wesley Professional
ISBN: 0321399838; Published: 10/13/2006;
Professional WF Chapter 6
This 40-page chapter focuses on activities and activity development.
Professional Windows Workflow Foundation
by Todd Kitta
Published by Wrox
ISBN: 9780470053867; Published: March 2007;
Active Directory Activities
The Active Directories can be used to get/set information in AD. The following Activities are in the bundle:
Amazon Web Service Activities
The Amazon Web Services Activity Library consists of two activities:
- AmazonSearch activity - Used to search for items on the Amazon.com site
- AmazonLookup activity - used to get details about a specific item These activities also demonstrate how to implement a custom ActivityDesigner.
Create Excel Spreadsheet Activity (Excel 2007)
Using the Open XML document specification, this activity creates an Excel spreadsheet. This was inspired by Doug Mahugh's "CreateXlsx Sample Program"
Create Word Document Activity (Word 2007)
Using the Open XML document specification, this activity will let you create a Word document within your workflow. This activity was inspired by technical evangelist Doug Mahugh's "CreateDOCX sample program".
Creating rules using the object model
This sample shows how to use the Windows Workflow Foundation (WF) Rules Object Model to create Rules directly using the APIs without using the designers. The rules created are then executed by the WF Rules Engine.
Custom Activity Framework
The Custom Activity Framework is a set of classes that simplify the development of custom activities. In this first version the base classes are designed for building activities that need to listen for external events. Examples of external events might be a file being created on the local file system, data being received in a queue, or the asynchronous completion of a web service call. To demonstrate how the base classes can be used, this package includes the FileSystemEvent activity that derives from the InputActivity base class in the Custom Activity Framework.
Custom rule actions
This sample shows how custom rule actions (derived from the RuleAction Type) can be defined and used in the Windows Workflow Foundation rules engine. Three sample rule actions are provided which demonstrate how to perform the following actions from a rule:
Write text to the console
Execute a RuleSet
Queue an activity for execution
Custom rule expressions
This sample shows the definition and use of a custom expression in the Windows Workflow Foundation rules engine. Custom expressions are used to model specific predicate types or functions and can be used directly in the rules object model and editors
Custom WF Designer and Debugger
Combining the designer re-hosting hands on lab with a custom tracking service, Vittorio has a demo written up that shows how you can "debug" a workflow instance inside of a Windows Forms application.
Dynamic Code Activity
Want to use something like the "Code" Activity, but maybe you want to pass your code in on the fly. Maybe you are re-hosting the designer, and in some scenarios you want advanced users to be able to write "Just that one little bit of code." Vittorio has put together a sample activity that does just that.
Enhanced SQL Activities
Sent in by Trevor and the fine folks at NailSoup.
This is an enhanced version of the Sql Activity posted elsewhere on this site.
Issues fixed in this release are the following:
- Ability to change the connection string in the CommandExecuting event.
- Ability to handle a return value from the stored procedure.
- Improved stability if the connection string is invalid at design time.
- Issues I know of, but haven't had time to fix are:
The activity needs a hard-coded connection string at design time in order to understand stored procedure parameters.
If you change the parameters of a stored procedure at design time, the activity often "remembers" parameters that no longer exist. It is really hard to get rid of these without deleting the activity and starting again. The activity doesn't handle output parameters. It thinks they are all input parameters.
The EBayGetCategories activity can be used to browse EBay’s product categories through EBay’s exposed web services. The EBayListItem activity can be used to post an item for sale. The EBayGetSellerList activity can be used to list the items a seller has for sale. These activities also demonstrate how to implement a custom ActivityDesigner.
External ruleset toolkit
This sample was put together by the rules team to illustrate how rules can be externalized outside the workflow and live inside a SQL server. This also shows how to rehost the rules designer, and execute the rule set outside of a WF.
File System Activity
The FileSystem activity can be used to perform File system operations/commands. This is a basic activity that uses the System.IO components to perform File system operations/commands at runtime. The FileSystem activity also demonstrates how to implement a custom ActivityDesigner, ActivityValidator, and UITypeEditor.
File System Watcher Activity for June CTP
The FileSystemEvent activity is designed to monitor a specified folder on the local file system for an event occurring to a file. An event might include the file being created, modified, renamed, or deleted. This version of the FileSystemEvent activity is an enhanced version of the sample in the Windows Workflow Foundation SDK. This version is designed to use the InputActivity base class in the CustomActivityFramework, which simplifies the development of event-based activities. This version of the FileSystemEvent also provides a custom designer.
For Each Activity
The ForEach activity takes an IEnumerable as input and upon activation it executes the body of the activity once for each item in the enumerator. If a child activity is added to the ForEach activity, a new instance of the child activity is created and executed in every loop. Each instance of the child activity goes through the entire Initialized -> Executing -> Closed life cycle and is removed from the execution context when the loop completes. The ForEach activity also provides a custom activity designer that inherits from the SequentialActivityDesigner. It is different from the SequentialActivityDesigner in two ways. First, it draws a looping arrow from the bottom of the designer to the top indicating that the execution would loop around. Second, it restricts that only one child activity can be dropped into the designer thus enforce the single child rule. There are two projects included in the download. One is the ForEachActivity project which contains the implementation of the ForEach custom activity. The other is the ForEachActivityTestWorkflow project which contains a workflow that uses the ForEach activity and a simple host to run the workflow. The ForEachActivity project must be built once before the activity can show up in the design surface of the workflow.
Hosting Workflows in Windows Services
Sample which shows how you can host a workflow inside of a windows service. More details available on his website
MSN Search Activities
The MSNSearch activity is designed to execute a web search against MSN’s public search web service. The activity simply calls the web service within the Execute method of the activity. Before you can use this activity, you will need to create an MSN Application Id. Follow these steps to create an Application ID from the MSN Search Web Service Developer Provisioning System:
- Point your browser to http://search.msn.com/developer.
- Click Create and Manage Application IDs.
- Sign in to the Passport Network. If you do not have a Passport, click Sign Up to create one. Passport authentication is required to use the Developer Provisioning System.
- Once you're signed in, click Get a new App ID to create a new Application ID for your application.
- Type a friendly name for your application in the Application Name text box.
Network Availability Activities
The NetworkActivities activity library contains two activities that are used to check and monitor network connectivity. These activities are wrappers on top of the classes provided in the System.Net.NetworkInformation namespace. These activities include:
GetNetworkAvailabilityActivity – Simple returns whether or not network connectivity is available.
NetworkAvailabilityActivity – Event-based activity that monitors network connectivity changes. This activity has two modes. It can either block until the network is available or it can close after receiving any event (connected or disconnected). The NetworkAvailabilityActivity uses the InputActivity base class in the CustomActivityFramework, which simplifies the development of custom, event-based activities.
Policy from file
The custom PolicyFromFile activity can be used in any workflow project. At design time, the policy activity will read from a specified rules file, or if no .rules was defined, a default .rules file with the same name as the workflow file will be created. In order to define a .rules file, set the RulesFileName property to the .rules file you want to use. The property can be found when you add the policy activity to your workflow and select Properties from the context menu.
Processing XML in rules
This sample shows how the WF Rules Engine can be used to process rules on Xml Documents.
Windows Workflow Foundation (WF) offers rules capabilities to the NetFx developer platform. RuleSets are collection of business rules with conditions and actions and they can be executed on any target object such as a Web application. In this sample we will show the stand alone functionality of rules in driving the page flow for a simple ASP.NET application.
Windows Workflow Foundation (WF) offers rules capabilities to the WinFx developer platform. RuleSets are collection of business rules with conditions and actions and they can be executed on any target object such as a Windows Form. In this sample we will demonstrate this capability by using rulesets to pre-populate fields, do cross validation and various calculations on a target Windows Form. We will also show rules features such as forward chaining in this sample.
This sample uses the rules object model to analyze dependencies and execution plans for a ruleset. This is a useful sample to debug and diagnose a complex ruleset.
Rules in Excel
This sample shows how you can use Visual Studio 2008 to create an Excel application that allows you to edit and define your rules inside of Excel.
Rules with collection
This sample illustrates the execution of rulesets against a collection of objects. This makes use of the techniques outlined in the Windows SDK documentation filed in the
Tracking Objects Sample
A sample that is given during WF talks that covers how the tracking service can be used to track things at an event level ("Workflow started") as well as things at a very granular level ("What is the Purchase Order amount?").
In order to track things, we first need to specify the tracking profile. This tells the workflow runtime which events and pieces of data we are interested in collecting while the workflow executes. I think that the xml representation of the tracking profile is pretty readable, but there is a tool that ships in the Windows SDK designed to make this even easier. The tool can be found after extracting the workflow samples to a directory under \Technologies\Applications\TrackingProfileDesigner. This tool will let you open up a workflow by pointing at its containing assembly and then design a tracking profile. It will deploy the tracking profile to the database for you, but I borrowed some code from another sample that shows the same functionality. The tool allows you to specify workflow level events as well as activity level events, and allows you to designate what information you would want to extract and specify the annotation as well.
The WMI Activities are event-based activities that monitor WMI events on the local machine. There are two different sets of WMIActivities. The WMIActivities project/assembly contains a WMIEvent activity class, which can be configured to listen to any WMI event. This activity derives from the InputActivity in the CustomActivityFramework, which provides the underly logic for building an event-based activity that uses queues. Instead of configuring the activity every time it is used in a workflow, you may want to have typed versions that represent specific WMI events. The WMIActivities.Common project/assembly contains a couple examples of typed activities. These examples include:
- ProcessEventActivity - monitors processes being created on the local system.
- EventLogEntryCreatedActivity – monitors the application event log for new records. However, these are just two example typed WMI event activities. There are numerous events that can be monitored through WMI by using the base WMIEvent activity.
WF Hands-On Lab-VB
A version of the hands on labs (HOL) for Windows Workflow Foundation that are written using VB.NET. This lab are identical to the C# versions available here. This contains the first three labs. They are suitable for the RTM version of Windows Workflow Foundation. The C# labs are also suitable for the RTM version even though the C# version currently specifies RC.
WF Workflow Manager (tracking/dynamic updates sample)
This application demonstrates how one can
1) enumerate and show to a user a list of live (currently executing) or tracked (executed in the past)
2) show current state of a workflow
3) control a workflow (suspend/resume/terminate)
4) change a worklfow from the UI
WF Workflow WebPage activities
Package includes WebPage Request/Response custom activities:
These activities will help integrate Workflow technology into your ASP.NET projects. Just derive your ASP.NET page from "WorkflowPage" and indicate which workflow to use.
- integration with Http Request/Response, ability to expose Http parameters in Workflow designer, ability to "Activity Bind" and use them in rules/condition expressions.
- integration with ASP.NET WebControls and data binding sample
- ability to use in both Sequential and StateMachine Workflows
- includes extensible examples of workflow driven authentication procedure, Sequential Page Navigation combined with EventHandlingScope and a StateMachine based search engine prototype.
U-Serve Product Derby
The UServ Product Derby is an end-to-end scenario sample based on the UServ Product Derby Case Study used at the Business Rules Forum. In this sample, the WF Rules Engine is used to model the rules for some key scenarios in this case study and perform the processes in the company such as -
Verification and approval of a new client application
Determine the eligibility of a client to obtain vehicle insurance
Determine the Premium for Vehicle Insurance
Building WF-Powered Services
This is a basic presentation I use for introducing the WF-WCF integration in the .NET 3.5.
What is the context of this conversation?
The .NET Framework 3.5 will introduce the functionality to call services from Windows Workflow Foundation (WF), and to expose workflows as a Windows Communication Foundation (WCF) service. A common pattern is to have a workflow serve as the coordinator between a number of other processes (including workflows). This talk will discuss how these conversations are implemented in WF, and common patterns for conversing over a long period of time, including asynchronous messaging, long-running cancellable work, managing m-of-n responses and check pointing of progress.
Demonstrating the New WF/WCF Content in Orcas with DinnerNow
This deck walks through a number of the new features for WF and WCF in the .NET Framework 3.5 including:
JSON encoding for WCF
HTTP Programming Model
Partial Trust for WCF
This is discussed within the context of the DinnerNow demo.
WF Building Activities
An introductory deck on the idea behind activities and developing them
WF Rules Use and Extensibility
An introduction to developing using the rules engine inside Windows Workflow Foundation, including a tour of the programmatic extensibility mechanisms.
Nov 22 2008 at 5:36 AM
, version 17
Sign in to add a comment
Tue Oct 7 2008 at 7:00 AM
More Tags ...
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.