Process scheme update
There are two strategies for updating the schemes of running processes:
- The old process uses the old scheme;
- The old process is updated on a new scheme.
Note that new processes always use new schemes in both strategies. Workflow Engine supports both strategies and their
combinations. On the other hand, the current or most actual version of a scheme is kept in the database table
Launching scheme update
Workflow Engine considers a scheme obsolete in case IsObsolete = true is attributed to it in the
table (scheme). This attribute is set by default by scheme designer upon its saving. This behavior may be changed by
DesignerAPI method in the following way (refer to the Designer
var res = WorkflowInit.Runtime.DesignerAPI(parameters, filestream, false);
You may also set the IsObsolete attribute by calling the following method:
In case you use a relational database, you may set the IsObsolete attribute with an SQL script.
If is needed to create a process or update the scheme of an existing process, but there are no up-to-date
(IsObsolete = false) schemes in the
WorkflowProcessScheme table (object), a scheme generator will be launched. Scheme
generator is an object implementing the
IWorkflowGenerator interface, which was conveyed to
during configuration. This object will generate a new up-to-date scheme and put it into the
table (object). Once the new scheme is created, the data related to it is saved and the scheme versioning is completed
accordingly by setting the field:
IsObsolete = false in this database table.
The old process uses a new scheme
Updating a scheme of the running process to a new scheme may be both manual and automatic.
Workflow Engine supports automatic update of a scheme to a new one upon receiving of the list of available commands. In
other words, if a scheme is obsolete, it will be updated for a certain process immediately after
WorkflowInit.Runtime.GetAvailableCommands(processId, identityId);. Thus, automatic update occurs in a lazy
mode when it is necessary. In order to enable automatic updates for schemes of existing processes, the following
conditions should be satisfied:
Update should be explicitly allowed during configuration of the
The Auto scheme update value of the Activity, in which a process scheme will be automatically updated, should equal true.
Manual scheme update occurs after calling the following
WorkflowRuntime object’s functions:
UpdateSchemeIfObsolete method version takes the Activity’s Auto scheme update property into
account. In case this property of the Current Activity equals false, a scheme won’t be updated. In order to ignore this
property’s value, use the following code:
After each process scheme update, the
OnSchemaWasChanged event is called, whose handler allows you to change the
current Activity of a process if it is not specified in the new scheme.
runtime.OnSchemaWasChanged += (sender, args) =>
var pi = runtime.GetProcessInstanceAndFillProcessParameters(args.ProcessId);
if (!pi.ProcessScheme.Activities.Any(a => a.Name == pi.CurrentActivityName))
var initialActivity = pi.ProcessScheme.InitialActivity;
pi.CurrentActivityName = initialActivity.Name;
The old process uses the old scheme
In case you don’t need to update schemes of running processes, simply do not enable automatic scheme update during
WorkflowRuntime initialization. In case you don’t explicitly enable it by calling
SwitchAutoUpdateSchemeBeforeGetAvailableCommandsOn configuration method, the schemes of the running processes
won’t be updated.