Skip to content

Commit 663e4cf

Browse files
committed
Version 1.5
1 parent 51e4743 commit 663e4cf

158 files changed

Lines changed: 2965 additions & 106077 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Interfaces/ErrorLevel.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
6+
namespace OptimaJet.Workflow.Core.Persistence
7+
{
8+
[Obsolete]
9+
public enum ErrorLevel
10+
{
11+
Critical
12+
}
13+
}

Interfaces/ISchemePersistenceProvider.cs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,15 @@ public interface ISchemePersistenceProvider<TSchemeMedium> where TSchemeMedium :
2929
/// </summary>
3030
/// <param name="schemeCode">Name of the scheme</param>
3131
/// <param name="parameters">Parameters for creating the scheme</param>
32+
/// <param name="rootSchemeId">Id of the root scheme in case of subprocess</param>
3233
/// <param name="ignoreObsolete">True if you need to ignore obsolete schemes</param>
3334
/// <returns>Not parsed scheme of the process</returns>
3435
SchemeDefinition<TSchemeMedium> GetProcessSchemeWithParameters(string schemeCode,
35-
IDictionary<string, object> parameters,
36-
bool ignoreObsolete);
37-
/// <summary>
38-
/// Gets not parsed scheme by scheme name and parameters
39-
/// </summary>
40-
/// <param name="schemeCode">Name of the scheme</param>
41-
/// <param name="parameters">Parameters for creating the scheme</param>
42-
/// <returns>Not parsed scheme of the process</returns>
43-
SchemeDefinition<TSchemeMedium> GetProcessSchemeWithParameters(string schemeCode,
44-
IDictionary<string, object> parameters);
36+
string parameters,
37+
Guid? rootSchemeId,
38+
bool ignoreObsolete);
39+
40+
4541
/// <summary>
4642
/// Gets not parsed scheme by scheme name
4743
/// </summary>
@@ -52,14 +48,8 @@ SchemeDefinition<TSchemeMedium> GetProcessSchemeWithParameters(string schemeCode
5248
/// <summary>
5349
/// Saves scheme to a store
5450
/// </summary>
55-
/// <param name="schemeCode">Name of the scheme</param>
56-
/// <param name="schemeId">Id of the scheme</param>
57-
/// <param name="scheme">Not parsed scheme</param>
58-
/// <param name="parameters">Parameters for creating the scheme</param>
59-
void SaveScheme(string schemeCode,
60-
Guid schemeId,
61-
TSchemeMedium scheme,
62-
IDictionary<string, object> parameters);
51+
/// <param name="scheme">Not parsed scheme of the process</param>
52+
void SaveScheme(SchemeDefinition<TSchemeMedium> scheme);
6353

6454
/// <summary>
6555
/// Sets sign IsObsolete to the scheme

Interfaces/IWorkflowBuilder.cs

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using OptimaJet.Workflow.Core.Cache;
4+
using OptimaJet.Workflow.Core.Model;
5+
6+
namespace OptimaJet.Workflow.Core.Builder
7+
{
8+
/// <summary>
9+
/// Interface of a workflow builder, which convert not parsed process scheme <see cref="SchemeDefinition{T}"/> to the object model of a scheme of a process <see cref="ProcessDefinition"/>
10+
/// </summary>
11+
public interface IWorkflowBuilder
12+
{
13+
/// <summary>
14+
/// Create new instance of the process.
15+
/// </summary>
16+
/// <param name="processId">Process id</param>
17+
/// <param name="schemeCode">Code of the scheme</param>
18+
/// <param name="parameters">The parameters for creating the scheme of the process</param>
19+
/// <returns>ProcessInstance object</returns>
20+
ProcessInstance CreateNewProcess(Guid processId,
21+
string schemeCode,
22+
IDictionary<string, object> parameters);
23+
24+
25+
ProcessInstance CreateNewSubprocess(Guid processId,
26+
ProcessInstance parentProcessInstance,
27+
TransitionDefinition startingTransition
28+
);
29+
30+
31+
/// <summary>
32+
/// Create new scheme for existing process
33+
/// </summary>
34+
/// <param name="schemeCode">Code of the scheme</param>
35+
/// <param name="parameters">The parameters for creating scheme of process</param>
36+
/// <returns>ProcessDefinition object</returns>
37+
ProcessDefinition CreateNewProcessScheme(string schemeCode, IDictionary<string, object> parameters);
38+
39+
ProcessDefinition CreateNewSubprocessScheme(ProcessDefinition parentProcessScheme,
40+
TransitionDefinition startingTransition);
41+
42+
/// <summary>
43+
/// Returns existing process instance
44+
/// </summary>
45+
/// <param name="processId">Process id</param>
46+
/// <returns>ProcessInstance object</returns>
47+
ProcessInstance GetProcessInstance(Guid processId);
48+
49+
/// <summary>
50+
/// Returns process scheme by specific id, if scheme not exists creates it
51+
/// </summary>
52+
/// <param name="schemeId">Id of the scheme</param>
53+
/// <returns>ProcessDefinition object</returns>
54+
ProcessDefinition GetProcessScheme(Guid schemeId);
55+
56+
/// <summary>
57+
/// Sets the cache to store parsed ProcessDefinition objects <see cref="ProcessDefinition"/>
58+
/// </summary>
59+
/// <param name="cache">Instance of cache object</param>
60+
void SetCache(IParsedProcessCache cache);
61+
62+
/// <summary>
63+
/// Removes the cache to store parsed ProcessDefinition objects <see cref="ProcessDefinition"/>
64+
/// </summary>
65+
void RemoveCache();
66+
67+
/// <summary>
68+
/// Returns process scheme by specific name, if scheme not exists creates it
69+
/// </summary>
70+
/// <param name="schemeCode">Name of the scheme</param>
71+
/// <returns>ProcessDefinition object</returns>
72+
ProcessDefinition GetProcessScheme(string schemeCode);
73+
74+
/// <summary>
75+
/// Returns process scheme by specific name and parameters for creating the scheme of the process, if scheme not exists creates it
76+
/// </summary>
77+
/// <param name="schemeCode">Name of the scheme</param>
78+
/// <param name="parameters">The parameters for creating the scheme of the process</param>
79+
/// <returns>ProcessDefinition object</returns>
80+
ProcessDefinition GetProcessScheme(string schemeCode, IDictionary<string, object> parameters);
81+
82+
/// <summary>
83+
/// Set IsObsolete sign to the scheme with specific name and parameters for creating the scheme of the process
84+
/// </summary>
85+
/// <param name="schemeCode">Name of the scheme</param>
86+
/// <param name="parameters">The parameters for creating the scheme of the process</param>
87+
void SetSchemeIsObsolete(string schemeCode, Dictionary<string, object> parameters);
88+
89+
/// <summary>
90+
/// Set IsObsolete sign to the scheme with specific name
91+
/// </summary>
92+
/// <param name="schemeCode">Name of the scheme</param>
93+
void SetSchemeIsObsolete(string schemeCode);
94+
95+
/// <summary>
96+
/// Returns existing process scheme directly from scheme persistence store
97+
/// </summary>
98+
/// <param name="code">Name of the scheme</param>
99+
/// <returns>ProcessDefinition object</returns>
100+
ProcessDefinition GetProcessSchemeForDesigner(string code);
101+
102+
/// <summary>
103+
/// Saves process scheme to scheme persistence store
104+
/// </summary>
105+
/// <param name="schemecode">Code of the scheme</param>
106+
/// <param name="pd">Object representation of the scheme</param>
107+
void SaveProcessScheme(string schemecode, ProcessDefinition pd);
108+
109+
/// <summary>
110+
/// Parses process scheme from the string
111+
/// </summary>
112+
/// <param name="scheme">String representation of not parsed scheme</param>
113+
/// <returns>ProcessDefinition object</returns>
114+
ProcessDefinition Parse(string scheme);
115+
116+
/// <summary>
117+
/// Serialize process scheme to the string
118+
/// </summary>
119+
/// <param name="processDefinition">SProcessDefinition object</param>
120+
/// <returns>String representation of not parsed scheme</returns>
121+
string Serialize(ProcessDefinition processDefinition);
122+
}
123+
124+
}

Interfaces/IWorkflowBus.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using OptimaJet.Workflow.Core.Runtime;
4+
5+
namespace OptimaJet.Workflow.Core.Bus
6+
{
7+
/// <summary>
8+
/// Interface of a bus, which provide control over execution of activities and actions
9+
/// </summary>
10+
public interface IWorkflowBus
11+
{
12+
/// <summary>
13+
/// Initialize the bus
14+
/// </summary>
15+
/// <param name="runtime">WorkflowRuntime instance which owned the bus</param>
16+
void Initialize(WorkflowRuntime runtime);
17+
/// <summary>
18+
/// Starts the bus
19+
/// </summary>
20+
void Start();
21+
/// <summary>
22+
/// Queue execution with the list of <see cref="ExecutionRequestParameters"/>
23+
/// </summary>
24+
/// <param name="requestParameters">List of <see cref="ExecutionRequestParameters"/></param>
25+
void QueueExecution(IEnumerable<ExecutionRequestParameters> requestParameters);
26+
/// <summary>
27+
/// Queue execution with the <see cref="ExecutionRequestParameters"/>
28+
/// </summary>
29+
/// <param name="requestParameters">Instance of <see cref="ExecutionRequestParameters"/></param>
30+
void QueueExecution(ExecutionRequestParameters requestParameters);
31+
32+
/// <summary>
33+
/// Event raised after the execution was complete
34+
/// </summary>
35+
event EventHandler<ExecutionResponseEventArgs> ExecutionComplete;
36+
/// <summary>
37+
/// Returns true if the bus supports asynchronous model of execution
38+
/// </summary>
39+
bool IsAsync { get; }
40+
}
41+
}

Interfaces/IWorkflowParser.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using OptimaJet.Workflow.Core.Model;
2+
3+
namespace OptimaJet.Workflow.Core.Parser
4+
{
5+
6+
/// <summary>
7+
/// Interface of a workflow parser, which parses not parsed process scheme <see cref="SchemeDefinition{T}"/> to the object model of a scheme of a process <see cref="ProcessDefinition"/>
8+
/// </summary>
9+
/// <typeparam name="TSchemeMedium">Type of not parsed scheme</typeparam>
10+
public interface IWorkflowParser<TSchemeMedium> where TSchemeMedium : class
11+
{
12+
/// <summary>
13+
/// Returns object model of the scheme of a process
14+
/// </summary>
15+
/// <param name="schemeMedium">Not parsed scheme</param>
16+
/// <returns>ProcessDefinition object</returns>
17+
ProcessDefinition Parse(TSchemeMedium schemeMedium);
18+
/// <summary>
19+
/// Returns object model of the scheme of a process
20+
/// </summary>
21+
/// <param name="scheme">String representation of not parsed scheme</param>
22+
/// <returns>ProcessDefinition object</returns>
23+
ProcessDefinition Parse(string scheme);
24+
25+
/// <summary>
26+
/// Serializes object model of the scheme to not parsed scheme
27+
/// </summary>
28+
/// <param name="processDefinition">ProcessDefinition object</param>
29+
/// <returns>Not parsed scheme</returns>
30+
TSchemeMedium SerializeToSchemeMedium(ProcessDefinition processDefinition);
31+
32+
/// <summary>
33+
/// Serializes object model of the scheme to string
34+
/// </summary>
35+
/// <param name="processDefinition">ProcessDefinition object</param>
36+
/// <returns>String representation of not parsed scheme</returns>
37+
string SerializeToString(ProcessDefinition processDefinition);
38+
}
39+
}

Interfaces/ProcessStatus.cs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
using System.Collections.Generic;
2+
3+
namespace OptimaJet.Workflow.Core.Persistence
4+
{
5+
/// <summary>
6+
/// Represent a stage of a life cycle of a process
7+
/// </summary>
8+
public sealed class ProcessStatus
9+
{
10+
public byte Id { get; private set; }
11+
public bool IsAllowedToChangeStatus { get; set; }
12+
public bool IsAllowedToExecuteCommand { get; set; }
13+
14+
/// <summary>
15+
/// Status of a processes which are not exists in persistence store
16+
/// </summary>
17+
public static readonly ProcessStatus NotFound = new ProcessStatus
18+
{
19+
Id = 255,
20+
IsAllowedToChangeStatus = false,
21+
IsAllowedToExecuteCommand = false
22+
};
23+
24+
/// <summary>
25+
/// Status of a processes which are exists in persistence store but theirs status is not defined
26+
/// </summary>
27+
public static readonly ProcessStatus Unknown = new ProcessStatus
28+
{
29+
Id = 254,
30+
IsAllowedToChangeStatus = false,
31+
IsAllowedToExecuteCommand = false
32+
};
33+
34+
/// <summary>
35+
/// Status of a processes which was created just now
36+
/// </summary>
37+
public static readonly ProcessStatus Initialized = new ProcessStatus
38+
{
39+
Id = 0,
40+
IsAllowedToChangeStatus = false,
41+
IsAllowedToExecuteCommand = false
42+
};
43+
/// <summary>
44+
/// Status of a processes which are executing at current moment
45+
/// </summary>
46+
public static readonly ProcessStatus Running = new ProcessStatus
47+
{
48+
Id = 1,
49+
IsAllowedToChangeStatus = false,
50+
IsAllowedToExecuteCommand = false
51+
};
52+
/// <summary>
53+
/// Status of a processes which are not executing at current moment and awaiting an external interaction
54+
/// </summary>
55+
public static readonly ProcessStatus Idled = new ProcessStatus
56+
{
57+
Id = 2,
58+
IsAllowedToChangeStatus = true,
59+
IsAllowedToExecuteCommand = true
60+
};
61+
/// <summary>
62+
/// Status of a processes which was finalized
63+
/// </summary>
64+
public static readonly ProcessStatus Finalized = new ProcessStatus
65+
{
66+
Id = 3,
67+
IsAllowedToChangeStatus = true,
68+
IsAllowedToExecuteCommand = false
69+
};
70+
71+
/// <summary>
72+
/// Status of a processes which was terminated with an error
73+
/// </summary>
74+
public static readonly ProcessStatus Terminated = new ProcessStatus
75+
{
76+
Id = 4,
77+
IsAllowedToChangeStatus = true,
78+
IsAllowedToExecuteCommand = false
79+
};
80+
81+
/// <summary>
82+
/// Status of a processes which had an error but not terminated
83+
/// </summary>
84+
public static readonly ProcessStatus Error = new ProcessStatus
85+
{
86+
Id = 5,
87+
IsAllowedToChangeStatus = true,
88+
IsAllowedToExecuteCommand = true
89+
};
90+
91+
public static readonly IEnumerable<ProcessStatus> All = new List<ProcessStatus>
92+
{Initialized, Running, Idled, Finalized, Terminated, Error};
93+
}
94+
}

Provider for MS SQL Server/DbPersistenceProvider.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public void InitializeProcess(ProcessInstance processInstance)
3939
Id = processInstance.ProcessId,
4040
SchemeId = processInstance.SchemeId,
4141
ActivityName = processInstance.ProcessScheme.InitialActivity.Name,
42-
StateName = processInstance.ProcessScheme.InitialActivity.State
42+
StateName = processInstance.ProcessScheme.InitialActivity.State,
43+
RootProcessId = processInstance.RootProcessId,
44+
ParentProcessId = processInstance.ParentProcessId
4345
};
4446
context.WorkflowProcessInstances.InsertOnSubmit(newProcess);
4547
context.SubmitChanges();
@@ -372,6 +374,9 @@ public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDe
372374
if (!string.IsNullOrEmpty(transition.From.State))
373375
inst.PreviousStateForReverse = transition.From.State;
374376
}
377+
378+
inst.ParentProcessId = processInstance.ParentProcessId;
379+
inst.RootProcessId = processInstance.RootProcessId;
375380
}
376381

377382
var history = new WorkflowProcessTransitionHistory()
@@ -495,7 +500,13 @@ private IEnumerable<ParameterDefinitionWithValue> GetSystemProcessParameters(Gui
495500
(object) processInstance.SchemeId),
496501
ParameterDefinition.Create(
497502
systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterIsPreExecution.Name),
498-
false)
503+
false),
504+
ParameterDefinition.Create(
505+
systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterParentProcessId.Name),
506+
processInstance.ParentProcessId),
507+
ParameterDefinition.Create(
508+
systemParameters.Single(sp => sp.Name == DefaultDefinitions.ParameterRootProcessId.Name),
509+
processInstance.RootProcessId)
499510
};
500511
return parameters;
501512
}

0 commit comments

Comments
 (0)