In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to implement the subprocess in WF 4.0.This article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
In WF 4. 0, there are different kinds of processes.
In workflow services, some subprocesses are often enabled in the main process. I often use bookmark to pause the process in the approval process, and this article will combine bookmark to implement the main process promoter process.
Use custom persistence from a previous article on WF4.0 custom persistence. However, a field parentid has been added to the data table to identify the parent process:
Take a process example as an example to illustrate how the main process enables the subprocess, and how the subprocess returns to the main process. The main process is as follows:
The * site audit "and the third node" second station audit "are both BookMark bookmarks. The code with BookMark is as follows:
Code
Public sealed class Read: NativeActivity {public Read (): base () {} public string BookmarkName {get; set;} / / Define an activity input argument of type string public InArgument Text {get; set;} / / Must return true for a NativeActivity that creates a bookmark protected override bool CanInduceIdle {get {return true } protected override void Execute (NativeActivityContext context) {context.CreateBookmark (this.BookmarkName, new BookmarkCallback (this.Continue));} void Continue (NativeActivityContext context, Bookmark bookmark, object obj) {this.Result.Set (context, (TResult) obj);}
The second node, "enable subprocess", is a custom node with the following code:
Code
Public sealed class CallChild: Activity {public string FlowName {get; set;} public CallChild () {base.Implementation = new Func (CreateBody) } public Activity CreateBody () {return new Sequence {DisplayName = "subprocess" Activities = {new ChildCodeActivity {FlowName=this.FlowName} New Read {BookmarkName= "CallChild",} }}
Notice that the ChildCodeActivity class above actually starts the subprocess in ChildCodeActivity, followed by a bookmark to pause the main process. When the subprocess is completed, the bookmark is restored in the subprocess, the subprocess ends, and the main process continues to run down. There is a FlowName attribute in this activity that indicates which subprocess is enabled. The ChildCodeActivity code is as follows:
Code
Sealed class ChildCodeActivity: CodeActivity {/ / Define an activity input argument of type string public string FlowName {get; set;} / / If your activity returns a value, derive from CodeActivity / / and return the value from the Execute method. Protected override void Execute (CodeActivityContext context) {Guid ChildGuid; ChildGuid = WorkFlowRun.CreateAndRun (FlowName); InstancesTable obj = InstancesTableBiz.GetInstancesTable (ChildGuid); / / id obj.parentid = context.WorkflowInstanceId; InstancesTableBiz.UpdateInstancesTable (obj) of the child process; / / follow the new parent process id}}
WorkFlowRun.CreateAndRun (FlowName) starts the corresponding sub-process according to the FlowName and gets the Guid of the instance. And change the parentid of the sub-process to the guid of the main process.
Examples of subprocesses are as follows:
The * nodes of the sub-process "sub-process * station audit" and the second node "sub-process second station audit" are also BookMark bookmarks.
* A node is "end". This node is also critical because I use this node to return from the subprocess to the main process. Therefore, each subprocess has an End node, and its code is as follows:
Code
Public sealed class End: CodeActivity {/ / Define an activity input argument of type string public InArgument Text {get; set;} / / If your activity returns a value, derive from CodeActivity / / and return the value from the Execute method. Protected override void Execute (CodeActivityContext context) {/ / Obtain the runtime value of the Text input argument string text = context.GetValue (this.Text); Guid id = context.WorkflowInstanceId; InstancesTable Obj = InstancesTableBiz.GetInstancesTable (id) If (Guid.Empty! = Obj.parentid) / / if it is a child process, return the parent process {WorkFlowRun.Submit (Obj.parentid, "ParentProcess", "returnMain");}
This is a solution that I came up with to enable a sub-process in WF4.0. If you have any better plans and suggestions, please leave me a message, thank you.
Original title: implementation of subprocesses in WF4.0
Link: http://www.cnblogs.com/zhuqil/archive/2010/01/31/SubProcessDemo.html
This is the answer to the question about how to realize the sub-process in WF 4.0. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 277
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.