These functions are available in Workflow Engine ≥ 4.0
Scheme inlining is embedding one scheme into another. You can check almost any scheme as available for inlining and then embed it into other schemes. First of all such mechanism is necessary to re-use typical scheme segments. Inlining is embedding one scheme into another one. The scheme the process will work with is the result of transferring objects of the scheme which is being inlined (inlined scheme) into the scheme, code of which is used to create the process (target scheme).
Inlined scheme is checked as available for inlining in the designer. There's a special button for this in the toolbar.
There are two required conditions for the scheme to be inlined:
After you have checked the scheme as available for inlining (can be inlined), you must save it. To embed the inlined scheme into the target scheme do the following: when editing the target scheme add Inline Activity by clicking the appropriate button on the toolbar.
After Inline Activity has been added into the scheme, it works the same way as any typical Activity, which means that transitions can enter and exit it normally.
One of the key differences is that Inline Activity has only two properties:
Name
- inline nameInline scheme
- inlined scheme codeWhen embedding the inlined scheme into the target scheme, transitions belonging to the target scheme are relinked to the Activities of the inlined scheme. Transitions entering the inlined scheme (i.e. transitions into the relevant Inline Activity) will be completed in the initial activity of the inlined scheme. Transitions exiting the inlined scheme (transitions out of the relevant Inline Activity) will start in the first final activity of the inlined scheme, if the Inlined Final Activity Name
field has not been filled for these transitions. If the Inlined Final Activity Name
field has been filled, these transitions will start in the appropriate Activity of the inlined scheme.
When the target scheme is saved in the designer, the designer checks whether it is possible to combine target scheme and inlined scheme. If not, error is displayed. Workflow Engine supports multi-level inlining when one scheme is inlined into another, and this other scheme is in its turn inlined into the third scheme. There can be an unlimited number of Inline Activities connected to any inlined schemes in the target scheme.
Two columns were added into the WorkflowScheme
table to ensure correct inlining:
CanBeInlined
- signifies that the scheme can be inline into other schemes. InlinedSchemes
- is a list of schemes that are inlined into the current scheme. This field is in JSON array format, for example: ["ThirdSimpleInline","SecondSimpleInline","FirstSimpleInline"]
.Inlining is executed via special system build step. When embedding the inlined scheme into the target scheme the following transformations of the inlined scheme elements take place:
Rule
property was linked to the Code action from the inlined scheme, the link will be replaced with the new name, the rest of the properties remain unchanged. Implementation
or PreExecutionImplementation
was linked to the Code action from the inlined scheme, the link will be replaced with the new name. The IsInitial
property is always defined false. The IsFinal
property defined false, if there is at least one transition from this Activity in the result scheme. The rest of the properties remain unchanged, including the State
property.We have deliberately not described the CodeActions, Actors, Activities and Transitions renaming algorithm, as new names are too complex (especially in case of multi-level inlining), and the renaming algorithm might change. Instead, we have added several properties into each element, which make it searchable, if you know element original name in the inlined scheme. They are described in the next section.
Use the following attributes to search for inlined elements of the scheme:
Hereby codeActionDefinition
is an object of the CodeActionDefinition
type. Get the code actions list:
List<CodeActionDefinition> codeActions = processInstance.ProcessScheme.CodeActions;
Additional properties:
codeActionDefinition.WasInlined
- will return true, if this element was inlined when building the scheme codeActionDefinition.OriginalName
- Code Action name in the inlined scheme.codeActionDefinition.OriginalSchemeCode
- the inlined scheme code, i.e. the code of the scheme the Code Action originally belonged to Hereby actorDefinition
is an object of the ActorDefinition
type. Get the actors list:
List<ActorDefinition> actors = processInstance.ProcessScheme.Actors;
Additional properties:
actorDefinition.WasInlined
- will return true, if this element was inlined when building the scheme actorDefinition.OriginalName
- Actor name in the inlined scheme.actorDefinition.OriginalSchemeCode
- the inlined scheme code, i.e. the code of the scheme the Actor originally belonged to Hereby activityDefinition
is an object of the ActivityDefinition
type. Get the activities list:
List<ActivityDefinition> activities = processInstance.ProcessScheme.Activities;
Additional properties:
activityDefinition.WasInlined
- will return true, if this element was inlined when building the schemeactivityDefinition.OriginalName
- Activity name in the inlined scheme.activityDefinition.OriginalSchemeCode
- the inlined scheme code, i.e. the code of the scheme the Activity originally belonged to activityDefinition.FirstTimeInlineName
- name of the Inline Activity instead of which the element was inlined for the first time activityDefinition.LastTimeInlineName
- the name of the Inline Activity instead of which the element was inlined for the last time. This value will be equal toactivityDefinition.FirstTimeInlineName
for one-level inlining. Hereby transitionDefinition
is an object of the TransitionDefinition
type. Get the transitions list:
List<TransitionDefinition> transitions = processInstance.ProcessScheme.Transitions;
Additional properties:
transitionDefinition.WasInlined
- will return true, if this element was inlined when building the schemetransitionDefinition.OriginalName
- Transition name in the inlined scheme.transitionDefinition.OriginalSchemeCode
- the inlined scheme code, i.e. the code of the scheme the Transition originally belonged to transitionDefinition.FirstTimeInlineName
- name of the Inline Activity instead of which the element was inlined for the first time transitionDefinition.LastTimeInlineName
- the name of the Inline Activity instead of which the element was inlined for the last time. This value will be equal to transitionDefinition.FirstTimeInlineName
for one-level inlining. When the inlined scheme in saved the designer, the IsObsolete
property will be automatically applied to all linked schemes. This link is defined by the InlinedSchemes
field in the WorkflowScheme
table. Use the following code to specify the IsObsolete
property manually:
var runtime = WorkflowInit.Runtime;
var codesForObsolete = runtime.Builder.GetRelatedByInliningSchemeCodes(schemeCode);
runtime.SetSchemeIsObsolete(schemeCode);
if (codesForObsolete != null)
{
foreach (var code in codesForObsolete)
{
runtime.SetSchemeIsObsolete(code);
}
}
Thus you can get the linked schemes code list by calling the runtime.Builder.GetRelatedByInliningSchemeCodes(schemeCode)
method.