Class ProcessInstance
OptimaJet.Workflow.Core.Model.ProcessInstance
Represents one execution of a scheme, with its own current activity, business state, and process parameters.
Namespace: OptimaJet.Workflow.Core.Model
public sealed class ProcessInstanceProperties
public Guid ProcessId { get; set; } #Gets or sets the identifier of this process instance.
public Guid? ParentProcessId { get; set; } #Gets or sets the identifier of the immediate parent process instance, or null for a top-level process instance.
public Guid RootProcessId { get; set; } #Gets or sets the identifier of the top-level root process instance in the process hierarchy.
public Guid SchemeId { get; set; } #Gets or sets the identifier of the built process scheme version used by this process instance.
public string PreviousState { get; set; } #Gets or sets the business state from TransitionDefinition.From for the most recently executed transition whose source activity has a nonempty ActivityDefinition.State.
public string ExecutedTimer { get; set; } #Gets or sets the name of the TimerDefinition that initiated the current transition execution.
public string PreviousStateForDirect { get; set; } #Gets or sets the business state from TransitionDefinition.From for the most recently executed TransitionClassifier.Direct transition whose source activity has a nonempty ActivityDefinition.State.
public string PreviousStateForReverse { get; set; } #Gets or sets the business state from TransitionDefinition.From for the most recently executed TransitionClassifier.Reverse transition whose source activity has a nonempty ActivityDefinition.State.
public string PreviousActivityName { get; set; } #Gets or sets the source activity name for the most recently executed transition.
public string PreviousActivityForDirectName { get; set; } #Gets or sets the source activity name for the most recently executed TransitionClassifier.Direct transition.
public string PreviousActivityForReverseName { get; set; } #Gets or sets the source activity name for the most recently executed TransitionClassifier.Reverse transition.
public string CurrentCommand { get; set; } #Gets or sets the name of the applicable CommandDefinition for the current execution.
public string IdentityId { get; set; } #Gets or sets the workflow participant identity of the executor that initiates the current execution.
public string ImpersonatedIdentityId { get; set; } #Gets or sets the workflow participant identity on whose behalf the current execution is performed.
public string ExecutedActivityState { get; set; } #Gets or sets the business state used while ProcessInstance.ExecutedActivity is executing. When the activity has no ActivityDefinition.State, Workflow Engine uses ProcessInstance.CurrentState.
public ActivityDefinition ExecutedActivity { get; set; } #Gets or sets the ActivityDefinition being executed.
public TransitionDefinition ExecutedTransition { get; set; } #Gets or sets the TransitionDefinition being executed.
public string CurrentActivityName { get; set; } #Gets or sets the name of the current ActivityDefinition.
public List<string> IdentityIds { get; set; } #Gets or sets the workflow participant identities resolved for transitions leading to activities along the path currently explored by pre-execution simulation. This value is populated only when ProcessInstance.IsPreExecution is true.
public List<string> IdentityIdsForCurrentActivity { get; set; } #Gets or sets the workflow participant identities that can execute a transition from the current activity. Unlike ProcessInstance.IdentityIds, this property applies only to the current activity rather than the entire simulated path. This value is populated only when ProcessInstance.IsPreExecution is true.
public string SchemeCode { get; set; } #Gets or sets the code of the process scheme used by this process instance.
public string CurrentState { get; set; } #Gets or sets the current business state name of this process instance.
public string TenantId { get; } #Gets the tenant identifier assigned to the process instance.
public string StartTransitionalProcessActivity { get; set; } #Gets or sets the name of the activity from which transitional execution started. When no value is stored, the getter returns ProcessInstance.CurrentActivityName.
public ActivityDefinition CurrentActivity { get; } #Gets the ActivityDefinition in ProcessInstance.ProcessScheme identified by ProcessInstance.CurrentActivityName.
Exceptions
Type
Description
ActivityNotFoundExceptionNo activity in ProcessInstance.ProcessScheme is named ProcessInstance.CurrentActivityName.
public bool IsPreExecution { get; set; } #Gets or sets a value indicating whether the process instance is being evaluated in pre-execution simulation.
public string SubprocessName { get; set; } #Gets or sets the name assigned to this subprocess by the starting TransitionDefinition.SubprocessName.
public DateTime CreationDate { get; set; } #Gets or sets the date and time when the process instance was created.
public DateTime? LastTransitionDate { get; set; } #Gets or sets the date and time of the most recent transition execution.
public DateTime? StartTransitionTime { get; set; } #Gets or sets the date and time when the current transition execution started.
public bool LogEnabled { get; set; } #Gets or sets a value indicating whether logging is enabled for this process instance. When no instance override exists, the getter returns ProcessDefinition.LogEnabled from ProcessInstance.ProcessScheme.
public string ActionParameterBeforeSubstitution { get; set; } #Gets or sets the current action parameter before process parameter placeholders are substituted.
public string CalendarName { get; set; } #Gets or sets the work calendar name assigned to the process instance.
public IWorkflowExternalParametersProvider ExternalParametersProvider { get; } #Gets the IWorkflowExternalParametersProvider configured for the associated WorkflowRuntime.
public ProcessDefinition ProcessScheme { get; set; } #Gets or sets the built ProcessDefinition associated with the process instance.
public bool IsSchemeObsolete { get; } #Gets a value indicating whether the associated process scheme version is obsolete.
public bool IsSubprocess { get; } #Gets a value indicating whether this process instance is a subprocess, as identified by a non-self ProcessInstance.ParentProcessId.
public ParametersCollection ProcessParameters { get; } #Gets the ParametersCollection owned by the process instance.
public ParametersCollection MergedSubprocessParameters { get; } #Gets the ParametersCollection from a subprocess that was merged into the current process instance.
public dynamic this[string name, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary] { get; set; } #Gets or sets the value of a process parameter or nested parameter property.
public Localizer Localizer { get; } #Gets a ProcessInstance.Localizer that searches the localization sources from ProcessInstance.ProcessScheme and the associated WorkflowRuntime.
Methods
public static ProcessInstance Create(WorkflowRuntime runtime, Guid schemeId, Guid processId, ProcessDefinition processScheme, bool isSchemeObsolete, string tenantId = null, string calendarName = null) #Creates a process instance for
processScheme and associates it with runtime.Parameters
Name
Type
Description
schemeIdGuidThe identifier of the built process scheme version to assign to ProcessInstance.SchemeId.
processSchemeProcessDefinitionThe built ProcessDefinition to assign to ProcessInstance.ProcessScheme.
tenantIdStringThe tenant identifier to assign to ProcessInstance.TenantId. A null, empty, or white-space value is stored as null.
Returns
Type
Description
ProcessInstanceThe created ProcessInstance.
Exceptions
Type
Description
LicenseExceptionThe number of activities, transitions, or commands in
processScheme exceeds the applicable license limit.public string GetSchemeCodeForActionCall() #Gets the process scheme code used when invoking code actions.
Returns
Type
Description
StringProcessDefinition.RootSchemeCode when ProcessDefinition.IsSubprocessScheme is true and the root scheme code is not empty; otherwise, the name of ProcessInstance.ProcessScheme.
public void Save(WorkflowRuntime runtime) #Saves parameters whose ParameterDefinition.Purpose is ParameterPurpose.Persistence by using
runtime.Parameters
Name
Type
Description
runtimeWorkflowRuntimeThe WorkflowRuntime whose WorkflowRuntime.PersistenceProvider performs the save.
public Task SaveAsync(WorkflowRuntime runtime) #Asynchronously saves parameters whose ParameterDefinition.Purpose is ParameterPurpose.Persistence by using
runtime.Parameters
Name
Type
Description
runtimeWorkflowRuntimeThe WorkflowRuntime whose WorkflowRuntime.PersistenceProvider performs the save.
Returns
Type
Description
TaskA Task that represents the asynchronous save operation.
public ICalendar GetCalendar() #Gets the work calendar selected for the process instance.
Returns
Type
Description
ICalendarThe ICalendar from WorkflowRuntime.Calendars selected by ProcessInstance.CalendarName, ProcessDefinition.CalendarName, or WorkflowRuntime.DefaultCalendarName, in that order; or null if no matching calendar is registered.
public ProcessInstance Clone() #Creates a copy of this process instance with a cloned ProcessInstance.ProcessScheme, a recursively copied parent process hierarchy, and a separate ProcessInstance.ProcessParameters collection.
Returns
Type
Description
ProcessInstanceThe cloned ProcessInstance.
public void AddParameter(ParameterDefinitionWithValue parameter) #Adds a parameter to ProcessInstance.ProcessParameters, replacing any existing entries with the same parameter name.
Parameters
Name
Type
Description
public void AddParameters(IEnumerable<ParameterDefinitionWithValue> parameters) #Adds parameters to ProcessInstance.ProcessParameters, replacing existing entries whose names match the names in
parameters.Parameters
Name
Type
Description
public bool IsParameterExisting(string name) #Determines whether ProcessInstance.ProcessParameters contains a non-null parameter value or an existing nested parameter property identified by
name.public ParameterDefinitionWithValue GetParameter(string name) #Gets the parameter or nested parameter property identified by
name.Parameters
Name
Type
Description
nameStringThe parameter name or dot-separated path to a nested property.
Returns
Type
Description
ParameterDefinitionWithValueThe matching ParameterDefinitionWithValue, or null if no parameter is found or a nested value is null.
public Task<ParameterDefinitionWithValue> GetParameterAsync(string name) #Asynchronously gets the parameter or nested parameter property identified by
name.Parameters
Name
Type
Description
nameStringThe parameter name or dot-separated path to a nested property.
Returns
Type
Description
Task<ParameterDefinitionWithValue>A Task<TResult> whose result is the matching ParameterDefinitionWithValue, or null if no parameter is found or a nested value is null.
Exceptions
Type
Description
ArgumentExceptionname is null or empty.public T GetParameter<T>(string name) #Gets the value of the parameter or nested parameter property identified by
name.Parameters
Name
Type
Description
nameStringThe parameter name or dot-separated path to a nested property.
Returns
Type
Description
{T}The value as
T, or the default value of T if no value is found.Example
If the
Order parameter contains a nested Customer.Name property, processInstance.GetParameter<string>("Order.Customer.Name") returns that property's value.public Task<T> GetParameterAsync<T>(string name) #Asynchronously gets the value of the parameter or nested parameter property identified by
name.Parameters
Name
Type
Description
nameStringThe parameter name or dot-separated path to a nested property.
Returns
Type
Description
Task<T>Exceptions
Type
Description
ArgumentExceptionname is null or empty.Example
If the
Order parameter contains a nested Customer.Name property, await processInstance.GetParameterAsync<string>("Order.Customer.Name") returns that property's value.public void SetParameter<T>(string name, T value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary) #Sets the value of the parameter or nested parameter property identified by
name.Parameters
Name
Type
Description
nameStringThe parameter name or dot-separated path to a nested property.
value{T}The value to assign.
purposeIfMissingParameterPurposeThe ParameterPurpose to use when no definition exists in ProcessDefinition.Parameters. When
purposeIfMissing is ParameterPurpose.Persistence, a scheme-defined parameter that is not yet instantiated is also created as persistent.Example
processInstance.SetParameter("Order.Customer.Name", "Alice") assigns "Alice" to the nested Name property of Customer in the Order parameter.public Task SetParameterAsync<T>(string name, T value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary) #Asynchronously sets the value of the parameter or nested parameter property identified by
name.Parameters
Name
Type
Description
nameStringThe parameter name or dot-separated path to a nested property.
value{T}The value to assign.
purposeIfMissingParameterPurposeThe ParameterPurpose to use when no definition exists in ProcessDefinition.Parameters. When
purposeIfMissing is ParameterPurpose.Persistence, a scheme-defined parameter that is not yet instantiated is also created as persistent.Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ArgumentExceptionname is null or empty.Example
await processInstance.SetParameterAsync("Order.Customer.Name", "Alice") assigns "Alice" to the nested Name property of Customer in the Order parameter.public void SetImplicitSerializedParameter(string name, string value, ParameterPurpose purposeIfMissing = ParameterPurpose.Temporary) #Sets an implicit parameter from its JSON-serialized value.
Parameters
Name
Type
Description
nameStringThe name of the implicit parameter.
valueStringThe JSON-serialized parameter value.
purposeIfMissingParameterPurposeThe ParameterPurpose to assign if the implicit parameter must be created.
public void RemoveParameter(string name) #Sets the value of a process parameter or nested parameter property to null.
Parameters
Name
Type
Description
nameStringThe parameter name or dot-separated path to a nested property.
public void SetProcessParameters(List<ParameterDefinitionWithValue> parameters) #Replaces the contents of ProcessInstance.ProcessParameters with
parameters.Parameters
Name
Type
Description
parametersList<ParameterDefinitionWithValue>The ParameterDefinitionWithValue objects that become the collection contents.
public void InitPersistenceParametersFromScheme() #Initializes parameters whose definitions in ProcessDefinition.Parameters have ParameterDefinition.Purpose set to ParameterPurpose.Persistence and whose ParameterDefinition.InitialValue is not null.
Exceptions
Type
Description
InvalidJsonParameterValueExceptionA persistence parameter other than string has an initial value that cannot be deserialized from JSON.
public bool ExecuteConditionFromCodeActions(string name, WorkflowRuntime runtime, string parameter) #Evaluates the condition named
name in local or global code actions.Parameters
Name
Type
Description
nameStringThe name of the condition to evaluate.
parameterStringThe additional parameter passed to the condition.
Returns
Type
Description
BooleanThe condition result.
public Task<bool> ExecuteConditionFromCodeActionsAsync(string name, WorkflowRuntime runtime, string parameter) #Asynchronously evaluates the condition named
name in local or global code actions.Parameters
Name
Type
Description
nameStringThe name of the condition to evaluate.
parameterStringThe additional parameter passed to the condition.
Returns
Type
Description
Task<Boolean>A Task<TResult> whose result is the condition result.
Exceptions
Type
Description
NotImplementedExceptionNo condition named
name can be resolved.public void ExecuteCodeAction(string name, WorkflowRuntime runtime, string parameter) #Executes the action named
name in local or global code actions.Parameters
Name
Type
Description
nameStringThe name of the action to execute.
parameterStringThe additional parameter passed to the action.
public Task ExecuteCodeActionAsync(string name, WorkflowRuntime runtime, string parameter) #Asynchronously executes the action named
name in local or global code actions.Parameters
Name
Type
Description
nameStringThe name of the action to execute.
parameterStringThe additional parameter passed to the action.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
NotImplementedExceptionNo action named
name can be resolved.public string GetLocalizedStateName(string name, CultureInfo culture = null) #Gets the localization for the business state named by
name.Parameters
Name
Type
Description
nameStringThe business state name used as the localization key.
Returns
Type
Description
StringThe localized business state name if found; otherwise,
name.public string GetLocalizedCommandName(string name, CultureInfo culture = null) #Gets the localization for
name with LocalizeType.Command.Parameters
Name
Type
Description
nameStringThe command name used as the localization key.
Returns
Type
Description
StringThe localized command name if found; otherwise,
name.public string GetLocalizedParameterName(string name, CultureInfo culture = null) #Gets the localization for
name with LocalizeType.Parameter.Parameters
Name
Type
Description
nameStringThe parameter name used as the localization key.
Returns
Type
Description
StringThe localized parameter name if found; otherwise,
name.public string GetLocalizedActionName(string name, CultureInfo culture = null) #Gets the localization for
name with LocalizeType.Action.Parameters
Name
Type
Description
nameStringThe action name used as the localization key.
Returns
Type
Description
StringThe localized action name if found; otherwise,
name.public string GetLocalizedConditionName(string name, CultureInfo culture = null) #Gets the localization for
name with LocalizeType.Condition.Parameters
Name
Type
Description
nameStringThe condition name used as the localization key.
Returns
Type
Description
StringThe localized condition name if found; otherwise,
name.public string GetLocalizedSchemeName(CultureInfo culture = null) #Gets the localized name of ProcessInstance.ProcessScheme by using LocalizeType.Scheme.
Parameters
Name
Type
Description
Returns
Type
Description
StringThe localized process scheme name if found; otherwise, the original name of ProcessInstance.ProcessScheme.
public string GetLocalizedComment(string key, CultureInfo culture = null) #Gets the localization for
key with LocalizeType.Comment.Parameters
Name
Type
Description
keyStringThe comment key to localize.
Returns
Type
Description
StringThe localized comment if found; otherwise,
key.public string ProcessParametersToString(ParameterPurpose purpose) #Formats process parameters whose ParameterDefinition.Purpose equals
purpose as text.Parameters
Name
Type
Description
Returns
Type
Description
StringText containing one
name='value' line for each matching parameter, ordered by parameter name.public void SetActivityAfterActionExecution(string activityName) #Schedules the activity named
activityName to be set and executed immediately after the current action finishes.Parameters
Name
Type
Description
activityNameStringThe name of the activity to set and execute.
Exceptions
Type
Description
ActivityNotFoundExceptionNo activity in ProcessInstance.ProcessScheme is named
activityName.public void SetActivityAfterActivityExecution(string activityName) #Schedules the activity named
activityName to be set and executed after the current activity finishes executing all of its actions.Parameters
Name
Type
Description
activityNameStringThe name of the activity to set and execute.
Exceptions
Type
Description
ActivityNotFoundExceptionNo activity in ProcessInstance.ProcessScheme is named
activityName.public void SetStateAfterActionExecution(string stateName) #Schedules the activity associated with the business state named
stateName to be set and executed immediately after the current action finishes.Parameters
Name
Type
Description
stateNameStringThe business state name used to select the activity.
Exceptions
Type
Description
ActivityNotFoundExceptionNo activity in ProcessInstance.ProcessScheme has a nonempty ActivityDefinition.State equal to
stateName and ActivityDefinition.IsForSetState set to true.public void SetStateAfterActivityExecution(string stateName) #Schedules the activity associated with the business state named
stateName to be set and executed after the current activity finishes executing all of its actions.Parameters
Name
Type
Description
stateNameStringThe business state name used to select the activity.
Exceptions
Type
Description
ActivityNotFoundExceptionNo activity in ProcessInstance.ProcessScheme has a nonempty ActivityDefinition.State equal to
stateName and ActivityDefinition.IsForSetState set to true.public string SubstituteValue(string parameter) #Replaces process parameter placeholders in
parameter.Parameters
Name
Type
Description
parameterStringThe text to inspect for process parameter placeholders.
Returns
Type
Description
StringThe text with matching placeholders replaced, or
parameter if no placeholders match.public Task<string> SubstituteValueAsync(string parameter) #Asynchronously replaces process parameter placeholders in
parameter.Parameters
Name
Type
Description
parameterStringThe text to inspect for process parameter placeholders.
Returns
Type
Description
Task<String>A Task<TResult> whose result is the text with matching placeholders replaced, or
parameter if no placeholders match.public T GetRootPersistedParameter<T>(string parameterName) #Gets the value of the parameter named
parameterName from the root process instance.Parameters
Name
Type
Description
parameterNameStringThe parameter name.
Returns
Type
Description
{T}The parameter value as
T, or the default value of T if no value is found.public Task<T> GetRootPersistedParameterAsync<T>(string parameterName) #Asynchronously gets the value of the parameter named
parameterName from the root process instance.Parameters
Name
Type
Description
parameterNameStringThe parameter name.
Returns
Type
Description
Task<T>A Task<TResult> whose result is the parameter value as
T, or the default value of T if no value is found.public ParameterDefinitionWithValue GetRootPersistedParameter(string parameterName) #Gets the parameter named
parameterName from the root process instance.Parameters
Name
Type
Description
parameterNameStringThe parameter name.
Returns
Type
Description
ParameterDefinitionWithValueThe matching ParameterDefinitionWithValue, or null if no parameter is found.
public Task<ParameterDefinitionWithValue> GetRootPersistedParameterAsync(string parameterName) #Asynchronously gets the parameter named
parameterName from the root process instance.Parameters
Name
Type
Description
parameterNameStringThe parameter name.
Returns
Type
Description
Task<ParameterDefinitionWithValue>A Task<TResult> whose result is the matching ParameterDefinitionWithValue, or null if no parameter is found.
public void SetRootPersistenceParameter<T>(string parameterName, T value) #Sets
parameterName on the root process instance, creating the parameter with ParameterPurpose.Persistence when it is missing.Parameters
Name
Type
Description
parameterNameStringThe parameter name.
value{T}The value to assign.
public Task SetRootPersistenceParameterAsync<T>(string parameterName, T value) #Asynchronously sets
parameterName on the root process instance, creating the parameter with ParameterPurpose.Persistence when it is missing.Parameters
Name
Type
Description
parameterNameStringThe parameter name.
value{T}The value to assign.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ImpossibleToSetStatusExceptionThe root process could not be locked for the update.
public void RemoveRootPersistenceParameter(string parameterName) #Clears the parameter named
parameterName in the root process instance.Parameters
Name
Type
Description
parameterNameStringThe parameter name.
public Task RemoveRootPersistenceParameterAsync(string parameterName) #Asynchronously clears the parameter named
parameterName in the root process instance.Parameters
Name
Type
Description
parameterNameStringThe parameter name.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ImpossibleToSetStatusExceptionThe root process could not be locked for the update.