Skip to content

Commit

Permalink
added in access to variables for every delegate even (readonly though)
Browse files Browse the repository at this point in the history
  • Loading branch information
roger-castaldo committed Feb 15, 2017
1 parent 083afa4 commit 5b7d177
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
1 change: 1 addition & 0 deletions BpmEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
<Compile Include="ProcessState.cs" />
<Compile Include="ProcessVariablesContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReadOnlyProcessVariablesContainer.cs" />
<Compile Include="Structures.cs" />
<Compile Include="Utility.cs" />
<Compile Include="XmlPrefixMap.cs" />
Expand Down
32 changes: 16 additions & 16 deletions BusinessProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private void _ErrorExternalTask(string taskID, Exception ex)
if (elem.id == taskID && elem is ATask)
{
if (_onTaskError != null)
_onTaskError((ATask)elem);
_onTaskError((ATask)elem, new ReadOnlyProcessVariablesContainer(elem.id, _state));
lock (_state)
{
_state.Path.FailTask((ATask)elem);
Expand Down Expand Up @@ -400,7 +400,7 @@ private void _suspendEvent(object parameters)
AEvent evnt = (AEvent)ie;
lock (_state) { _state.Path.SucceedEvent(evnt); }
if (_onEventCompleted != null)
_onEventCompleted(evnt);
_onEventCompleted(evnt,new ReadOnlyProcessVariablesContainer(ie.id,_state));
break;
}
}
Expand Down Expand Up @@ -573,15 +573,15 @@ public bool BeginProcess(ProcessVariablesContainer variables)
{
WriteLogLine(LogLevels.Info, new StackFrame(1, true), DateTime.Now, string.Format("Valid Process Start[{0}] located, beginning process", se.id));
if (_onProcessStarted != null)
_onProcessStarted(p);
_onProcessStarted(p, new ReadOnlyProcessVariablesContainer(variables));
if (_onEventStarted!=null)
_onEventStarted(se);
_onEventStarted(se, new ReadOnlyProcessVariablesContainer(variables));
_state.Path.StartEvent(se, null);
foreach (string str in variables.Keys)
_state[se.id,str]=variables[str];
_state.Path.SucceedEvent(se);
if (_onEventCompleted!=null)
_onEventCompleted(se);
_onEventCompleted(se, new ReadOnlyProcessVariablesContainer(se.id, _state));
ret=true;
}
}
Expand Down Expand Up @@ -699,7 +699,7 @@ private void _ProcessElement(string sourceID,IElement elem)
_state.Path.ProcessSequenceFlow(sf);
}
if (_onSequenceFlowCompleted != null)
_onSequenceFlowCompleted(sf);
_onSequenceFlowCompleted(sf,new ReadOnlyProcessVariablesContainer(elem.id,_state));
}
else if (elem is MessageFlow)
{
Expand All @@ -709,7 +709,7 @@ private void _ProcessElement(string sourceID,IElement elem)
_state.Path.ProcessMessageFlow(mf);
}
if (_onMessageFlowCompleted != null)
_onMessageFlowCompleted(mf);
_onMessageFlowCompleted(mf, new ReadOnlyProcessVariablesContainer(elem.id, _state));
}
else if (elem is AGateway)
{
Expand All @@ -731,7 +731,7 @@ private void _ProcessElement(string sourceID,IElement elem)
_state.Path.StartGateway(gw, sourceID);
}
if (_onGatewayStarted != null)
_onGatewayStarted(gw);
_onGatewayStarted(gw, new ReadOnlyProcessVariablesContainer(elem.id, _state));
string[] outgoings = null;
try
{
Expand All @@ -741,7 +741,7 @@ private void _ProcessElement(string sourceID,IElement elem)
{
WriteLogException(new StackFrame(1, true), DateTime.Now, e);
if (_onGatewayError != null)
_onGatewayError(gw);
_onGatewayError(gw, new ReadOnlyProcessVariablesContainer(elem.id, _state));
outgoings = null;
}
lock (_state)
Expand All @@ -756,7 +756,7 @@ private void _ProcessElement(string sourceID,IElement elem)
{
AEvent evnt = (AEvent)elem;
if (_onEventStarted != null)
_onEventStarted(evnt);
_onEventStarted(evnt, new ReadOnlyProcessVariablesContainer(elem.id, _state));
lock (_state)
{
_state.Path.StartEvent(evnt, sourceID);
Expand Down Expand Up @@ -792,17 +792,17 @@ private void _ProcessElement(string sourceID,IElement elem)
{
lock (_state) { _state.Path.FailEvent(evnt); }
if (_onEventError != null)
_onEventError(evnt);
_onEventError(evnt, new ReadOnlyProcessVariablesContainer(elem.id, _state));
}
else
{
lock (_state) { _state.Path.SucceedEvent(evnt); }
if (_onEventCompleted != null)
_onEventCompleted(evnt);
_onEventCompleted(evnt, new ReadOnlyProcessVariablesContainer(elem.id, _state));
if (evnt is EndEvent)
{
if (_onProcessCompleted != null)
_onProcessCompleted(((EndEvent)evnt).Process);
_onProcessCompleted(((EndEvent)evnt).Process, new ReadOnlyProcessVariablesContainer(elem.id, _state));
_processLock.Set();
}
}
Expand All @@ -811,7 +811,7 @@ private void _ProcessElement(string sourceID,IElement elem)
{
ATask tsk = (ATask)elem;
if (_onTaskStarted != null)
_onTaskStarted(tsk);
_onTaskStarted(tsk, new ReadOnlyProcessVariablesContainer(elem.id, _state));
lock (_state)
{
_state.Path.StartTask(tsk, sourceID);
Expand Down Expand Up @@ -869,7 +869,7 @@ private void _ProcessElement(string sourceID,IElement elem)
{
WriteLogException(new StackFrame(1, true), DateTime.Now, e);
if (_onTaskError != null)
_onTaskError(tsk);
_onTaskError(tsk, new ReadOnlyProcessVariablesContainer(elem.id, _state));
lock (_state) { _state.Path.FailTask(tsk); }
}
}
Expand Down Expand Up @@ -911,7 +911,7 @@ private void _MergeVariables(ATask task, ProcessVariablesContainer variables,str
}
}
if (_onTaskCompleted != null)
_onTaskCompleted(task);
_onTaskCompleted(task, new ReadOnlyProcessVariablesContainer(task.id, _state));
if (task is UserTask)
_state.Path.SucceedTask((UserTask)task,completedByID);
else
Expand Down
28 changes: 14 additions & 14 deletions Delegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
namespace Org.Reddragonit.BpmEngine
{
#region Ons
public delegate void OnEventStarted(IElement Event);
public delegate void OnEventCompleted(IElement Event);
public delegate void OnEventError(IElement Event);
public delegate void OnTaskStarted(IElement task);
public delegate void OnTaskCompleted(IElement task);
public delegate void OnTaskError(IElement task);
public delegate void OnProcessStarted(IElement process);
public delegate void OnProcessCompleted(IElement process);
public delegate void OnProcessError(IElement process);
public delegate void OnSequenceFlowCompleted(IElement flow);
public delegate void OnMessageFlowCompleted(IElement flow);
public delegate void OnGatewayStarted(IElement gateway);
public delegate void OnGatewayCompleted(IElement gateway);
public delegate void OnGatewayError(IElement gateway);
public delegate void OnEventStarted(IElement Event, ReadOnlyProcessVariablesContainer variables);
public delegate void OnEventCompleted(IElement Event, ReadOnlyProcessVariablesContainer variables);
public delegate void OnEventError(IElement Event, ReadOnlyProcessVariablesContainer variables);
public delegate void OnTaskStarted(IElement task, ReadOnlyProcessVariablesContainer variables);
public delegate void OnTaskCompleted(IElement task, ReadOnlyProcessVariablesContainer variables);
public delegate void OnTaskError(IElement task, ReadOnlyProcessVariablesContainer variables);
public delegate void OnProcessStarted(IElement process, ReadOnlyProcessVariablesContainer variables);
public delegate void OnProcessCompleted(IElement process, ReadOnlyProcessVariablesContainer variables);
public delegate void OnProcessError(IElement process, ReadOnlyProcessVariablesContainer variables);
public delegate void OnSequenceFlowCompleted(IElement flow, ReadOnlyProcessVariablesContainer variables);
public delegate void OnMessageFlowCompleted(IElement flow, ReadOnlyProcessVariablesContainer variables);
public delegate void OnGatewayStarted(IElement gateway, ReadOnlyProcessVariablesContainer variables);
public delegate void OnGatewayCompleted(IElement gateway, ReadOnlyProcessVariablesContainer variables);
public delegate void OnGatewayError(IElement gateway, ReadOnlyProcessVariablesContainer variables);
public delegate void OnStateChange(XmlDocument stateDocument);
internal delegate void processStateChanged();
#endregion
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
25 changes: 25 additions & 0 deletions ReadOnlyProcessVariablesContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Org.Reddragonit.BpmEngine
{
public class ReadOnlyProcessVariablesContainer
{
private ProcessVariablesContainer _variables;

internal ReadOnlyProcessVariablesContainer(string elementID, ProcessState state)
{
_variables = new BpmEngine.ProcessVariablesContainer(elementID,state);
}

internal ReadOnlyProcessVariablesContainer(ProcessVariablesContainer variables)
{
_variables = variables;
}

public object this[string name] { get { return _variables[name]; } }

public string[] Keys { get { return _variables.Keys; } }
}
}

0 comments on commit 5b7d177

Please sign in to comment.