From d6e8494a2a02a6ed074a1af28c836518d4056ee5 Mon Sep 17 00:00:00 2001 From: roger-castaldo Date: Thu, 30 May 2019 11:40:15 -0400 Subject: [PATCH] corrected bug wrt incoming flows and gateways executing without proper conditions being met. --- BpmEngine.csproj | 8 ++++---- BusinessProcess.cs | 48 +++++++++++++++++++++++++++------------------- Utility.cs | 1 + 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/BpmEngine.csproj b/BpmEngine.csproj index 743ab4d..ee94e80 100644 --- a/BpmEngine.csproj +++ b/BpmEngine.csproj @@ -4,16 +4,16 @@ netstandard2.0;net452;net20 Org.Reddragonit.BpmEngine Org.Reddragonit.BpmEngine - 1.9.9 + 1.9.10 Roger Castaldo A BPMN Engine written in .net. The engine attempts to read in a bpmn notation xml document defining both the process(s) as well as the diagrams. From here you can then load/unload the state, render the diagram in its current state or animated into a gif. Using the delegates for a process, you intercept and handle task and condition checking by reading additional xml held within flow and task objects. https://github.com/roger-castaldo/BPMEngine https://www.gnu.org/licenses/gpl-3.0.en.html https://github.com/roger-castaldo/BPMEngine BPMN - updated package to use a single control thread for the time delays in all business processes instead of multiple threads per process - 1.9.9.0 - 1.9.9.0 + updated to correct bug wrt not dealing with gateways properly for the incoming paths. + 1.9.10.0 + 1.9.10.0 true diff --git a/BusinessProcess.cs b/BusinessProcess.cs index 3188de8..0e6557b 100644 --- a/BusinessProcess.cs +++ b/BusinessProcess.cs @@ -1149,30 +1149,38 @@ private void _ProcessElement(string sourceID,IElement elem) } } } + bool gatewayComplete = false; lock (_state) { - _state.Path.StartGateway(gw, sourceID); - } - if (_onGatewayStarted != null) - _onGatewayStarted(gw, new ReadOnlyProcessVariablesContainer(elem.id, _state,this)); - string[] outgoings = null; - try - { - outgoings = gw.EvaulateOutgoingPaths(def, _isFlowValid, new ProcessVariablesContainer(elem.id, _state,this)); - } - catch (Exception e) - { - WriteLogException(new StackFrame(1, true), DateTime.Now, e); - if (_onGatewayError != null) - _onGatewayError(gw, new ReadOnlyProcessVariablesContainer(elem.id, _state,this)); - outgoings = null; + if (gw.IsIncomingFlowComplete(sourceID, _state.Path)) + { + gatewayComplete = true; + _state.Path.StartGateway(gw, sourceID); + } } - lock (_state) + if (gatewayComplete) { - if (outgoings == null) - _state.Path.FailGateway(gw); - else - _state.Path.SuccessGateway(gw, outgoings); + if (_onGatewayStarted != null) + _onGatewayStarted(gw, new ReadOnlyProcessVariablesContainer(elem.id, _state, this)); + string[] outgoings = null; + try + { + outgoings = gw.EvaulateOutgoingPaths(def, _isFlowValid, new ProcessVariablesContainer(elem.id, _state, this)); + } + catch (Exception e) + { + WriteLogException(new StackFrame(1, true), DateTime.Now, e); + if (_onGatewayError != null) + _onGatewayError(gw, new ReadOnlyProcessVariablesContainer(elem.id, _state, this)); + outgoings = null; + } + lock (_state) + { + if (outgoings == null) + _state.Path.FailGateway(gw); + else + _state.Path.SuccessGateway(gw, outgoings); + } } } else if (elem is AEvent) diff --git a/Utility.cs b/Utility.cs index af15494..d9b0280 100644 --- a/Utility.cs +++ b/Utility.cs @@ -34,6 +34,7 @@ static Utility() _backgroundMREEvent = new ManualResetEvent(true); _suspendedEvents = new List(); _backgroundSuspendThread = new Thread(new ThreadStart(_BackgroundSuspendStart)); + _backgroundSuspendThread.Name = "Background Suspend Thread"; _backgroundSuspendThread.IsBackground = true; _backgroundSuspendThread.Start(); _xmlConstructors = new Dictionary();