Microsoft's workflow engine: Windows workflow foudation

Source: Internet
Author: User
Microsoft's workflow engine: Windows workflow foudation

This is the original article:

Https://msdn.microsoft.com/windowsvista/building/workflow/default.aspx? Pull =/library/en-US/dnlong/html/wwfgetstart. asp

This is

Http://www.microsoft.com/downloads/details.aspx? Familyid = 7096d039-2638-4f63-8654-d2e5d98fa417 & displaylang = en

This development environment needs to be installed in vs2005.

You can select the host of your workflow engine.

He mainly processes two types of workflows: sequential workflow and state machine workflow ):

ASequential WorkflowIs 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.

AState Machine WorkflowIs 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.

There is a visual design interface. Just like designing An ASPX page, you can drag and drop various activities as controls. Each work item is like a control, and the workflow is a form that can be directly written.CodeFor example, MessageBox. Show.
To continue with the Windows Forms analogy, a workflow is like a form, whereas activities are like controls.
This form can also be saved in XML format, but the. CS file still looks like that. This is what he actually did.

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 );

You can configure an endpoint debugging workflow.

Data transmission: There are two methods: Param and event. You can set the required param (that is, some common attributes)
The provision and processing of data is still done by the host. For example, if a lower parameter is required, the host time should be linked to workflow. The following is the event processing code of a button in a form (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 );

In terms of process processing, It is very powerful and can be designed with over 30 types, such as ifelse, while, waitfordata, suspend, listen, delay, and eventdriven.

Develop an activity:
Public partial class sendmailactivity: system. workflow. componentmodel. Activity
{
Public sendmailactivity ()
{
Initializecomponent ();
}

Protected override status execute (activityexecutioncontext context)
{
:
}
}

It is troublesome to initialize a state machine workflow:

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 );
}
In. net2.0, eventhandler actually expanded its functions.

This is one step.

Private guid startorderworkflow (string orderid) {// create a new guid for the workflowinstanceid guid instanceid = guid. newguid (); // load the orderworkflows Assembly ASM = assembly. load ("orderworkflows"); // get a type reference to the orderworkflows. workflow1 class type workflowtype = ASM. getType ("orderworkflows. workflow1 "); // start a new instance of the state machine with state tracking support statemachineinstance statemachine = _ statemachinetrackingservice. registerinstance (workflowtype, instanceid); statemachine. statechanged + = new eventhandler (statemachine_statechanged); statemachine. startworkflow (); _ statemachineinstances. add (instanceid. tostring (), statemachine); // return the workflow guid return instanceid ;}










It can be integrated with other Microsoft products, such as BizTalk and office.
Compared with other workflow engines, such as osworkflow, Microsoft has powerful functions.


































Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.