Interface IPersistenceProvider
OptimaJet.Workflow.Core.Persistence.IPersistenceProvider
Defines the persistence operations used by WorkflowRuntime to store and load process checkpoints, global parameters, timers, and runtime operational state.
Namespace: OptimaJet.Workflow.Core.Persistence
public interface IPersistenceProvider : IApprovalProvider, IFormDataProviderType Hierarchy
- IPersistenceProvider Current type
- Base interfaces
- Derived interfaces
- Implementing types
Properties
string Id { get; } #Gets the identifier of the persistence provider implementation.
string ConnectionString { get; } #Gets the connection string configured for the persistence provider.
bool IsBulkOperationsSupported { get; } #Gets a value indicating whether the provider supports bulk process initialization.
Methods
void Init(WorkflowRuntime runtime) #Initializes the persistence provider for a WorkflowRuntime.
Parameters
Name
Type
Description
Task InitializeProcessAsync(ProcessInstance processInstance) #Creates the persisted process instance record for a ProcessInstance.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ProcessAlreadyExistsExceptionA persisted record already exists with the ProcessInstance.ProcessId of
processInstance.Task FillProcessParametersAsync(ProcessInstance processInstance) #Loads ParameterPurpose.System and ParameterPurpose.Persistence process parameters into a ProcessInstance.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task FillPersistedProcessParametersAsync(ProcessInstance processInstance) #Loads all ParameterPurpose.Persistence process parameters into a ProcessInstance.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task FillPersistedProcessParameterAsync(ProcessInstance processInstance, string parameterName) #Loads one ParameterPurpose.Persistence process parameter into a ProcessInstance.
Parameters
Name
Type
Description
parameterNameStringThe parameter name.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task FillSystemProcessParametersAsync(ProcessInstance processInstance) #Loads ParameterPurpose.System process parameters into a ProcessInstance.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task SavePersistenceParametersAsync(ProcessInstance processInstance) #Saves changed process parameters whose purpose is ParameterPurpose.Persistence.
Task SavePersistenceParameterAsync(ProcessInstance processInstance, string parameterName) #Saves one modified process parameter whose purpose is ParameterPurpose.Persistence.
Parameters
Name
Type
Description
parameterNameStringThe parameter name.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ArgumentNullExceptionprocessInstance is null.ArgumentExceptionparameterName is null or empty.InvalidOperationExceptionNo modified ParameterPurpose.Persistence parameter named
parameterName is available to save.Task RemoveParameterAsync(ProcessInstance processInstance, string parameterName) #Deletes the persisted value of a named process parameter.
Parameters
Name
Type
Description
parameterNameStringThe parameter name.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task SetWorkflowInitializedAsync(ProcessInstance processInstance) #Sets the process instance status to ProcessStatus.Initialized.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ImpossibleToSetStatusExceptionThe ProcessStatus cannot be changed.
Task SetWorkflowIdledAsync(ProcessInstance processInstance) #Sets the process instance status to ProcessStatus.Idled.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ImpossibleToSetStatusExceptionThe ProcessStatus cannot be changed.
Task SetWorkflowRunningAsync(ProcessInstance processInstance) #Sets the process instance status to ProcessStatus.Running.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ImpossibleToSetStatusExceptionThe ProcessStatus cannot be changed.
Task SetWorkflowFinalizedAsync(ProcessInstance processInstance) #Sets the process instance status to ProcessStatus.Finalized.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ImpossibleToSetStatusExceptionThe ProcessStatus cannot be changed.
Task SetProcessStatusAsync(Guid processId, ProcessStatus newStatus) #Sets the ProcessStatus of a ProcessInstance.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ImpossibleToSetStatusExceptionThe ProcessStatus cannot be changed.
Task SetWorkflowTerminatedAsync(ProcessInstance processInstance) #Sets the process instance status to ProcessStatus.Terminated.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ImpossibleToSetStatusExceptionThe ProcessStatus cannot be changed.
Task WriteInitialRecordToHistoryAsync(ProcessInstance processInstance) #Writes the initial transition history record for the current activity when transition history persistence is enabled.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task UpdatePersistenceStateAsync(ProcessInstance processInstance, TransitionDefinition transition) #Updates persisted process activity, state, and transition history for an executed transition according to the destination activity's persistence settings.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Remarks
State and transition history persistence are controlled independently by ActivityDefinition.DisablePersistState and ActivityDefinition.DisablePersistTransitionHistory.
Task<bool> IsProcessExistsAsync(Guid processId) #Determines whether a ProcessInstance exists in persistence.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
Returns
Type
Description
Task<Boolean>Task<bool> IsProcessExistsAsync(Guid processId, string tenantId) #Determines whether a ProcessInstance exists in persistence for a tenant.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
tenantIdStringThe tenant identifier.
Returns
Type
Description
Task<Boolean>Task<ProcessStatus> GetInstanceStatusAsync(Guid processId) #Gets the ProcessStatus of a ProcessInstance.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
Returns
Type
Description
Task<ProcessStatus>The persisted ProcessStatus, ProcessStatus.NotFound when the process has no status record, or ProcessStatus.Unknown when the persisted status is not recognized.
Task BindProcessToNewSchemeAsync(ProcessInstance processInstance) #Updates a persisted ProcessInstance to reference its new process scheme.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
ProcessNotFoundExceptionNo persisted record exists with the ProcessInstance.ProcessId of
processInstance.Task RegisterTimerAsync(Guid processId, Guid rootProcessId, string name, DateTime nextExecutionDateTime, string tenantId, bool notOverrideIfExists) #Creates or updates a persisted timer registration for a ProcessInstance.
Parameters
Name
Type
Description
rootProcessIdGuidThe identifier of the root process in the owning process tree.
nameStringThe timer name.
nextExecutionDateTimeDateTimeThe date and time when the timer becomes due.
tenantIdStringThe tenant identifier, if any.
notOverrideIfExistsBooleantrue to retain an existing registration with the same process identifier and timer name; otherwise, false to update its execution time. This value corresponds to TimerDefinition.NotOverrideIfExists.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task ClearTimersAsync(Guid processId, List<string> timersIgnoreList) #Deletes all persisted timer registrations for a ProcessInstance except timers whose names are retained.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
timersIgnoreListList<String>The timer names to retain.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task<List<ProcessTimer>> GetTimersForProcessAsync(Guid processId) #Gets all persisted timer registrations for a ProcessInstance.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
Returns
Type
Description
Task<ProcessTimer>The ProcessTimer objects registered for the ProcessInstance.
Task DeleteProcessAsync(Guid processId) #Deletes the persisted process instance record and related records managed by the provider.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task DeleteProcessAsync(Guid[] processIds) #Deletes persisted process instance records and related records managed by the provider.
Parameters
Name
Type
Description
processIdsGuid[]The process identifiers.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task SaveGlobalParameterAsync<T>(string type, string name, T value) #Saves a global parameter value that is not scoped to a tenant.
Parameters
Name
Type
Description
typeStringThe logical parameter type.
nameStringThe parameter name.
value{T}The parameter value.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task<T> LoadGlobalParameterAsync<T>(string type, string name) #Loads a global parameter value that is not scoped to a tenant.
Parameters
Name
Type
Description
typeStringThe logical parameter type.
nameStringThe parameter name.
Returns
Type
Description
Task<T>The parameter value, or the default value of
T when no matching parameter exists.Task<Dictionary<string, T>> LoadGlobalParametersWithNamesAsync<T>(string type, Sorting sort = null) #Loads the names and values of global parameters that have a logical type and are not scoped to a tenant.
Parameters
Returns
Type
Description
Task<String, T>A mapping from parameter names to values.
Task<List<T>> LoadGlobalParametersAsync<T>(string type, Sorting sort = null) #Loads the values of global parameters that have a logical type and are not scoped to a tenant.
Parameters
Returns
Type
Description
Task<List<T>>The parameter values.
Task<PagedResponse<T>> LoadGlobalParametersWithPagingAsync<T>(string type, Paging paging, string name = null, Sorting sort = null) #Loads a page of global parameter values and the total matching count.
Parameters
Name
Type
Description
typeStringThe logical parameter type.
nameStringThe optional parameter-name filter.
Returns
Type
Description
Task<PagedResponse<T>>A PagedResponse<T> containing the selected parameter values and total matching count.
Task DeleteGlobalParametersAsync(string type, string name = null) #Deletes global parameters that are not scoped to a tenant, optionally limiting the deletion by name.
Task SaveTenantGlobalParameterAsync<T>(TenantGlobalParameterKey key, T value) #Saves a global parameter value in the tenant scope specified by a TenantGlobalParameterKey.
Parameters
Name
Type
Description
keyTenantGlobalParameterKeyThe TenantGlobalParameterKey. Its TenantGlobalParameterKey.Name is required.
value{T}The parameter value.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task<T> LoadTenantGlobalParameterAsync<T>(TenantGlobalParameterKey key) #Loads a global parameter value from the tenant scope specified by a TenantGlobalParameterKey.
Parameters
Name
Type
Description
keyTenantGlobalParameterKeyThe TenantGlobalParameterKey. Its TenantGlobalParameterKey.Name is required.
Returns
Type
Description
Task<T>The parameter value, or the default value of
T when no matching parameter exists.Task<Dictionary<string, T>> LoadTenantGlobalParametersWithNamesAsync<T>(TenantGlobalParameterScope scope, Sorting sort = null) #Loads global parameter names and values from a TenantGlobalParameterScope.
Parameters
Name
Type
Description
Returns
Type
Description
Task<String, T>A mapping from parameter names to values.
Task<List<T>> LoadTenantGlobalParametersAsync<T>(TenantGlobalParameterScope scope, Sorting sort = null) #Loads global parameter values from a TenantGlobalParameterScope.
Parameters
Name
Type
Description
Returns
Type
Description
Task<List<T>>The parameter values.
Task<PagedResponse<T>> LoadTenantGlobalParametersWithPagingAsync<T>(TenantGlobalParameterScope scope, Paging paging, Sorting sort = null) #Loads a page of global parameter values from a TenantGlobalParameterScope and the total matching count.
Parameters
Name
Type
Description
Returns
Type
Description
Task<PagedResponse<T>>A PagedResponse<T> containing the selected parameter values and total matching count.
Task DeleteTenantGlobalParametersAsync(TenantGlobalParameterScope scope) #Deletes all global parameters in a TenantGlobalParameterScope.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task DeleteTenantGlobalParameterAsync(TenantGlobalParameterKey key) #Deletes one global parameter identified by a TenantGlobalParameterKey.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task<List<ProcessHistoryItem>> GetProcessHistoryAsync(Guid processId, Paging paging = null) #Gets persisted transition history for a ProcessInstance.
Task<int> GetProcessHistoryCountAsync(Guid processId) #Gets the number of persisted transition history records for a ProcessInstance.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
Returns
Type
Description
Task<Int32>The number of persisted transition history records.
Task BulkInitProcessesAsync(List<ProcessInstance> instances, ProcessStatus status, CancellationToken token) #When bulk operations are supported, persists multiple ProcessInstance objects, their persistent parameters, and their initial status.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Remarks
Check IPersistenceProvider.IsBulkOperationsSupported before calling this method.
Task BulkInitProcessesAsync(List<ProcessInstance> instances, List<TimerToRegister> timers, ProcessStatus status, CancellationToken token) #When bulk operations are supported, persists multiple ProcessInstance objects, their persistent parameters, timer registrations, and their initial status.
Parameters
Name
Type
Description
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Remarks
Check IPersistenceProvider.IsBulkOperationsSupported before calling this method.
Task<List<IProcessInstanceTreeItem>> GetProcessInstanceTreeAsync(Guid rootProcessId) #Gets the persisted process instance tree for a root process.
Parameters
Name
Type
Description
rootProcessIdGuidThe root process identifier.
Returns
Type
Description
Task<IProcessInstanceTreeItem>The IProcessInstanceTreeItem records in the process instance tree.
Task<bool> MultiServerRuntimesExistAsync() #Determines whether persistence contains a multi-server WorkflowRuntime record whose status is neither RuntimeStatus.Dead nor RuntimeStatus.Terminated.
Returns
Type
Description
Task<Boolean>Task<WorkflowRuntimeModel> CreateWorkflowRuntimeAsync(string runtimeId, RuntimeStatus status) #Creates a persisted operational record for a WorkflowRuntime.
Parameters
Name
Type
Description
runtimeIdStringThe runtime identifier.
Returns
Type
Description
Task<WorkflowRuntimeModel>The created WorkflowRuntimeModel.
Task<WorkflowRuntimeModel> UpdateWorkflowRuntimeStatusAsync(WorkflowRuntimeModel runtime, RuntimeStatus status) #Updates the persisted status of a WorkflowRuntime using its concurrency token.
Parameters
Name
Type
Description
runtimeWorkflowRuntimeModelThe WorkflowRuntimeModel containing the current WorkflowRuntimeModel.Lock.
Returns
Type
Description
Task<WorkflowRuntimeModel>The updated WorkflowRuntimeModel.
Exceptions
Type
Description
ImpossibleToSetRuntimeStatusExceptionThe WorkflowRuntimeModel cannot be updated with the supplied concurrency token.
Task<(bool Success, WorkflowRuntimeModel UpdatedModel)> UpdateWorkflowRuntimeRestorerAsync(WorkflowRuntimeModel runtime, string restorerId) #Attempts to assign a WorkflowRuntime to restore processes associated with another WorkflowRuntime.
Parameters
Name
Type
Description
runtimeWorkflowRuntimeModelThe WorkflowRuntimeModel containing the current WorkflowRuntimeModel.Lock.
Returns
Type
Description
Task<Boolean, WorkflowRuntimeModel>A result that indicates whether the update succeeded and contains the updated WorkflowRuntimeModel when it did.
Task<List<Guid>> GetRunningProcessesAsync(string runtimeId = null) #Gets the identifiers of ProcessInstance objects whose status is ProcessStatus.Running.
Parameters
Name
Type
Description
runtimeIdStringThe optional runtime identifier used to filter the ProcessInstance objects, or null or an empty string to include all WorkflowRuntime instances.
Returns
Type
Description
Task<Guid>The identifiers of the matching ProcessInstance objects.
Task<List<ProcessTimer>> GetActiveTimersForProcessAsync(Guid processId) #Gets the timer registrations for a ProcessInstance that have not been marked as ignored.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
Returns
Type
Description
Task<ProcessTimer>The active ProcessTimer objects registered for the ProcessInstance.
Task DeleteInactiveTimersByProcessIdAsync(Guid processId) #Deletes timer registrations for a ProcessInstance that have been marked as ignored.
Parameters
Name
Type
Description
processIdGuidThe process identifier.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task DeleteTimerAsync(Guid timerId) #Deletes a persisted timer registration.
Parameters
Name
Type
Description
timerIdGuidThe timer registration identifier.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task<List<WorkflowTimer>> GetTopTimersToExecuteAsync(int top) #Gets a limited set of due timer registrations that have not been marked as ignored.
Parameters
Name
Type
Description
topInt32The maximum number of timer registrations to return.
Returns
Type
Description
Task<WorkflowTimer>The due WorkflowTimer objects in execution-time order.
Exceptions
Type
Description
ArgumentExceptiontop is not greater than zero.Task<int> SetTimerIgnoreAsync(Guid id) #Marks a persisted timer registration as ignored so it is not selected for execution.
Parameters
Name
Type
Description
idGuidThe timer registration identifier.
Returns
Type
Description
Task<Int32>The number of timer records changed.
Task<int> ActiveMultiServerRuntimesCountAsync(string currentRuntimeId) #Counts multi-server WorkflowRuntime records whose status is RuntimeStatus.Alive, RuntimeStatus.Restore, or RuntimeStatus.SelfRestore, excluding the specified runtime.
Parameters
Name
Type
Description
currentRuntimeIdStringThe runtime identifier to exclude from the count.
Returns
Type
Description
Task<Int32>The number of other active multi-server WorkflowRuntime records.
Task<WorkflowRuntimeModel> GetWorkflowRuntimeModelAsync(string runtimeId) #Gets the persisted operational model for a WorkflowRuntime.
Parameters
Name
Type
Description
runtimeIdStringThe runtime identifier.
Returns
Type
Description
Task<WorkflowRuntimeModel>The persisted WorkflowRuntimeModel, or null when no matching runtime record exists.
Task<List<WorkflowRuntimeModel>> GetWorkflowRuntimesAsync() #Gets all persisted WorkflowRuntimeModel records.
Returns
Type
Description
Task<WorkflowRuntimeModel>The persisted WorkflowRuntimeModel objects.
Task<int> SendRuntimeLastAliveSignalAsync() #Updates WorkflowRuntimeModel.LastAliveSignal for the current WorkflowRuntime when its status is RuntimeStatus.Alive or RuntimeStatus.SelfRestore.
Returns
Type
Description
Task<Int32>The number of runtime records changed.
Task<DateTime?> GetNextTimerDateAsync(TimerCategory timerCategory, int timerInterval) #Attempts to reserve the next timer polling time for a TimerCategory in multi-server mode.
Parameters
Name
Type
Description
timerCategoryTimerCategoryThe TimerCategory.Timer or TimerCategory.ServiceTimer category whose polling time is reserved.
timerIntervalInt32The interval, in milliseconds, between polling times.
Returns
Type
Description
Task<DateTime>The reserved polling date and time, or null when another WorkflowRuntime changed the coordination lock first.
Task DeleteWorkflowRuntimeAsync(string name) #Deletes a persisted WorkflowRuntime record.
Parameters
Name
Type
Description
nameStringThe runtime identifier.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Task DropUnusedWorkflowProcessSchemeAsync() #Deletes obsolete compiled process schemes that are not referenced by persisted ProcessInstance records when the provider supports this cleanup operation.
Returns
Type
Description
TaskA Task that represents the asynchronous operation.
Exceptions
Type
Description
NotImplementedExceptionThe provider does not support cleanup of unused compiled process schemes.
Task<List<ProcessInstanceItem>> GetProcessInstancesAsync(List<(string parameterName, SortDirection sortDirection)> orderParameters = null, Paging paging = null) #Gets persisted process instance records using optional ordering and paging.
Parameters
Name
Type
Description
orderParametersList<String, SortDirection>The ordered list of persisted field names and corresponding SortDirection values, or null to use the provider's default ordering.
Returns
Type
Description
Task<ProcessInstanceItem>The selected ProcessInstanceItem records.
Task<int> GetProcessInstancesCountAsync() #Gets the total number of persisted process instance records.
Returns
Type
Description
Task<Int32>The number of persisted process instance records.
Task<List<SchemeItem>> GetSchemesAsync(List<(string parameterName, SortDirection sortDirection)> orderParameters, Paging paging) #Gets persisted workflow scheme records using the specified ordering and paging.
Parameters
Name
Type
Description
orderParametersList<String, SortDirection>The ordered list of persisted field names and corresponding SortDirection values.
Returns
Type
Description
Task<SchemeItem>The selected SchemeItem records.
Task<int> GetSchemesCountAsync() #Gets the total number of persisted workflow scheme records.
Returns
Type
Description
Task<Int32>The number of persisted workflow scheme records.