[Translator Press] Andy Li's article is the best and most thorough article I've ever seen about the SharePoint workflow architecture. By reading his article, I was clearly aware of the workings of SharePoint workflow and knew how to find a problem when I encountered a problem. Therefore, I hope to be helpful to the developers of workflow.
This blog is made up of Andy Li contribution, he was SharePoint Developer Support Group of engineers who handle difficult issues. The original address. This series on Workflow , which he contributed to the community, helped us to better understand the internal mechanisms of the Workflow Runtime and how to SharePoint interaction.
This article is translated by Spfarmer.
SharePoint and the Workflow Runtime the combination
The following diagram describes the SharePoint Workflow several chunks of the component. I'll start with a brief explanation of the data flow, and then in the next few chapters, I'll cover each part in detail.
First think about how you started a workflow the.
This section is about the module in the diagram above, the blue arrow pointing to the left part.
1. First you're in List library workflow page Click link to this list library workflow workflow initial form initiation Form, If you have this Workflow )
2. After submitting the initial form (Initiation form), the message was sent to spworkflowmanager . spworkflowmanager is in the sharepointobject Model , the only thing you can use to start a The object for the workflow sample.
3. SPWorkflowManager then notifies the SharePoint workflow Runtimeobject (spwinoehostservice ) requires a workflow instance to be started .
4. Spwinoehostservice 's function is to notify Windows Workflow Runtime to really start Workflow Instance . This is done by first calling the System.Workflow.WorkflowRuntime.CreateWorkflow () , and then call System.Workflow.WorkflowInstance.Start (). to achieve.
Another common scenario is to submit a Workflow task .
A lot of people are hard to understand Task How the data is transmitted to Workflow instance of the. This is actually the most complicated place for sharepointworkflow, because this involves workflowruntime and SharePoint a lot of modules. I'll explain the data flow in a nutshell, and then explain the details in a few blog posts later .
1. This process starts when you open a form that workflow a task .
2. If you have a custom task form, you usually call spworkflowtask.altertask () To commit the changes to this task . The API then calls splistitem.update () to commit the changes . If you don't have a custom Task form, then oobsharepoint Task in essence, doing the same thing . .
3.the data fromTaskpassedWorokflowthe mechanism is througheventreceivers.realized, you may have thought of it. Yes, this isTaskHow data is passed toWorkflowof the. I'll explain .Event Receiversis how to be registered toTaskson the.Now you're going to need to know that each oneWorkflowTaskall have aEventreceiverwasHookon top. The aim is toTaskthe changes that are passed to the correspondingWorkflowinstance.
4. Event receiver call spworkflowmanager ( Yes, it's the only way to call workflowruntime object) private method spworkflowmanager.runworkflow () .  that is to say, as a developer, you can only call spworkflowtask.altertask ()     splistitem.update ()  
Note : SharePoint has introduced a new concept called pluggableservice, to achieve Workflow can interact with any external service , such as custom Wcfservice, and so on . in the SharePoint2007 , this is impossible, in SharePoint2007 , only through Sharepointtask Two and Workflow Communication . in the chart, Spworkflowexternaldataexchangeservice is used to pass custom events to workflow. Essentially, this and passing task workflow is the same, so here we use our own task
5. the spworkflowmanager then passes the data to sharepointworkflow runtime , and then find out who the data should be passed down to. For example, this is a task, or a normal item. based on the type of data, the corresponding Dataexchange Service will continue to pass the data.
6. all data Exchange Services , even if based on Workflow Communication Services . in the SharePoint inside ,Microsoft.SharePoint.Workflow.ITaskService is in Workflow and the SharePoint interface for exchanging data between We'll discuss more later.
SharePoint Workflow Architecture (i) combination of SharePoint and workflow runtime