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
233 lines (198 loc) · 10.1 KB
/
IPersistenceProvider.cs
File metadata and controls
233 lines (198 loc) · 10.1 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
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;
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>
void InitializeProcess(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>
void FillProcessParameters(ProcessInstance processInstance);
/// <summary>
/// Fills persisted <see cref="ParameterPurpose.Persistence"/> parameters of the process
/// </summary>
/// <param name="processInstance">Instance of the process</param>
void FillPersistedProcessParameters(ProcessInstance processInstance);
/// <summary>
/// Fills system <see cref="ParameterPurpose.System"/> parameters of the process
/// </summary>
/// <param name="processInstance">Instance of the process</param>
void FillSystemProcessParameters(ProcessInstance processInstance);
/// <summary>
/// Saves persisted <see cref="ParameterPurpose.Persistence"/> parameters of the process to store
/// </summary>
/// <param name="processInstance">Instance of the process</param>
void SavePersistenceParameters(ProcessInstance processInstance);
/// <summary>
/// Set process instance status to <see cref="ProcessStatus.Initialized"/>
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <exception cref="ImpossibleToSetStatusException"></exception>
void SetWorkflowIniialized(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>
void SetWorkflowIdled(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>
void SetWorkflowRunning(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>
void SetWorkflowFinalized(ProcessInstance processInstance);
/// <summary>
/// Set process instance status to <see cref="ProcessStatus.Terminated"/>
/// </summary>
/// <param name="processInstance">Instance of the process</param>
/// <exception cref="ImpossibleToSetStatusException"></exception>
#pragma warning disable 612
void SetWorkflowTerminated(ProcessInstance processInstance, ErrorLevel level, string errorMessage);
#pragma warning restore 612
/// <summary>
/// Resets all process to <see cref="ProcessStatus.Idled"/> status
/// </summary>
void ResetWorkflowRunning();
/// <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>
void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition);
/// <summary>
/// Checks existence of the process
/// </summary>
/// <param name="processId">Id of the process</param>
/// <returns></returns>
bool IsProcessExists(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>
ProcessStatus GetInstanceStatus(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>
void BindProcessToNewScheme(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>
void BindProcessToNewScheme(ProcessInstance processInstance, bool resetIsDeterminingParametersChanged);
/// <summary>
/// Register a new timer
/// </summary>
/// <param name="processId">Id of the 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>
void RegisterTimer(Guid processId, 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>
void ClearTimers(Guid processId, List<string> timersIgnoreList);
/// <summary>
/// Clears sign Ignore for all timers
/// </summary>
void ClearTimersIgnore();
/// <summary>
/// Clears sign Ignore for specific timers
/// </summary>
void ClearTimerIgnore(Guid timerId);
/// <summary>
/// Remove specific timer
/// </summary>
/// <param name="timerId">Id of the timer</param>
void ClearTimer(Guid timerId);
/// <summary>
/// Get closest execution date and time for all timers
/// </summary>
/// <returns></returns>
DateTime? GetCloseExecutionDateTime();
/// <summary>
/// Get all timers which must be executed at this moment of time
/// </summary>
/// <returns>List of timers to execute</returns>
List<TimerToExecute> GetTimersToExecute();
/// <summary>
/// Remove all information about the process from the store
/// </summary>
/// <param name="processId">Id of the process</param>
void DeleteProcess(Guid processId);
/// <summary>
/// Remove all information about the process from the store
/// </summary>
/// <param name="processIds">List of ids of the process</param>
void DeleteProcess(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>
void SaveGlobalParameter<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>
T LoadGlobalParameter<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>
List<T> LoadGlobalParameters<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>
void DeleteGlobalParameters(string type, string name = null);
/// <summary>
/// Returns the history of process
/// </summary>
/// <param name="processId">Id of the process</param>
/// <returns></returns>
List<ProcessHistoryItem> GetProcessHistory(Guid processId);
bool IsBulkOperationsSupported { get; }
Task BulkInitProcesses(List<ProcessInstance> instances, ProcessStatus status, CancellationToken token);
Task BulkInitProcesses(List<ProcessInstance> instances, List<TimerToRegister> timers, ProcessStatus status, CancellationToken token);
}
}