# Class WorkflowRuntime OptimaJet.Workflow.Core.Runtime.WorkflowRuntime Provides the main API for configuring Workflow Engine and working with [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) objects. Namespace: [OptimaJet.Workflow.Core.Runtime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/) ```csharp public sealed class WorkflowRuntime ``` ## Constructors `public WorkflowRuntime(Guid runtimeId)` Initializes a workflow runtime with the specified identifier. ### Parameters | Name | Type | Description | | --- | --- | --- | | `runtimeId` | `Guid` | The value assigned to [WorkflowRuntime.Id](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). | `public WorkflowRuntime(string runtimeId)` Initializes a workflow runtime with the specified identifier. ### Parameters | Name | Type | Description | | --- | --- | --- | | `runtimeId` | `String` | The value assigned to [WorkflowRuntime.Id](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). | `public WorkflowRuntime(IRuntimeIdProvider runtimeIdProvider)` Initializes a workflow runtime using an [IRuntimeIdProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IRuntimeIdProvider/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `runtimeIdProvider` | `IRuntimeIdProvider` | The provider whose [IRuntimeIdProvider.GetId()](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IRuntimeIdProvider/) result becomes [WorkflowRuntime.Id](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). | `public WorkflowRuntime()` Initializes a workflow runtime with [Guid.Empty](https://learn.microsoft.com/dotnet/api/system.guid.empty) as its identifier. ## Properties `public OfflineApi OfflineApi { get; }` Gets the [OfflineApi](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/OfflineApi/) instance for building approval maps and executing ordered batches of workflow commands. `public ActorsApi ActorsApi { get; }` Gets the [ActorsApi](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ActorsApi/) instance for resolving workflow participant identities and their associated commands from actor restrictions. `public GetUsersWithIdentitiesAsyncDelegate GetUsersWithIdentitiesAsync { get; set; }` Gets or sets the [GetUsersWithIdentitiesAsyncDelegate](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetUsersWithIdentitiesAsyncDelegate/) used to load user names and their associated workflow participant identities. `public GetUserByIdentityAsyncDelegate GetUserByIdentityAsync { get; set; }` Gets or sets the [GetUserByIdentityAsyncDelegate](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetUserByIdentityAsyncDelegate/) used to resolve the user name associated with a workflow participant identity. `public GetCustomTimerValueAsyncDelegate GetCustomTimerValueAsync { get; set; }` Gets or sets the [GetCustomTimerValueAsyncDelegate](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetCustomTimerValueAsyncDelegate/) used to resolve custom timer values. `public string Id { get; }` Gets the runtime identifier. `public WorkflowRuntimeSettings Settings { get; }` Gets the [WorkflowRuntimeSettings](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntimeSettings/) that control runtime behavior. `public IDesignerAutocompleteProvider DesignerAutocompleteProvider { get; set; }` Gets or sets the [IDesignerAutocompleteProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IDesignerAutocompleteProvider/) used to supply autocomplete data to the Designer. `public ICodeAutocompleteProvider CodeAutocompleteProvider { get; set; }` Gets or sets the [ICodeAutocompleteProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/ICodeAutocompleteProvider/) used for code autocomplete. ### Remarks If no provider has been assigned, the first access creates a [CodeAutocompleteProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/CodeAutocompleteProvider/). `public IDesignerParameterFormatProvider DesignerParameterFormatProvider { get; set; }` Gets or sets the [IDesignerParameterFormatProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IDesignerParameterFormatProvider/) that describes how the Designer edits action, condition, and rule parameters. `public IWorkflowRuleProvider RuleProvider { get; }` Gets the [IWorkflowRuleProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IWorkflowRuleProvider/) used to evaluate workflow participant identities against named authorization rules. `public IWorkflowBuilder Builder { get; }` Gets the [IWorkflowBuilder](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Builder/IWorkflowBuilder/) used to load, build, and update process schemes and instances. `public ITimerManager TimerManager { get; }` Gets the [ITimerManager](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ITimerManager/) that schedules and executes process timers. `public ConcurrentDictionary Calendars { get; set; }` Gets or sets the work calendars keyed by [ICalendar.Name](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Calendars/ICalendar/). `public string DefaultCalendarName { get; }` Gets the key in [WorkflowRuntime.Calendars](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) of the default work calendar. `public IPersistenceProvider PersistenceProvider { get; }` Gets the [IPersistenceProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/IPersistenceProvider/) used to store and load schemes, processes, parameters, and runtime data. `public IWorkflowActionProvider ActionProvider { get; }` Gets the [IWorkflowActionProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IWorkflowActionProvider/) whose actions and conditions can be invoked by process schemes. `public IWorkflowExternalParametersProvider ExternalParametersProvider { get; }` Gets the [IWorkflowExternalParametersProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IWorkflowExternalParametersProvider/) used to load and save external process parameters. `public ILocalizationProvider? LocalizationProvider { get; }` Gets the localization-provider value stored on this runtime instance. ### Remarks The built-in [WorkflowRuntime.Localizer](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) does not read this property. Configure runtime localization with [WorkflowRuntimeConfigurationExtension.WithLocalizationProvider(WorkflowRuntime, ILocalizationProvider)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntimeConfigurationExtension/). `public DateTime RuntimeDateTimeNow { get; }` Gets [DateTime.UtcNow](https://learn.microsoft.com/dotnet/api/system.datetime.utcnow) or [DateTime.Now](https://learn.microsoft.com/dotnet/api/system.datetime.now), according to [WorkflowRuntimeSettings.UseUtcDateTimeAsRuntimeTime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntimeSettings/). `public bool IsCold { get; }` Gets a value indicating whether the runtime was started through [WorkflowRuntimeConfigurationExtension.ColdStartAsync(WorkflowRuntime)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntimeConfigurationExtension/). `public CancellationTokenHandling CancellationTokenHandling { get; set; }` Gets or sets a cancellation-token handling value on the runtime instance. ### Remarks Workflow execution reads [WorkflowRuntimeSettings.CancellationTokenHandling](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntimeSettings/) from [WorkflowRuntime.Settings](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). Configure that setting to change execution behavior. `public IWorkflowServiceRunner WorkflowServiceRunner { get; }` Gets the [IWorkflowServiceRunner](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.ServiceRunners/IWorkflowServiceRunner/) that coordinates runtime services and timer processing. `public bool IsRunning { get; }` Gets a value indicating whether the runtime is currently running. `public static bool CodeActionsCompillationEnable { get; set; }` Gets or sets [CodeActionsCompiller.CompillationEnable](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/CodeActionsCompiller/). The default value is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). `public static bool ExpressionsCompilationEnable { get; set; }` Gets or sets [ExpressionsCompiler.CompilationEnable](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/ExpressionsCompiler/). The default value is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). `public static ExpressionsCompilerOptions ExpressionsCompilerOptions { get; set; }` Gets or sets [ExpressionsCompiler.Options](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/ExpressionsCompiler/) used for expression compilation. ### Remarks The default value is [ExpressionsCompilerOptions.Default](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/ExpressionsCompilerOptions/). `public static bool CodeActionsDebugMode { get; set; }` Gets or sets [CodeActionsCompiller.DebugMode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/CodeActionsCompiller/). The default value is [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). ### Remarks In debug mode, a code action can break into an attached debugger by calling [Debugger.Break()](https://learn.microsoft.com/dotnet/api/system.diagnostics.debugger.break) or by containing the `/*break*/` marker. `public CodeActionsInvoker GlobalActionsInvoker { get; }` Gets the [CodeActionsInvoker](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.CodeActions/CodeActionsInvoker/) produced by the latest global code-action compilation. `public DateTime LastGlobalActionsCompilationTime { get; }` Gets the [WorkflowRuntime.RuntimeDateTimeNow](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) timestamp recorded after the latest global code-action compilation. `public IBulkApi Bulk { get; }` Gets the [IBulkApi](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.Bulk/IBulkApi/) bound to this [WorkflowRuntime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). `public Localizer Localizer { get; }` Gets the [WorkflowRuntime.Localizer](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) used to resolve names from the configured [ILocalizationProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ILocalizationProvider/) and process-scheme localization entries. `public ILogger Logger { get; set; }` Gets or sets the [ILogger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/ILogger/) used by workflow runtime logging methods. ### Remarks Replaced logger instances are disposed through [IDisposable.Dispose()](https://learn.microsoft.com/dotnet/api/system.idisposable.dispose) when this property is set. `public IProcessLogProvider ProcessLogger { get; set; }` Gets or sets the [IProcessLogProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/IProcessLogProvider/) that stores process-specific log entries. ### Remarks Defaults to a [MemoryProcessLogger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Logging/MemoryProcessLogger/) that retains up to `100` log entries for each of up to `100` processes. ## Methods `public static void CodeActionsRegisterAssembly(Assembly assembly)` Registers an [Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly) as a referenced assembly for code action compilation. ### Parameters | Name | Type | Description | | --- | --- | --- | | `assembly` | `Assembly` | The [Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly) to reference when compiling code actions. | `public Task<(bool success, Dictionary compilerErrors)> CompileGlobalCodeActionsAsync(bool ignoreNotCompiled)` Compiles global code actions, updates [WorkflowRuntime.GlobalActionsInvoker](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) and [WorkflowRuntime.LastGlobalActionsCompilationTime](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/), and raises [WorkflowRuntime.GlobalCodeActionsCompiled](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `ignoreNotCompiled` | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to ignore all global code action compilation errors. | ### Returns | Type | Description | | --- | --- | | `Task` | A tuple containing compilation success flag and compiler errors by action name. | `public static void RegisterLicense(string licenseText)` Registers a Workflow Engine license used by subsequent [WorkflowRuntime.GetLicenseRestrictions()](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) calls. ### Parameters | Name | Type | Description | | --- | --- | --- | | `licenseText` | `String` | The license text. | `public static IWorkflowEngineNetRestriction GetLicenseRestrictions()` Gets the restrictions of the current license. ### Returns | Type | Description | | --- | --- | | `IWorkflowEngineNetRestriction` | The current [IWorkflowEngineNetRestriction](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.License/IWorkflowEngineNetRestriction/) instance. | `public Task CheckAllSubprocessesCompletedAsync(ProcessInstance processInstance)` Checks whether the specified [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) has no active direct subprocesses. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) to check. | ### Returns | Type | Description | | --- | --- | | `Task` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if there are no active subprocesses. | `public Task CheckAllSubprocessesAndParentProcessCompletedAsync(ProcessInstance processInstance)` Checks whether a process and all of its direct subprocess branches have converged at the same subprocess merge activity. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) on which the outgoing transition from the merge activity is being evaluated. | ### Returns | Type | Description | | --- | --- | | `Task` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) when [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) is the [TransitionDefinition.From](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) activity of [ProcessInstance.ExecutedTransition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and no direct subprocesses remain active; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | ### Remarks Use this method as a condition on an outgoing transition from a subprocess merge activity. It permits that transition only after the process itself is waiting at the merge activity and every direct subprocess branch has finalized and merged into it. `public Task DeleteAllSubprocessesAsync(ProcessInstance processInstance)` Deletes every direct child subprocess of a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/), including each child's descendant subprocesses. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The parent [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `Task` | The number of direct child subprocess trees deleted. | `public Task SetPersistentProcessParameterAsync(Guid processId, string parameterName, object parameterValue)` Sets a process parameter with [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/) and saves the process's persistent parameters. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `parameterName` | `String` | The process parameter name. | | `parameterValue` | `Object` | The value to assign to the process parameter. | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task> GetProcessTimersAsync(Guid processId)` Gets the scheduled [ProcessTimer](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessTimer/) objects for a process. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `Task` | The scheduled [ProcessTimer](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessTimer/) objects. | `public Task GetProcessStatusAsync(Guid processId)` Gets the [ProcessStatus](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/) of the specified process. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `Task` | The current [ProcessStatus](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/). | `public Task ShutdownAsync(int timeout = -1)` Shuts down the runtime, switches off the API, waits for API calls and background processes to complete, stops timers, and raises [WorkflowRuntime.OnRuntimeShutdown](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) and [WorkflowRuntime.OnRuntimeShutdownAsync](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `timeout` | `Int32` | Maximum time in milliseconds to wait separately for active API calls and background processes. The default value, [Timeout.Infinite](https://learn.microsoft.com/dotnet/api/system.threading.timeout.infinite), waits indefinitely. | ### Returns | Type | Description | | --- | --- | | `Task` | | `public void RegisterDesignerAction(string operation, IDesignerAction designerAction)` Registers an [IDesignerAction](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Designer/IDesignerAction/) that handles a named Designer extension operation. ### Parameters | Name | Type | Description | | --- | --- | --- | | `operation` | `String` | Operation name. | | `designerAction` | `IDesignerAction` | The [IDesignerAction](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Designer/IDesignerAction/) to invoke for the operation. | ### Exceptions | Type | Description | | --- | --- | | `ArgumentException` | An action is already registered for the operation. | | `ArgumentNullException` | `operation` is [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | `public IDesignerAction GetDesignerAction(string operation)` Gets the [IDesignerAction](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Designer/IDesignerAction/) registered for a named Designer extension operation. ### Parameters | Name | Type | Description | | --- | --- | --- | | `operation` | `String` | Operation name. | ### Returns | Type | Description | | --- | --- | | `IDesignerAction` | The matching [IDesignerAction](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Designer/IDesignerAction/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when no action is registered. | `public T GetPlugin() where T : IWorkflowPlugin` Gets a plugin of the specified type from [WorkflowRuntime.Plugins](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). ### Returns | Type | Description | | --- | --- | | `{T}` | The matching plugin, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if none is registered. | ### Exceptions | Type | Description | | --- | --- | | `InvalidOperationException` | The plugin is registered more than once. | `public Task ExecuteTimerAsync(Guid processId, string timerName)` Executes timer transitions matching `timerName` from [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `timerName` | `String` | The name of the [TimerDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TimerDefinition/) associated with the timer transition to execute. | ### Returns | Type | Description | | --- | --- | | `Task` | | ### Remarks If no matching transition exists, the method completes without changing the process. `public Task SetProcessNewStatusAsync(ProcessInstance processInstance, ProcessStatus newStatus, bool suppressEvent = false)` Persists a new [ProcessStatus](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/) and raises [WorkflowRuntime.OnProcessStatusChanged](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) and [WorkflowRuntime.OnProcessStatusChangedAsync](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) when the status changes. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) whose status is changed. | | `newStatus` | `ProcessStatus` | The new [ProcessStatus](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/). | | `suppressEvent` | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to suppress [WorkflowRuntime.OnProcessStatusChanged](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) and [WorkflowRuntime.OnProcessStatusChangedAsync](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SetIdledOrFinalizedStatusAsync(ProcessInstance processInstance, ActivityDefinition newCurrentActivity)` Sets the process status to [ProcessStatus.Finalized](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/) when [ActivityDefinition.IsFinal](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool); otherwise, sets it to [ProcessStatus.Idled](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) whose status is changed. | | `newCurrentActivity` | `ActivityDefinition` | The new current [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task CheckIdentityAsync(ProcessInstance processInstance, string identityId, string ruleName, string parameter, CancellationToken token)` Checks whether a workflow participant identity satisfies a named rule exposed by [WorkflowRuntime.RuleProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) that provides the rule context. | | `identityId` | `String` | The workflow participant identity to evaluate. | | `ruleName` | `String` | A rule name returned by [IWorkflowRuleProvider.GetRules(string, NamesSearchType)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/IWorkflowRuleProvider/). | | `parameter` | `String` | The provider- or code-action-defined value passed to the rule after workflow substitutions are applied, typically originating from [ActorDefinition.Value](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActorDefinition/). | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to observe cancellation. | ### Returns | Type | Description | | --- | --- | | `Task` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the workflow participant identity passes the rule. | `public Task CheckIdentityByActorAsync(ProcessInstance processInstance, string identityId, string actorName, CancellationToken token)` Checks whether a workflow participant identity satisfies the rule configured by a named [ActorDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActorDefinition/) in the process scheme. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) whose scheme defines the actor. | | `identityId` | `String` | The workflow participant identity to evaluate. | | `actorName` | `String` | The name of the [ActorDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActorDefinition/) whose rule is evaluated. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to observe cancellation. | ### Returns | Type | Description | | --- | --- | | `Task` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the workflow participant identity passes the actor rule. | `public Task> GetAvailableCommandsAsync(ProcessInstance processInstance, IEnumerable identityIds, string commandNameFilter = null, string mainIdentityId = null, CultureInfo culture = null, bool conditionCheck = false, CancellationToken token = default)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the specified workflow participant identities from [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and the current activities of active subprocesses. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) whose commands are evaluated. | | `identityIds` | `IEnumerable` | The workflow participant identities whose command permissions are evaluated. | | `commandNameFilter` | `String` | Optional [WorkflowCommand.CommandName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) filter. If specified, only matching command transitions are returned. | | `mainIdentityId` | `String` | Optional workflow participant identity checked before `identityIds`. When it satisfies a transition's actor restrictions, the remaining identities are not checked for that transition. | | `culture` | `CultureInfo` | Optional culture used for [WorkflowCommand.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) and [CommandParameter.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandParameter/). | | `conditionCheck` | `Boolean` | When [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), transitions are excluded when the combined evaluation of their configured [TransitionDefinition.Conditions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) does not permit execution. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to observe cancellation. | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the provided workflow participant identities. | ### Remarks When multiple transitions produce the same [WorkflowCommand.CommandName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/), [WorkflowCommand.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/), and [WorkflowCommand.Classifier](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/), they are represented by one command whose [WorkflowCommand.Identities](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) contains all matching workflow participant identities. `public Task> GetAvailableCommandsAsync(ProcessInstance processInstance, string identityId)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to one workflow participant identity from [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and the current activities of active subprocesses. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) whose commands are evaluated. | | `identityId` | `String` | The workflow participant identity whose command permissions are evaluated. | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the workflow participant identity. | `public Task> GetAvailableCommandsAsync(Guid processId, IEnumerable identityIds, string commandNameFilter = null, string mainIdentityId = null, CultureInfo culture = null, bool conditionCheck = false, CancellationToken token = default)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the specified workflow participant identities from the process's current activity and the current activities of active subprocesses. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `identityIds` | `IEnumerable` | The workflow participant identities whose command permissions are evaluated. | | `commandNameFilter` | `String` | Optional [WorkflowCommand.CommandName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) filter. If specified, only matching command transitions are returned. | | `mainIdentityId` | `String` | Optional workflow participant identity checked before `identityIds`. When it satisfies a transition's actor restrictions, the remaining identities are not checked for that transition. | | `culture` | `CultureInfo` | Optional culture used for [WorkflowCommand.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) and [CommandParameter.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandParameter/). | | `conditionCheck` | `Boolean` | Whether to exclude transitions when the combined evaluation of their configured [TransitionDefinition.Conditions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) does not permit execution. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to observe cancellation. | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the provided workflow participant identities. | `public Task> GetAvailableCommandsAsync(Guid processId, string identityId)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to one workflow participant identity from the process's current activity and the current activities of active subprocesses. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `identityId` | `String` | The workflow participant identity whose command permissions are evaluated. | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the workflow participant identity. | `public Task> GetAvailableCommandsAsync(Guid processId, string identityId, CultureInfo culture)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to one workflow participant identity from the process's current activity and the current activities of active subprocesses, using the specified culture. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `identityId` | `String` | The workflow participant identity whose command permissions are evaluated. | | `culture` | `CultureInfo` | The culture used for [WorkflowCommand.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) and [CommandParameter.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandParameter/). | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the workflow participant identity. | `public Task ExecuteCommandAsync(WorkflowCommand command, string identityId, string impersonatedIdentityId, CancellationToken token = default, bool checkRestrictions = false)` Executes a [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) for the process and activity identified by the command. ### Parameters | Name | Type | Description | | --- | --- | --- | | `command` | `WorkflowCommand` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) to execute. | | `identityId` | `String` | The workflow participant identity that initiates command execution. | | `impersonatedIdentityId` | `String` | The workflow participant identity on whose behalf the command is executed. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to observe cancellation. | | `checkRestrictions` | `Boolean` | When [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), `impersonatedIdentityId` is validated against the actor restrictions in [TransitionDefinition.Restrictions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) for each candidate transition. | ### Returns | Type | Description | | --- | --- | | `Task` | The [CommandExecutionResult](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandExecutionResult/) produced by command execution. | ### Exceptions | Type | Description | | --- | --- | | `InvalidCommandException` | Thrown when the command is invalid or is not valid for [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | `public Task ExecuteCommandWithRestrictionCheckAsync(WorkflowCommand command, string identityId, string impersonatedIdentityId, CancellationToken token = default)` Executes a [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) after validating the impersonated workflow participant identity against [TransitionDefinition.Restrictions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) for each candidate transition. ### Parameters | Name | Type | Description | | --- | --- | --- | | `command` | `WorkflowCommand` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) to execute. | | `identityId` | `String` | The workflow participant identity that initiates command execution. | | `impersonatedIdentityId` | `String` | The workflow participant identity on whose behalf the command is executed. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to observe cancellation. | ### Returns | Type | Description | | --- | --- | | `Task` | The [CommandExecutionResult](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandExecutionResult/) produced by command execution. | `[Obsolete("Use GetInitialCommandsAsync(GetInitialCommandsParams parameters) instead.")] public Task> GetInitialCommandsAsync(string schemeCode, string identityId)` Obsolete Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects defined for [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) name used as the scheme code. | | `identityId` | `String` | Workflow participant identity argument retained for backward compatibility. | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available on the initial activity. | ### Remarks This overload delegates to [WorkflowRuntime.GetInitialCommandsAsync(GetInitialCommandsParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) and does not use `identityId` in command filtering. `[Obsolete("Use GetInitialCommandsAsync(GetInitialCommandsParams parameters) instead.")] public Task> GetInitialCommandsAsync(string schemeCode, string identityId, CultureInfo culture)` Obsolete Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects defined for [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) name used as the scheme code. | | `identityId` | `String` | Workflow participant identity argument retained for backward compatibility. | | `culture` | `CultureInfo` | The culture used for [WorkflowCommand.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) and [CommandParameter.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandParameter/). | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available on the initial activity. | ### Remarks This overload delegates to [WorkflowRuntime.GetInitialCommandsAsync(GetInitialCommandsParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) and does not use `identityId` in command filtering. `[Obsolete("Use GetInitialCommandsAsync(GetInitialCommandsParams parameters) instead.")] public Task> GetInitialCommandsAsync(string schemeCode, IEnumerable identityIds, string commandNameFilter = null, CultureInfo culture = null)` Obsolete Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects defined for [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) name used as the scheme code. | | `identityIds` | `IEnumerable` | Workflow participant identity list retained for backward compatibility. | | `commandNameFilter` | `String` | Optional [WorkflowCommand.CommandName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) filter. If specified, only matching command transitions are returned. | | `culture` | `CultureInfo` | The culture used for [WorkflowCommand.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) and [CommandParameter.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandParameter/). | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available on the initial activity. | ### Remarks This overload delegates to [WorkflowRuntime.GetInitialCommandsAsync(GetInitialCommandsParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) and does not use `identityIds` in command filtering. `public Task> GetInitialCommandsAsync(GetInitialCommandsParams parameters)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects defined for [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) in the selected scheme. ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `GetInitialCommandsParams` | Provides [GetInitialCommandsParams.SchemeCode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetInitialCommandsParams/), optional [GetInitialCommandsParams.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetInitialCommandsParams/), [GetInitialCommandsParams.CommandNameFilter](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetInitialCommandsParams/), and [GetInitialCommandsParams.Culture](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetInitialCommandsParams/). | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available on the initial activity. | ### Remarks Only transitions for which [TransitionDefinition.IsAlwaysTransition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) is [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) are returned. `public Task> GetAvailableCommandsWithConditionCheckAsync(Guid processId, string identityId)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects from the current activities of a process and its active subprocesses, excluding transitions when the combined evaluation of their configured [TransitionDefinition.Conditions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) does not permit execution. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `identityId` | `String` | The workflow participant identity whose command permissions are evaluated. | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the workflow participant identity. | `public Task> GetAvailableCommandsWithConditionCheckAsync(Guid processId, string identityId, CultureInfo culture)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects from the current activities of a process and its active subprocesses, excluding transitions when the combined evaluation of their configured [TransitionDefinition.Conditions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) does not permit execution. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `identityId` | `String` | The workflow participant identity whose command permissions are evaluated. | | `culture` | `CultureInfo` | The culture used for [WorkflowCommand.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) and [CommandParameter.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandParameter/). | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the workflow participant identity. | `public Task> GetAvailableCommandsWithConditionCheckAsync(Guid processId, IEnumerable identityIds, string commandNameFilter = null, string mainIdentityId = null, CultureInfo culture = null)` Gets the [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects from the current activities of a process and its active subprocesses, excluding transitions when the combined evaluation of their configured [TransitionDefinition.Conditions](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TransitionDefinition/) does not permit execution. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `identityIds` | `IEnumerable` | The workflow participant identities whose command permissions are evaluated. | | `commandNameFilter` | `String` | Optional [WorkflowCommand.CommandName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) filter. If specified, only matching command transitions are returned. | | `mainIdentityId` | `String` | Optional workflow participant identity checked before `identityIds`. When it satisfies a transition's actor restrictions, the remaining identities are not checked for that transition. | | `culture` | `CultureInfo` | Optional culture used for [WorkflowCommand.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) and [CommandParameter.LocalizedName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CommandParameter/). | ### Returns | Type | Description | | --- | --- | | `Task` | The [WorkflowCommand](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowCommand/) objects available to the provided workflow participant identities. | `public Task CreateInstanceAsync(string schemeCode, Guid processId, CancellationToken token = default)` Creates a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) from the specified scheme and starts execution from [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) name used as the scheme code. | | `processId` | `Guid` | The value to assign to [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to observe while creating the process instance. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that completes after initial process execution finishes. | `public Task CreateInstanceAsync(CreateInstanceParams createInstanceParams, CancellationToken token = default)` Creates a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) with the supplied configuration and starts execution from [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `createInstanceParams` | `CreateInstanceParams` | Provides [CreateInstanceParams.SchemeCode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CreateInstanceParams/), [CreateInstanceParams.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CreateInstanceParams/), optional [CreateInstanceParams.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CreateInstanceParams/), [CreateInstanceParams.CalendarName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CreateInstanceParams/), [CreateInstanceParams.IdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CreateInstanceParams/), [CreateInstanceParams.ImpersonatedIdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CreateInstanceParams/), [CreateInstanceParams.InitialProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CreateInstanceParams/), and [CreateInstanceParams.Persist](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CreateInstanceParams/). | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to observe while creating the process instance. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that completes after initial process execution finishes. | `public Task DeleteInstanceAsync(Guid processId)` Deletes a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and all of its descendant subprocesses asynchronously. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) of the process to delete. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that completes when the process instance and subprocesses are deleted. | `public Task IsProcessExistsAsync(Guid processId)` Checks whether a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) with the specified identifier exists. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) to check. | ### Returns | Type | Description | | --- | --- | | `Task` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if the process exists; otherwise, [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool). | `public Task DeleteInstanceAsync(ProcessInstance processInstance)` Deletes a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and all of its descendant subprocesses asynchronously. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) to delete. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that completes when the process instance and subprocesses are deleted. | `public Task GetProcessInstancesTreeAsync(Guid rootProcessId, CancellationToken cancellationToken = default)` Gets the [ProcessInstancesTree](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Subprocess/ProcessInstancesTree/) for a root process asynchronously. ### Parameters | Name | Type | Description | | --- | --- | --- | | `rootProcessId` | `Guid` | The root value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `cancellationToken` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to observe while building the tree. | ### Returns | Type | Description | | --- | --- | | `Task` | The process instance tree rooted at `rootProcessId`. | `public Task GetProcessInstancesTreeAsync(ProcessInstance processInstance, CancellationToken cancellationToken = default)` Gets the complete [ProcessInstancesTree](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Subprocess/ProcessInstancesTree/) that contains the specified process. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) whose tree should be loaded. | | `cancellationToken` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) to observe while building the tree. | ### Returns | Type | Description | | --- | --- | | `Task` | The tree rooted at [ProcessInstance.RootProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). When `processInstance` is a subprocess, the result also contains its parent and sibling subprocesses. | `public Task GetProcessInstanceAndFillProcessParametersAsync(Guid processId)` Gets a [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and loads its process parameters asynchronously. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `Task` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) with its process parameters loaded. | `public Task> GetProcessHistoryAsync(Guid processId, Paging paging = null)` Gets the [ProcessHistoryItem](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessHistoryItem/) entries for a process asynchronously. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `paging` | `Paging` | Optional [Paging.PageIndex](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/Paging/) and [Paging.PageSize](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/Paging/) values for history retrieval. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of [ProcessHistoryItem](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessHistoryItem/) objects. | `public Task GetProcessHistoryCountAsync(Guid processId)` Gets the number of [ProcessHistoryItem](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessHistoryItem/) entries for a process asynchronously. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `Task` | The total number of history records. | `public Task ChangeProcessLogEnabledAsync(Guid processId)` Toggles [ProcessInstance.LogEnabled](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) for a process and all of its subprocesses. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `Task` | The new [ProcessInstance.LogEnabled](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) value. | `public string GetLocalizedStateName(Guid processId, string stateName)` Gets the localized [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name for a process, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `stateName` | `String` | The [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name to localize. | ### Returns | Type | Description | | --- | --- | | `String` | The localized state name, or the original value when no translation is available. | `public Task GetLocalizedStateNameAsync(Guid processId, string stateName)` Gets the localized [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name for a process asynchronously, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `stateName` | `String` | The [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name to localize. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that resolves to the localized state name, or the original value when no translation is available. | `public string GetLocalizedStateNameBySchemeId(Guid schemeId, string stateName)` Gets the localized [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name for a scheme, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeId` | `Guid` | The value of [ProcessDefinition.Id](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). | | `stateName` | `String` | The [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name to localize. | ### Returns | Type | Description | | --- | --- | | `String` | The localized state name, or the original value when no translation is available. | `public Task GetLocalizedStateNameBySchemeIdAsync(Guid schemeId, string stateName)` Gets the localized [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name for a scheme asynchronously, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeId` | `Guid` | The value of [ProcessDefinition.Id](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). | | `stateName` | `String` | The [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name to localize. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that resolves to the localized state name, or the original value when no translation is available. | `public string GetLocalizedStateNameBySchemeCode(string schemeCode, string stateName)` Gets the localized [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name for a scheme code, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) name used as the scheme code. | | `stateName` | `String` | The [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name to localize. | ### Returns | Type | Description | | --- | --- | | `String` | The localized state name, or the original value when no translation is available. | `public Task GetLocalizedStateNameBySchemeCodeAsync(string schemeCode, string stateName)` Gets the localized [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name for a scheme code asynchronously, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) name used as the scheme code. | | `stateName` | `String` | The [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name to localize. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that resolves to the localized state name, or the original value when no translation is available. | `public string GetLocalizedStateNameBySchemeCode(string schemeCode, string? tenantId, string stateName)` Gets the localized [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name for a tenant-specific scheme code, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) name used as the scheme code. | | `tenantId` | `String` | The value of [ProcessDefinition.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | | `stateName` | `String` | The [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name to localize. | ### Returns | Type | Description | | --- | --- | | `String` | The localized state name, or the original value when no translation is available. | `public Task GetLocalizedStateNameBySchemeCodeAsync(string schemeCode, string? tenantId, string stateName)` Gets the localized [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name for a tenant-specific scheme code asynchronously, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) name used as the scheme code. | | `tenantId` | `String` | The value of [ProcessDefinition.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/), or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | | `stateName` | `String` | The [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) name to localize. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that resolves to the localized state name, or the original value when no translation is available. | `public string GetLocalizedCommandName(Guid processId, string commandName)` Gets the localized name of a [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) for a process, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `commandName` | `String` | The name of the [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) to localize. | ### Returns | Type | Description | | --- | --- | | `String` | The localized command name, or the original value when no translation is available. | `public Task GetLocalizedCommandNameAsync(Guid processId, string commandName)` Gets the localized name of a [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) for a process asynchronously, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `commandName` | `String` | The name of the [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) to localize. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that resolves to the localized command name, or the original value when no translation is available. | `public string GetLocalizedCommandNameBySchemeId(Guid schemeId, string commandName)` Gets the localized name of a [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) for a scheme, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeId` | `Guid` | The value of [ProcessDefinition.Id](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). | | `commandName` | `String` | The name of the [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) to localize. | ### Returns | Type | Description | | --- | --- | | `String` | The localized command name, or the original value when no translation is available. | `public Task GetLocalizedCommandNameBySchemeIdAsync(Guid schemeId, string commandName)` Gets the localized name of a [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) for a scheme asynchronously, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeId` | `Guid` | The value of [ProcessDefinition.Id](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). | | `commandName` | `String` | The name of the [CommandDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/CommandDefinition/) to localize. | ### Returns | Type | Description | | --- | --- | | `Task` | A task that resolves to the localized command name, or the original value when no translation is available. | `public void LogInfo(string message, Dictionary parameters)` Writes a message through [WorkflowRuntime.Logger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) at the Info level. ### Parameters | Name | Type | Description | | --- | --- | --- | | `message` | `String` | Message to write. | | `parameters` | `Dictionary` | Dictionary of properties to serialize in the log entry. | ### Exceptions | Type | Description | | --- | --- | | `Exception` | Thrown when the logger is not configured. | `public void LogInfoIfLoggerExists(string message, Dictionary parameters)` Writes a message to the log with Info level if [WorkflowRuntime.Logger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) is set. ### Parameters | Name | Type | Description | | --- | --- | --- | | `message` | `String` | Message to write. | | `parameters` | `Dictionary` | Dictionary of properties to serialize in the log entry. | `public void LogDebug(string message, Dictionary parameters)` Writes a message through [WorkflowRuntime.Logger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) at the Debug level. ### Parameters | Name | Type | Description | | --- | --- | --- | | `message` | `String` | Message to write. | | `parameters` | `Dictionary` | Dictionary of properties to serialize in the log entry. | ### Exceptions | Type | Description | | --- | --- | | `Exception` | Thrown when the logger is not configured. | `public void LogDebugIfLoggerExists(string message, Dictionary parameters)` Writes a message to the log with Debug level if [WorkflowRuntime.Logger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) is set. ### Parameters | Name | Type | Description | | --- | --- | --- | | `message` | `String` | Message to write. | | `parameters` | `Dictionary` | Dictionary of properties to serialize in the log entry. | `public void LogError(string message, Dictionary parameters)` Writes a message through [WorkflowRuntime.Logger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) at the Error level. ### Parameters | Name | Type | Description | | --- | --- | --- | | `message` | `String` | Message to write. | | `parameters` | `Dictionary` | Dictionary of properties to serialize in the log entry. | ### Exceptions | Type | Description | | --- | --- | | `Exception` | Thrown when the logger is not configured. | `public void LogErrorIfLoggerExists(string message, Dictionary parameters)` Writes a message to the log with Error level if [WorkflowRuntime.Logger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) is set. ### Parameters | Name | Type | Description | | --- | --- | --- | | `message` | `String` | Message to write. | | `parameters` | `Dictionary` | Dictionary of properties to serialize in the log entry. | `public void LogExceptionIfLoggerExists(Exception exception, string message, Dictionary parameters)` Writes an [Exception](https://learn.microsoft.com/dotnet/api/system.exception) and optional properties through [WorkflowRuntime.Logger](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) at the Error level when a logger is configured. ### Parameters | Name | Type | Description | | --- | --- | --- | | `exception` | `Exception` | The [Exception](https://learn.microsoft.com/dotnet/api/system.exception) to write. | | `message` | `String` | Message to write. | | `parameters` | `Dictionary` | Dictionary of properties to serialize in the log entry. | `public Task> PreExecuteFromInitialActivityAsync(Guid processId, bool ignoreCurrentStateCheck = false, CancellationToken token = default)` Runs a pre-execution simulation from [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) without persisting the simulated process state. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `ignoreCurrentStateCheck` | `Boolean` | When [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and [ProcessInstance.CurrentState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) differs from [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) of [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) (for example, after a scheme upgrade), the simulation stops after the initial activity. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to cancel the simulation. | ### Returns | Type | Description | | --- | --- | | `Task` | The predicted activity path produced by the pre-execution simulation. | ### Remarks The simulation evaluates transitions and executes actions from [ActivityDefinition.PreExecutionImplementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) instead of the regular [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). Although Workflow Engine does not persist simulated process changes, these actions can still affect external systems. `public Task> PreExecuteFromCurrentActivityAsync(Guid processId, bool ignoreCurrentStateCheck = false, CancellationToken token = default)` Runs a pre-execution simulation from [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) without persisting the simulated process state. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `ignoreCurrentStateCheck` | `Boolean` | When [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and [ProcessInstance.CurrentState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) differs from [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) of [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) (for example, after a scheme upgrade), the simulation stops after the current activity. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to cancel the simulation. | ### Returns | Type | Description | | --- | --- | | `Task` | The predicted activity path produced by the pre-execution simulation. | ### Remarks The simulation evaluates transitions and executes actions from [ActivityDefinition.PreExecutionImplementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) instead of the regular [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). Although Workflow Engine does not persist simulated process changes, these actions can still affect external systems. `public Task> PreExecuteAsync(Guid processId, string fromActivityName, bool ignoreCurrentStateCheck = false, CancellationToken token = default)` Runs a pre-execution simulation from the [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) named by `fromActivityName` without persisting the simulated process state. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `fromActivityName` | `String` | The name of the [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) where the simulation starts. | | `ignoreCurrentStateCheck` | `Boolean` | When [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) and [ProcessInstance.CurrentState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) differs from [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) of the starting activity (for example, after a scheme upgrade), the simulation stops after that activity. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) used to cancel the simulation. | ### Returns | Type | Description | | --- | --- | | `Task` | The predicted activity path produced by the pre-execution simulation. | ### Remarks The simulation evaluates transitions and executes actions from [ActivityDefinition.PreExecutionImplementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) instead of the regular [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). Although Workflow Engine does not persist simulated process changes, these actions can still affect external systems. `public Task> GetSchemeCodesAsync(List? tags = null)` Gets the codes of shared process schemes, optionally restricting the result to schemes matching `tags`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tags` | `List` | Optional collection of tags to filter by. If [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), all shared scheme codes are returned. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching shared scheme codes. | `public Task> GetSchemeCodesAsync(string tenantId)` Gets the codes of process schemes defined in the exact tenant scope identified by `tenantId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tenantId` | `String` | The [ProcessDefinition.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) for which schemes are searched. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching scheme codes. | `public Task> GetSchemeCodesAsync(string tenantId, List tags)` Gets the codes of process schemes defined in the exact tenant scope identified by `tenantId` and matching `tags`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `tenantId` | `String` | The [ProcessDefinition.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) for which schemes are searched. | | `tags` | `List` | Tags used to filter the search. | ### Returns | Type | Description | | --- | --- | | `Task` | The matching scheme codes. | `public Task SetSchemeIsObsoleteAsync(string schemeCode, string? tenantId = null)` Marks generated versions of a process scheme as obsolete so eligible process instances can be moved to a newly built version. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The code of the process scheme whose generated versions are marked obsolete. | | `tenantId` | `String` | The [ProcessDefinition.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) to target. [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) marks matching schemes obsolete in all tenants. | ### Returns | Type | Description | | --- | --- | | `Task` | | ### Exceptions | Type | Description | | --- | --- | | `ShutdownException` | Thrown when the runtime is shutting down and cannot start a new operation. | `public Task UpdateSchemeIfObsoleteAsync(Guid processId)` Moves a process and eligible descendant subprocesses from obsolete schemes to newly built scheme versions when [ActivityDefinition.IsAutoSchemeUpdate](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) permits the update at their current activities. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `Task` | | ### Exceptions | Type | Description | | --- | --- | | `ShutdownException` | Thrown when the runtime is shutting down and cannot start a new operation. | `public Task UpdateSchemeIfObsoleteAsync(Guid processId, bool ignoreAutoSchemeUpdate)` Moves a process and eligible descendant subprocesses from obsolete schemes to newly built scheme versions, optionally bypassing the activity-level [ActivityDefinition.IsAutoSchemeUpdate](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) requirement. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `ignoreAutoSchemeUpdate` | `Boolean` | [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to update even when [ActivityDefinition.IsAutoSchemeUpdate](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) is disabled at a process's current activity; [false](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) to require that permission. | ### Returns | Type | Description | | --- | --- | | `Task` | | ### Exceptions | Type | Description | | --- | --- | | `ShutdownException` | Thrown when the runtime is shutting down and cannot start a new operation. | `public Task UpdateSchemeIfObsoleteAsync(ProcessInstance processInstance)` Moves `processInstance` and eligible descendant subprocesses from obsolete schemes to newly built scheme versions when [ActivityDefinition.IsAutoSchemeUpdate](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) permits the update at their current activities. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) to update. | ### Returns | Type | Description | | --- | --- | | `Task` | The supplied process instance, with an updated scheme when an update was required and permitted; or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if the process was dropped during the update. | ### Exceptions | Type | Description | | --- | --- | | `ShutdownException` | Thrown when the runtime is shutting down and cannot start a new operation. | `public Task GetProcessSchemeAsync(Guid processId)` Gets the built process scheme currently assigned to the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The value of [ProcessInstance.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | ### Returns | Type | Description | | --- | --- | | `Task` | The process's [ProcessDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/). | `public Task> GetAvailableStateToSetAsync(Guid processId)` Gets the states that [WorkflowRuntime.SetStateAsync(SetStateParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) can assign to the process identified by `processId`, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture) for [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The process identifier. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of available [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) objects. | `public Task> GetAvailableStateToSetAsync(Guid processId, CultureInfo culture)` Gets the states that [WorkflowRuntime.SetStateAsync(SetStateParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) can assign to the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The process identifier. | | `culture` | `CultureInfo` | The culture used for [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/). | ### Returns | Type | Description | | --- | --- | | `Task` | A list of available [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) objects. | `public Task> GetAvailableStateToSetAsync(ProcessInstance processInstance)` Gets the states that [WorkflowRuntime.SetStateAsync(SetStateParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) can assign to `processInstance`, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture) for [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) whose available states are requested. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of available [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) objects. | `public Task> GetAvailableStateToSetAsync(ProcessInstance processInstance, CultureInfo culture)` Gets the states that [WorkflowRuntime.SetStateAsync(SetStateParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) can assign to `processInstance`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) whose available states are requested. | | `culture` | `CultureInfo` | The culture used for [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/). | ### Returns | Type | Description | | --- | --- | | `Task` | A list of available [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) objects. | `[Obsolete("Use GetAvailableStateToSetAsync(GetStateBySchemeParams parameters) instead.")] public Task> GetAvailableStateToSetAsync(string schemeCode)` Obsolete Gets the states that [WorkflowRuntime.SetStateAsync(SetStateParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) can assign in the scheme identified by `schemeCode`, using [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture) for [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The process scheme code. | ### Returns | Type | Description | | --- | --- | | `Task` | A list of available [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) objects. | `[Obsolete("Use GetAvailableStateToSetAsync(GetStateBySchemeParams parameters) instead.")] public Task> GetAvailableStateToSetAsync(string schemeCode, CultureInfo culture)` Obsolete Gets the states that [WorkflowRuntime.SetStateAsync(SetStateParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) can assign in the scheme identified by `schemeCode`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The process scheme code. | | `culture` | `CultureInfo` | The culture used for [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/). | ### Returns | Type | Description | | --- | --- | | `Task` | A list of available [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) objects. | `public Task> GetAvailableStateToSetAsync(GetStateBySchemeParams parameters)` Gets the states that [WorkflowRuntime.SetStateAsync(SetStateParams)](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntime/) can assign in the scheme selected by [GetStateBySchemeParams.SchemeCode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/) and optional [GetStateBySchemeParams.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/). [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) is localized with [GetStateBySchemeParams.Culture](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/) or [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `GetStateBySchemeParams` | Provides [GetStateBySchemeParams.SchemeCode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/), optional [GetStateBySchemeParams.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/), and optional [GetStateBySchemeParams.Culture](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/). | ### Returns | Type | Description | | --- | --- | | `Task` | A list of available [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) objects. | `public Task SetStateAsync(SetStateParams setStateParams)` Sets a process to a state represented by an [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) marked with [ActivityDefinition.IsForSetState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/), optionally executing [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) and applying [SetStateParams.ProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SetStateParams/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `setStateParams` | `SetStateParams` | Provides [SetStateParams.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SetStateParams/), [SetStateParams.StateName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SetStateParams/), [SetStateParams.IdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SetStateParams/), [SetStateParams.ImpersonatedIdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SetStateParams/), [SetStateParams.ProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SetStateParams/), [SetStateParams.Persist](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SetStateParams/), and [SetStateParams.PreventExecution](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SetStateParams/). | ### Returns | Type | Description | | --- | --- | | `Task` | | ### Exceptions | Type | Description | | --- | --- | | `ActivityNotFoundException` | No [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) with the requested state is marked with [ActivityDefinition.IsForSetState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). | `public Task SetActivityWithoutExecutionAsync(ActivityDefinition activityToSet, ProcessInstance processInstance, bool doNotSetRunningStatus = false)` Sets `activityToSet` as [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) without executing [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `activityToSet` | `ActivityDefinition` | The [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) to set as current. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) to update. | | `doNotSetRunningStatus` | `Boolean` | When [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), skips setting the process status to [ProcessStatus.Running](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/). | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SetActivityWithExecutionAsync(string identityId, string impersonatedIdentityId, IDictionary parameters, ActivityDefinition activityToSet, ProcessInstance processInstance, bool doNotSetRunningStatus = false, CancellationToken token = default)` Sets `activityToSet` as [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and executes [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `identityId` | `String` | The workflow participant identity stored in [ProcessInstance.IdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) for this execution. | | `impersonatedIdentityId` | `String` | The workflow participant identity stored in [ProcessInstance.ImpersonatedIdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `parameters` | `IDictionary` | Process parameters made available to actions in [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). | | `activityToSet` | `ActivityDefinition` | The [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) to set as current and execute. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) to update. | | `doNotSetRunningStatus` | `Boolean` | When [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), skips setting the process status to [ProcessStatus.Running](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/). | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) observed while setting the activity. | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task SetActivityWithExecutionAsync(string identityId, string impersonatedIdentityId, IDictionary parameters, ActivityDefinition activityToSet, ProcessInstance processInstance, bool doNotSetRunningStatus, List persist, CancellationToken token = default)` Sets `activityToSet` as [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) and executes [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). ### Parameters | Name | Type | Description | | --- | --- | --- | | `identityId` | `String` | The workflow participant identity stored in [ProcessInstance.IdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) for this execution. | | `impersonatedIdentityId` | `String` | The workflow participant identity stored in [ProcessInstance.ImpersonatedIdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/). | | `parameters` | `IDictionary` | Process parameters made available to actions in [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/). | | `activityToSet` | `ActivityDefinition` | The [ActivityDefinition](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) to set as current and execute. | | `processInstance` | `ProcessInstance` | The [ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) to update. | | `doNotSetRunningStatus` | `Boolean` | When [true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool), skips setting the process status to [ProcessStatus.Running](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/). | | `persist` | `List` | Names from `parameters` to store with [ParameterPurpose.Persistence](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ParameterPurpose/). | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) observed while setting the activity. | ### Returns | Type | Description | | --- | --- | | `Task` | | `public Task ResumeAsync(Guid processId, CancellationToken token = default)` Resumes process execution by evaluating outgoing [TriggerType.Auto](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TriggerType/) transitions from [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) without executing [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) for that activity. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The process identifier. | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) observed while resuming. | ### Returns | Type | Description | | --- | --- | | `Task` | A [ResumeResult](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeResult/) whose [ResumeResult.WasResumed](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeResult/) indicates whether execution advanced and whose [ResumeResult.ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeResult/) contains the resulting process instance. | `public Task ResumeAsync(ResumeParams resumeParams, CancellationToken token = default)` Resumes process execution by evaluating outgoing [TriggerType.Auto](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/TriggerType/) transitions from [ResumeParams.ActivityName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeParams/) or [ProcessInstance.CurrentActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) without executing [ActivityDefinition.Implementation](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) for that activity. ### Parameters | Name | Type | Description | | --- | --- | --- | | `resumeParams` | `ResumeParams` | Provides [ResumeParams.ProcessId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeParams/), optional [ResumeParams.ActivityName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeParams/), [ResumeParams.IdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeParams/), [ResumeParams.ImpersonatedIdentityId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeParams/), [ResumeParams.ProcessParameters](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeParams/), and [ResumeParams.Persist](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeParams/). | | `token` | `CancellationToken` | The [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) observed while resuming. | ### Returns | Type | Description | | --- | --- | | `Task` | A [ResumeResult](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeResult/) whose [ResumeResult.WasResumed](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeResult/) indicates whether execution advanced and whose [ResumeResult.ProcessInstance](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeResult/) contains the resulting process instance. | ### Exceptions | Type | Description | | --- | --- | | `ActivityNotFoundException` | The activity named by [ResumeParams.ActivityName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ResumeParams/) was not found. | `public Task GetCurrentStateNameAsync(Guid processId)` Returns [ProcessInstance.CurrentState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) for the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The process identifier. | ### Returns | Type | Description | | --- | --- | | `Task` | The current state name, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if not set. | `public Task GetCurrentActivityNameAsync(Guid processId)` Returns [ProcessInstance.CurrentActivityName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) for the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The process identifier. | ### Returns | Type | Description | | --- | --- | | `Task` | The current activity name. | `public Task GetCurrentStateAsync(Guid processId, CultureInfo culture = null)` Returns a [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) for [ProcessInstance.CurrentState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessInstance/) of the process identified by `processId`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `processId` | `Guid` | The process identifier. | | `culture` | `CultureInfo` | The culture used for [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/), or [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture) when [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | ### Returns | Type | Description | | --- | --- | | `Task` | A [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) describing the current state, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if the state is not set. | `[Obsolete("Use GetInitialStateAsync(GetStateBySchemeParams parameters) instead.")] public Task GetInitialStateAsync(string schemeCode, CultureInfo culture = null)` Obsolete Returns the [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) defined by [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) of [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) in the scheme identified by `schemeCode`. ### Parameters | Name | Type | Description | | --- | --- | --- | | `schemeCode` | `String` | The process scheme code. | | `culture` | `CultureInfo` | The culture used for [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/), or [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture) when [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null). | ### Returns | Type | Description | | --- | --- | | `Task` | [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) that represents the scheme initial state. | `public Task GetInitialStateAsync(GetStateBySchemeParams parameters)` Returns the [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) defined by [ActivityDefinition.State](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ActivityDefinition/) of [ProcessDefinition.InitialActivity](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Model/ProcessDefinition/) in the scheme selected by [GetStateBySchemeParams.SchemeCode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/) and optional [GetStateBySchemeParams.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/). [WorkflowState.VisibleName](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) is localized with [GetStateBySchemeParams.Culture](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/) or [CultureInfo.CurrentCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.currentculture). ### Parameters | Name | Type | Description | | --- | --- | --- | | `parameters` | `GetStateBySchemeParams` | Provides [GetStateBySchemeParams.SchemeCode](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/), optional [GetStateBySchemeParams.TenantId](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/), and optional [GetStateBySchemeParams.Culture](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/GetStateBySchemeParams/). | ### Returns | Type | Description | | --- | --- | | `Task` | [WorkflowState](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowState/) that represents the scheme initial state. | ## Fields `public List Plugins` Contains all registered [IWorkflowPlugin](https://api.workflowengine.io/core/OptimaJet.Workflow.Plugins/IWorkflowPlugin/) instances. `public List CustomActivities` Contains all registered custom [ActivityBase](https://api.workflowengine.io/core/OptimaJet.Workflow.Core/ActivityBase/) implementations. `public List CustomConditions` Contains all registered custom condition [FormBase](https://api.workflowengine.io/core/OptimaJet.Workflow.Core/FormBase/) implementations. ## Events `public event EventHandler GlobalCodeActionsCompiled` Raised with [CodeActionsCompiledEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/CodeActionsCompiledEventArgs/) after global code-action compilation. `public event EventHandler OnSchemaWasChanged` Raised with [SchemaWasChangedEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SchemaWasChangedEventArgs/) when the process scheme has changed. `public event EventHandler OnWorkflowError` Raised with [WorkflowErrorEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowErrorEventArgs/) when a workflow error occurs. `public event EventHandler OnStartingTransitionNotFound` Raised with [StartingTransitionNotFoundEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/StartingTransitionNotFoundEventArgs/) when the runtime cannot find the starting transition of a subprocess in a new root scheme. `public event EventHandler OnProcessActivityChanged` Raised with [ProcessActivityChangedEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessActivityChangedEventArgs/) when the current activity of a process changes. `public event EventHandler OnBeforeActivityExecution` Raised with [BeforeActivityExecutionEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/BeforeActivityExecutionEventArgs/) before execution of the selected activity. `public event EventHandler OnProcessStatusChanged` Raised with [ProcessStatusChangedEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessStatusChangedEventArgs/) when the [ProcessStatus](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/) of a process has changed. `public event EventHandler OnRuntimeStart` Raised with [RuntimeStartEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/RuntimeStartEventArgs/) after the runtime has started. `public event EventHandler OnRuntimeShutdown` Raised with [EventArgs](https://learn.microsoft.com/dotnet/api/system.eventargs) after the runtime has shut down. `public event AsyncEventHandler OnSchemaWasChangedAsync` Raised asynchronously with [SchemaWasChangedEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/SchemaWasChangedEventArgs/) when the process scheme has changed. `public event AsyncEventHandler OnWorkflowErrorAsync` Raised asynchronously with [WorkflowErrorEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowErrorEventArgs/) when a workflow error occurs. `public event AsyncEventHandler OnStartingTransitionNotFoundAsync` Raised asynchronously with [StartingTransitionNotFoundEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/StartingTransitionNotFoundEventArgs/) when the runtime cannot find the starting transition of a subprocess in a new root scheme. `public event AsyncEventHandler OnProcessActivityChangedAsync` Raised asynchronously with [ProcessActivityChangedEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessActivityChangedEventArgs/) when the current activity of a process changes. `public event AsyncEventHandler OnBeforeActivityExecutionAsync` Raised asynchronously with [BeforeActivityExecutionEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/BeforeActivityExecutionEventArgs/) before execution of the selected activity. `public event AsyncEventHandler OnProcessStatusChangedAsync` Raised asynchronously with [ProcessStatusChangedEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/ProcessStatusChangedEventArgs/) when the [ProcessStatus](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Persistence/ProcessStatus/) of a process has changed. `public event AsyncEventHandler OnRuntimeStartAsync` Raised asynchronously with [RuntimeStartEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/RuntimeStartEventArgs/) after the runtime has started. `public event AsyncEventHandler OnRuntimeShutdownAsync` Raised asynchronously with [EventArgs](https://learn.microsoft.com/dotnet/api/system.eventargs) after the runtime has shut down. [Previous WorkflowErrorEventArgs](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowErrorEventArgs/) [Next WorkflowRuntimeBulkApi](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime/WorkflowRuntimeBulkApi/)