Slickflow.NET open source workflow engine Quick Start II: Simple parallel branch flow coding examples

Introduction: For developers eager to understand the function of the engine, after the download version, wanted to try to write code to complete a process of development and testing. This paper attempts a simple process to parallel branches example shows how to write engine to quickly understand code.

1. Create a branch of the process graphics

      Branched process flow is common decision classes, different decision process for handling traffic scenarios appears, and wherein each branch can be seen as a fragment of a serial process.

 var pmb = ProcessModelBuilder.CreateProcess("process-split-name", "process-split-code");
var process = pmb.Start("Start")
                         .Task("Task-001")
                         .AndSplit("Split")
                         .Parallels(
                               () => pmb.Branch(
                                   () => pmb.Task("Task-100")
                               )
                               , () => pmb.Branch(
                                    () => pmb.Task("Task-200")
                                )
                         )
                         .AndJoin("Join")
                         .Task("Task-500")
                         .End("End")
                         .Store();

  

   The above code creates a parallel branch of the process, there are two branches, and the branch is a parallel branch (AndSplit-AndJoin), a flowchart of an example as follows:

2. The process up and running

      The process is up and running two most commonly used API interface.

2.1 Start Process

      Start to be addressed is to create a process instance, as well as create a task node after the start node and start node, sample code as follows:

 IWorkflowService wfService = new WorkflowService();
 var wfResult = wfService.CreateRunner("10", "jack")
             .UseApp("DS-100", "Book-Order", "DS-100-LX")
             .UseProcess("process-split-code")
             .Start();
    

      Examples of activity record table as follows:

 

  2.2 processes run

      The process is run by the current to-do began to go and run to the next step of the process. Usually need to explicitly specify the next transfer path list (NextActivityTree), can be exemplified here as a simple example of a single step operation:

IWorkflowService wfService = new WorkflowService();
var wfResult = wfService.CreateRunner("10", "jack")
             .UseApp("DS-100", "Book-Order", "DS-100-LX")
             .UseProcess("process-split-code")
             .OnTask(8004)
             .NextStepInt("20", "Alice")
             .Run();

      Examples of activity record table as follows:

3. The process of withdrawal and return  

3.1 Process revoked

       If the user complete their to-do, and the next issue to deal with people found to have an error message, if necessary revoked, can be initiated by themselves, will withdraw the current process back. When revocation of the parallel branches, when two parallel branches will be simultaneously retracted and revocation status set indicating a branch is strongly associated with two types of activities.

IWorkflowService wfService = new WorkflowService();
var wfResult = wfService.CreateRunner("10", "Jack")
              .UseApp("DS-100", "Book-Order", "DS-100-LX")
              .UseProcess("process-split-code")
              .OnTask(8004)             //TaskID
              .Withdraw();

   Examples of activity record table as follows:

  3.2 Return Process

       Return process is initiated by the task of handling the current to-do people, to return to the previous step of the process. If the parallel branches of one of the branches return process, this time, the default task only return to the gateway node before the current branch, and will not affect the other branches.

IWorkflowService wfService = new WorkflowService();
var wfResult = wfService.CreateRunner("20", "Alice")
          .UseApp("DS-100", "Book-Order", "DS-100-LX")
          .UseProcess("process-split-code")
          .PrevStepInt()
          .OnTask(8009)             //TaskID
          .SendBack();

  Examples of activity record table as follows:

  4. Summary

      The above code can help developers to quickly become familiar with the interface and useful features simple branch of engine components, full functionality will be available at the Enterprise Edition version above. Parallel branch and revocation of return because of concerns of neighboring processing branch, the process inside the engine is rather special. Here, only the description of the results recorded after the return, the internal processing logic will return in the future arrangements for another article specifically go introduction.

Guess you like

Origin www.cnblogs.com/slickflow/p/11527264.html