I found three instances that run WF under ASP. NET and all of them run successfully on my computer. Two of them are found online at the following addresses:
WF (Windows Workflow Foundation) workflow Learning (1) an ASP. NET state machine verification program and
WF (Windows Workflow Foundation)Workflow Learning (2) an ASP. NETExample of combining with a sequential Workflow
The two examples show how to run a state machine workflow and a sequence workflow in Asp.net. Both instances are very simple. I didn't talk too much about it, but through this example we know that WF and Asp.net can be combined, which is the motivation for our continued research.
The third example is found in the book, titled Windows Workflow Foundation next-generation workflow development transaction. In section 8.3 of this book, there is a combination of ASP. NET ApplicationsProgramExamples of developing WF. (In fact, this project is to modify the WF application instance "orderingstatemachine" officially provided by WF. WFCodeThe instance can be from: http://www.microsoft.com/downloads/en/details.aspx? Familyid = 35ec8682-d5fd-4bc3-a51a-d8ad115a8792 & displaylang = EN download) I have been running on my computer. A better place is that I can control page jumps through WF. As shown in the following four figures.
This is a workflow instance for member renewal application. The START workflow status is "waiting for Members to enter the status". In Figure 1, enter the member number and click "Start application process". Then, the workflow jumps to Figure 2, after you click "process application process" in Figure 2, the workflow jumps to the status in figure 3. In Figure 3, click "apply for completion reply" and the workflow ends. This will jump to the progesscomplete. ASPX page. The previous figure 1-3 shows the default. aspx page, and figure 4 jumps to the new page, which is controlled by the workflow.
Figure 1
Figure 2
Figure 3
Figure 4
1. overall architecture of the third case project
First, explain the project structure, as shown in the structure:
Figure 1
The solution consists of two projects: ASP. NET web application webapplication1 and workflowlibrary1. Webapplication1 is the foreground interface of the project and serves as the host application of the workflow. Therefore, we will reference the workflow class library workflowlibrary1 in webapplication1. As shown in:
Figure 2
2. Analysis of workflow class library workflowlibrary1
This case is an application of the approval process, which is divided into four states: waiting for Members to enter the status, starting the application form, processing the application form, and processing the application. As shown in.
Figure 3
Add the eventdriven control in the status, such as prcreatedevent, and add the external event handelexternaleventactivity to be triggered in eventdriven, as shown in:
Figure 4
As shown in, after handelexternaleventactivity1 is executed, the workflow will automatically execute setstateactivity1, that is, change the workflow status from "waiting for member input status" to "Start Application Form ". This is determined by the connections between workflow states.
For each handelexternaleventactivity, you must configure its event name eventname and interface type interfacetype. As shown in:
Figure 5
These are all defined in iprogressservice. iprogressservice is equivalent to defining a contract to describe the introduced events and types. For example, you have created the workflow data event parameter class ordereventargs in iprogressservice, which inherits from the external data event parameter class: externaldataeventargs, and then created a workflow data communication interface iprogressservice, in which the event ordercreated is defined.
We define a contract, an event parameter class, and all the metadata required for the workflow to receive events. Next, we need to talk about service implementation. The service implementation is written in progressservice. The progressservice class implements the iprogressservice interface, and defines the process of event triggering. For example:
Public void raiseprogresscreatedevent (string orderid, guid instanceid ){}
3. webapplication1 host Application Analysis
Webapplication1 is a Host application used to call the workflow class library. In this example, default. aspx is the homepage of the presentation layer. The workflow execution logic is defined in default. aspx. CS.
First, we need to add externaldataexchangeservice to the runtime (workflowruntime. Externaldataexchangeservice manages the local communication service of the host, which is defined as follows in iprogressservice:
[Externaldataexchange]
Public interface iprogressservice
The [externaldataexchange] above indicates that the local communication service is defined.
The manualworkflowschedulerservice class provides a thread service that allows you to create the Host application of a workflow instance and specify the thread used to run the workflow instance. This is to consider the situation where multiple users call workflow instances. We only need to know that the workflow instance can be started through the object of this class.
The externaldataexchangeservice class indicates a service that must be added to the workflow runtime engine to enable local service communication. To correctly initialize and register these services, you must add the local service implementation to externaldataexchangeservice. Our local service is progressservice, so the progressservice will be added to externaldataexchangeservice in the program, while externaldataexchangeservice will be added to workflowruntime.
Externaldataexchange and externaldataexchangeservice are paired. Only the local service defined as [externaldataexchange] can be added to externaldataexchangeservice.