1. Using workflows under WinForm (Web program)
How can I make a WinForm or Web page form block waiting for a workflow to continue like a console?
2. Bookmark bookmarks
Bookmarks: and general bookmarks when reading a book, it is convenient to view the last look, the bookmark in the workflow means to pause the workflow and wait for the user to continue working in the current state.
3, the creation of bookmarks
Right-click in the project → add New item → code activity. A base class with the name bookmarkcodeactivity.cs//code activity is codeactivity
The following code is a code activity that is created
namespaceeazybpms.workflow{ Public Sealed classceshi:codeactivity {//defines an activity input parameter for a string type Publicinargument<string> Text {Get;Set; } //If the activity returns a value, the codeactivity<tresult>//and returns the value from the Execute method. protected Override voidExecute (Codeactivitycontext context) {//gets the run-time value of the Text input parameter stringText = context. GetValue ( This. Text); } }}
But if you use it as a bookmark, you must make the following changes
1. Change the base class to change the CodeActivity to Nativeactivity
2. Overriding attribute Caninduceidle
3, modify the incoming parameters Codeactivitycontext modified to Nativeactivitycontext
4. Create bookmarks
namespaceeazybpms.workflow{//1. Change the base class to change the codeactivity to Nativeactivity//2. Overriding attribute Caninduceidle//3, modify the incoming parameters Codeactivitycontext modified to Nativeactivitycontext//4. Create Bookmarks Public Sealed classWaitinputdataactivity<t>: nativeactivity {//This property means whether the workflow is allowed to idle/pause protected Override BOOLCaninduceidle {Get { return true; } } //defines an activity input parameter for a string type Publicinoutargument<string> BookmarkName {Get;Set; } PublicOutargument<t> Outresult {Get;Set; } //If the activity returns a value, the codeactivity<tresult>//and returns the value from the Execute method. protected Override voidExecute (Nativeactivitycontext context) {//gets the run-time value of the BookmarkName input parameter stringText = context. GetValue ( This. BookmarkName);
Context. CreateBookMark (text,NewBookmarkcallback (mycallback)); } //Pass the data passed in as the value of the output parameter Outresult to the outside of the bookmark Private voidMycallback (nativeactivitycontext context, bookmark bookmark,Objectvalue) { vardata = value asBaseresumebookmarkvalue; if(Data! =NULL) {context. SetValue (Outresult, (T) data.value); Context. SetValue (BookmarkName, data. BookmarkName); } } }}
ASP. NET Workflow Workflow actual combat bookmarks (ii)