Parallel Branches. Continued
Reading time: 5 minutes 13 seconds
Introducing Formengine - The New Formbuilder, try for FREE formengine.io.
Reading time: 5 minutes 13 seconds
Feel free to download the source code.
Since version 1.5 Workflow Engine comes with an ability to define and use forks (parallel processes). Each fork defines a sub-process.
This article explains how to define, use and control parallel branches. You may find an example in the Alternative to Windows Workflow Foundation article.
Warning: the functional doesn’t work with the free license of Workflow Engine. It requires more limits of the scheme. The sample has a trial license key that allows you to use this functionality.
We added some flags to Transitions for parallel branches.
Let’s create the scheme of the process with a root process and two sub-processes.
Commands:
Root Process
Activities:
If you want to create transitions between activities, use the “approve” command for direct transition and the “denied” command for reverse.
Sub-process “RollBack”
This process is used to execute a rollback.
Activities:
The process starts with MainState1 activity and it has two transitions:
The incoming transition:
The outcoming transition:
Sub-process "FastApprove"
This process is used to execute fast approve and to change the state of the main process to Final.
Activities:
The process starts with Draft activity and it has two transitions:
The incoming transition:
The outcoming transition:
As a result, your scheme should look like this.
Operation:
0 - CreateInstance
1 - GetAvailableCommands
2 - ExecuteCommand
3 - GetAvailableState
4 - SetState
5 - DeleteProcess
9 - Exit
The process isn`t created.
CreateInstance - OK.
ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: Draft, CurrentActivity: Draft
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:approve
ExecuteCommand - OK.
ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: MainState1, CurrentActivity: MainState1
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- denial (LocalizedName:denial, Classifier:Reverse)
- rollback (LocalizedName:rollback, Classifier:Reverse)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:fastapprove
ExecuteCommand - OK.
ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: Final, CurrentActivity: Final
Enter code of operation:4
Available state to set:
- Draft
- MainState1
- MainState2
- Final
Enter state:draft
SetState - OK.
ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: Draft, CurrentActivity: Draft
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:approve
ExecuteCommand - OK.
ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: MainState1, CurrentActivity: MainState1
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- denial (LocalizedName:denial, Classifier:Reverse)
- rollback (LocalizedName:rollback, Classifier:Reverse)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:approve
ExecuteCommand - OK.
ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: MainState2, CurrentActivity: MainState2
Enter code of operation:2
Available commands:
- approve (LocalizedName:approve, Classifier:Direct)
- denial (LocalizedName:denial, Classifier:Reverse)
- rollback (LocalizedName:rollback, Classifier:Reverse)
- fastapprove (LocalizedName:fastapprove, Classifier:Direct)
Enter command:rollback
ExecuteCommand - OK.
ProcessId = 'c3b6c1c2-a2b8-4ae0-b208-72351cdc9f43'. CurrentState: Draft, CurrentActivity: Draft