forked from optimajet/WorkflowEngine.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIPersistenceProvider.cs
More file actions
271 lines (219 loc) · 12.3 KB
/
IPersistenceProvider.cs
File metadata and controls
271 lines (219 loc) · 12.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using OptimaJet.Workflow.Core.Fault;
using OptimaJet.Workflow.Core.Model;
using OptimaJet.Workflow.Core.Runtime;
using OptimaJet.Workflow.Core.Runtime.Timers;
namespace OptimaJet.Workflow.Core.Persistence
{
/// <summary>
/// Interface of a persistence provider, which provide storing of process's instance specific parameters and global parameters
/// </summary>
public interface IPersistenceProvider
{
/// <summary>
/// Init the provider
/// </summary>
/// <param name="runtime">Workflow runtime instance which owned the provider</param>
void Init(WorkflowRuntime runtime);
/// <summary>
/// Initialize a process instance in persistence store
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <exception cref="ProcessAlreadyExistsException"></exception>
Task InitializeProcessAsync(ProcessInstance processInstance);
/// <summary>
/// Fills system <see cref="ParameterPurpose.System"/> and persisted <see cref="ParameterPurpose.Persistence"/> parameters of the process
/// </summary>
/// <param name="processInstance">Instance of the process</param>
Task FillProcessParametersAsync(ProcessInstance processInstance);
/// <summary>
/// Fills persisted <see cref="ParameterPurpose.Persistence"/> parameters of the process
/// </summary>
/// <param name="processInstance">Instance of the process</param>
Task FillPersistedProcessParametersAsync(ProcessInstance processInstance);
/// <summary>
/// Fills persisted <see cref="ParameterPurpose.Persistence"/> parameter of the process
/// </summary>
/// <param name="processInstance">Instance of the process</param>
Task FillPersistedProcessParameterAsync(ProcessInstance processInstance, string parameterName);
/// <summary>
/// Fills system <see cref="ParameterPurpose.System"/> parameters of the process
/// </summary>
/// <param name="processInstance">Instance of the process</param>
Task FillSystemProcessParametersAsync(ProcessInstance processInstance);
/// <summary>
/// Saves persisted <see cref="ParameterPurpose.Persistence"/> parameters of the process to store
/// </summary>
/// <param name="processInstance">Instance of the process</param>
Task SavePersistenceParametersAsync(ProcessInstance processInstance);
/// <summary>
/// Save persisted <see cref="ParameterPurpose.Persistence"/> parameter of the process to store
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <param name="parameterName">Name of parameter for save</param>
Task SavePersistenceParameterAsync(ProcessInstance processInstance, string parameterName);
/// <summary>
/// Remove persisted <see cref="ParameterPurpose.Persistence"/> parameter of the process from store
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <param name="parameterName">Name of parameter for save</param>
Task RemoveParameterAsync(ProcessInstance processInstance, string parameterName);
/// <summary>
/// Set process instance status to <see cref="ProcessStatus.Initialized"/>
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <exception cref="ImpossibleToSetStatusException"></exception>
Task SetWorkflowInitializedAsync(ProcessInstance processInstance);
/// <summary>
/// Set process instance status to <see cref="ProcessStatus.Idled"/>
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <exception cref="ImpossibleToSetStatusException"></exception>
Task SetWorkflowIdledAsync(ProcessInstance processInstance);
/// <summary>
/// Set process instance status to <see cref="ProcessStatus.Running"/>
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <exception cref="ImpossibleToSetStatusException"></exception>
Task SetWorkflowRunningAsync(ProcessInstance processInstance);
/// <summary>
/// Set process instance status to <see cref="ProcessStatus.Finalized"/>
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <exception cref="ImpossibleToSetStatusException"></exception>
Task SetWorkflowFinalizedAsync(ProcessInstance processInstance);
/// <summary>
/// Set process instance status to newStatus
/// </summary>
/// <param name="processId">Process id</param>
/// <param name="newStatus">New process status</param>
/// <exception cref="ImpossibleToSetStatusException"></exception>
Task SetProcessStatusAsync(Guid processId, ProcessStatus newStatus);
/// <summary>
/// Set process instance status to <see cref="ProcessStatus.Terminated"/>
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <exception cref="ImpossibleToSetStatusException"></exception>
Task SetWorkflowTerminatedAsync(ProcessInstance processInstance);
/// <summary>
/// Updates system parameters of the process in the store
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <param name="transition">Last executed transition</param>
Task UpdatePersistenceStateAsync(ProcessInstance processInstance, TransitionDefinition transition);
/// <summary>
/// Checks existence of the process
/// </summary>
/// <param name="processId">Id of the process</param>
/// <returns></returns>
Task<bool> IsProcessExistsAsync(Guid processId);
/// <summary>
/// Returns status of the process <see cref="ProcessStatus"/>
/// </summary>
/// <param name="processId">Id of the process</param>
/// <returns>Status of the process</returns>
Task<ProcessStatus> GetInstanceStatusAsync(Guid processId);
/// <summary>
/// Saves information about changed scheme to the store
/// </summary>
/// <param name="processInstance">Instance of the process whith changed scheme <see cref="ProcessInstance.ProcessScheme"/></param>
Task BindProcessToNewSchemeAsync(ProcessInstance processInstance);
/// <summary>
/// Saves information about changed scheme to the store
/// </summary>
/// <param name="processInstance">Instance of the process whith changed scheme <see cref="ProcessInstance.ProcessScheme"/></param>
/// <param name="resetIsDeterminingParametersChanged">True if required to reset IsDeterminingParametersChanged flag <see cref="ProcessInstance.IsDeterminingParametersChanged"/></param>
/// <exception cref="ProcessNotFoundException"></exception>
Task BindProcessToNewSchemeAsync(ProcessInstance processInstance, bool resetIsDeterminingParametersChanged);
/// <summary>
/// Register a new timer
/// </summary>
/// <param name="processId">Id of the process</param>
/// <param name="rootProcessId">Id of the root process</param>
/// <param name="name">Timer name <see cref="TimerDefinition.Name"/></param>
/// <param name="nextExecutionDateTime">Next date and time of timer's execution</param>
/// <param name="notOverrideIfExists">If true specifies that the existing timer with same name will not be overriden <see cref="TimerDefinition.NotOverrideIfExists"/></param>
Task RegisterTimerAsync(Guid processId, Guid rootProcessId, string name, DateTime nextExecutionDateTime, bool notOverrideIfExists);
/// <summary>
/// Removes all timers from the store, exlude listed in ignore list
/// </summary>
/// <param name="processId">Id of the process</param>
/// <param name="timersIgnoreList">Ignore list</param>
Task ClearTimersAsync(Guid processId, List<string> timersIgnoreList);
/// <summary>
/// Get all timers of a process
/// </summary>
/// <param name="processId">Id of the process</param>
/// <returns></returns>
Task<List<ProcessTimer>> GetTimersForProcessAsync(Guid processId);
/// <summary>
/// Remove all information about the process from the store
/// </summary>
/// <param name="processId">Id of the process</param>
Task DeleteProcessAsync(Guid processId);
/// <summary>
/// Remove all information about the process from the store
/// </summary>
/// <param name="processIds">List of ids of the process</param>
Task DeleteProcessAsync(Guid[] processIds);
/// <summary>
/// Saves a global parameter value
/// </summary>
/// <typeparam name="T">System type of the parameter</typeparam>
/// <param name="type">Logical type of the parameter</param>
/// <param name="name">Name of the parameter</param>
/// <param name="value">Value of the parameter</param>
Task SaveGlobalParameterAsync<T>(string type, string name, T value);
/// <summary>
/// Returns a global parameter value
/// </summary>
/// <typeparam name="T">System type of the parameter</typeparam>
/// <param name="type">Logical type of the parameter</param>
/// <param name="name">Name of the parameter</param>
/// <returns>Value of the parameter</returns>
Task<T> LoadGlobalParameterAsync<T>(string type, string name);
/// <summary>
/// Returns a global parameter value
/// </summary>
/// <typeparam name="T">System type of the parameter</typeparam>
/// <param name="type">Logical type of the parameter</param>
/// <returns>List of the values of the parameters</returns>
Task<List<T>> LoadGlobalParametersAsync<T>(string type);
/// <summary>
/// Deletes a global parameter
/// </summary>
/// <param name="type">Logical type of the parameter</param>
/// <param name="name">Name of the parameter</param>
Task DeleteGlobalParametersAsync(string type, string name = null);
/// <summary>
/// Returns the history of process
/// </summary>
/// <param name="processId">Id of the process</param>
/// <returns></returns>
Task<List<ProcessHistoryItem>> GetProcessHistoryAsync(Guid processId);
bool IsBulkOperationsSupported { get; }
Task BulkInitProcessesAsync(List<ProcessInstance> instances, ProcessStatus status, CancellationToken token);
Task BulkInitProcessesAsync(List<ProcessInstance> instances, List<TimerToRegister> timers, ProcessStatus status, CancellationToken token);
Task<List<IProcessInstanceTreeItem>> GetProcessInstanceTreeAsync(Guid rootProcessId);
Task<bool> MultiServerRuntimesExistAsync();
Task<WorkflowRuntimeModel> CreateWorkflowRuntimeAsync(string runtimeId, RuntimeStatus status);
Task<WorkflowRuntimeModel> UpdateWorkflowRuntimeStatusAsync(WorkflowRuntimeModel runtime, RuntimeStatus status);
Task<(bool Success, WorkflowRuntimeModel UpdatedModel)> UpdateWorkflowRuntimeRestorerAsync(WorkflowRuntimeModel runtime, string restorerId);
Task<List<Guid>> GetRunningProcessesAsync(string runtimeId = null);
Task<List<ProcessTimer>> GetActiveTimersForProcessAsync(Guid processId);
Task DeleteInactiveTimersByProcessIdAsync(Guid processId);
Task DeleteTimerAsync(Guid timerId);
Task<List<Model.WorkflowTimer>> GetTopTimersToExecuteAsync(int top);
Task<int> SetTimerIgnoreAsync(Guid id);
Task<int> ActiveMultiServerRuntimesCountAsync(string currentRuntimeId);
Task<WorkflowRuntimeModel> GetWorkflowRuntimeModelAsync(string runtimeId);
Task<List<WorkflowRuntimeModel>> GetWorkflowRuntimesAsync();
Task<int> SendRuntimeLastAliveSignalAsync();
Task<DateTime?> GetNextTimerDateAsync(TimerCategory timerCategory, int timerInterval);
Task DeleteWorkflowRuntimeAsync(string name);
IApprovalProvider GetIApprovalProvider();
}
}