In this article, I handed over all the operations related to data processing in WF to WCF for processing. WF only cares about the design and processing of the process, and does not need to worry about how to operate the underlying data. This is very bigProgramReduces the coupling between applications.
Sendactivity: Client activity, used to simulate synchronous calls to WCF Service operations.
In WF, sendactivity can be used to call WCF, without the traditional method.CodeAnd then call the corresponding method. In the project, we rely on "handleexternalevent activity" to trigger external events, and write relevant business logic code in the events. The coupling degree is higher, because WF not only needs to design workflows, it also needs to deal with databases.
Solution: Add sendactivity after handleexternalevent activity. The only function of the event of handleexternalevent is to assign a value to the sendactivity parameter. As there are many statuses in the project, I will show the activity diagram of the employee status:
Sendactivity attribute settings:
1: channeltoken: The channeltoken used by sendactivity to establish an association between itself and the client channel.
2: Name: gets or sets the Instance name. This name must comply withProgramming LanguageVariable naming rules.
3: endpointname: the endpoint used to communicate with the service.
4: serviceoperationinfo: WCF Service Interface.
5: owneractivityname: name of the associated activity.
6: parameters in the method. This parameter must be supported by the background code, which is divided into two steps:
1. Create a new member:
Public StaticDependencyproperty sendactivityvalueproperty=
Dependencyproperty. Register ("Sendactivityvalue",
Typeof(Expenseaccountinfo ),
Typeof(Approveworkflow. myworkflowstatemachine. workflow1 ));
[Designerserializationvisibilityattribute (designerserializationvisibility. Visible)]
[Browsableattribute ( True )]
[Categoryattribute ( " Parameters " )]
Public Expenseaccountinfo sendactivity1value
{
Get
{
Return (Expenseaccountinfo )( Base . Getvalue (workflow1.sendactivityvalueproperty )));
}
Set
{
Base . Setvalue (workflow1.sendactivityvalueproperty, value );
}
}
Second, set parameters, such:
The sendactivity attribute setting interface is as follows:
WF code changes:The employee's Event code is as follows, and no Code related to the business logic is found. It only assigns a value to an attribute. All communication operations are handed over to sendactivity.
Private Void Onstaffsubmit_invoked ( Object Sender, externaldataeventargs E)
{
Info = E As Expenseaccountinfo;
Sendactivity1value = Info;
}
Changes in website structure after WCF is Enabled:When processing the approval process, the website UI (web page layer) only communicates with WF. WF is only responsible for process processing and does not care about the data processing process. WCF completes the requests sent by WF. The WF before transformation requires the design approval process and data processing.
Next debugging: To apply WCF to WF, the most important step is to add a reference to WCF. If this WCF is in IIS, that is, the address is fixed. After adding the reference, if we directly press F5 to run the solution, the application will dynamically allocate a port so that after the proxy class is generated, the endpoint is not in the configuration file, my solution is to directly add the project's WCF, and then start the WCF and web programs at the same time, that is, start multiple projects, so that you can debug the program to the server. Or the website program is also placed in IIS, and the website is opened from IIS, which avoids problems caused by dynamic application port.
Note:
Reference: http://www.cnblogs.com/foundation/archive/2008/05/23/1205430.html