這是下載地址
http://www.microsoft.com/downloads/details.aspx?familyid=7096d039-2638-4f63-8654-d2e5d98fa417&displaylang=en
這個開發環境需要安裝在vs2005里面。
可以選擇你的workflow引擎的Host
他處理的主要有兩類工作流:順序工作流( Sequential Workflow )和狀態機工作流( State Machine Workflow ):
A sequential workflow is ideal for operations expressed by a pipeline of steps that execute one after the next until the last activity completes. Sequential workflows, however, are not purely sequential in their execution. They can still receive external events or start parallel tasks, in which case the exact sequence of execution can vary somewhat.
A state machine workflow is made up of a set of states, transitions, and actions. One state is denoted as a start state, and then, based on an event, a transition can be made to another state. The state machine workflow can have a final state that determines the end of the workflow.
有可視化的設計界面,就像設計一個aspx頁面一樣,把各個活動( activities )當成控件向里拖放。每個工作項就像一個控件,那工作流則一個窗體,可以直接寫代碼,比如 MessageBox.Show.
To continue with the Windows Forms analogy, a workflow is like a form, whereas activities are like controls.
這個窗體也可以保存成xml格式的,但是.cs文件還是那樣子。這是他實際做的
this.Activities.Add(this.code1);
this.DynamicUpdateCondition = null;
this.ID = "Workflow1";
FirstName.Direction = System.Workflow.ComponentModel.ParameterDirection.In;
FirstName.Name = "FirstName";
FirstName.Type = typeof(string);
可以設置端點調試工作流。
傳遞數據:有兩種方式Param 和 event ??梢宰约涸O置需要的Param (就是一些共有的屬性而以)
數據的提供和處理還是Host要做的,比如,要出低一些參數進來,還一個把Host上的時間聯系到workflow上。下邊是一個窗體(Host)的一個按鈕的事件處理代碼
Dictionary parameters = new Dictionary();
parameters.Add("FirstName", txtFirstName.Text);
parameters.Add("LastName", txtLastName.Text);
// Start the workflow
Guid instanceID = Guid.NewGuid();
_wr.StartWorkflow(workflowType, instanceID, parameters);
流程處理上,功能很強大,可以設計諸如 IfElse,while,WaitForData,Suspend,Listen,Delay,EventDriven 等30多種。
開發一個Activity:
public partial class SendMailActivity : System.Workflow.ComponentModel.Activity
{
public SendMailActivity()
{
InitializeComponent();
}
protected override Status Execute(ActivityExecutionContext context)
{
:
}
}
狀態機工作流比較麻煩,這是初始化一個狀態機工作流:
private void StartWorkflowRuntime()
{
// Create a new Workflow Runtime for this application
_runtime = new WorkflowRuntime();
// Register event handlers for the WorkflowRuntime object
_runtime.WorkflowTerminated += new
EventHandler (WorkflowRuntime_WorkflowTerminated);
_runtime.WorkflowCompleted += new
EventHandler (WorkflowRuntime_WorkflowCompleted);
// Create a new instance of the StateMachineTrackingService class
_stateMachineTrackingService = new StateMachineTrackingService(_runtime);
// Start the workflow runtime
_runtime.StartRuntime();
// Add a new instance of the OrderService to the runtime
_orderService = new OrderService();
_runtime.AddService(_orderService);
}
在.net2.0里面EventHandler其實做了功能上的擴充
這是其中一步的處理