Beispiel #1
0
 private void RunStates(dynamic bpmnEvent, Processor graph)
 {
     if (bpmnEvent.GetType().Equals(typeof(StartEvent)))
     {
         ((StartEvent)bpmnEvent).outgoing.ForEach(x => RunStates(trail.GetSequenceFlow(x), graph));
     }
     else if (bpmnEvent.GetType().Equals(typeof(EndEvent)))
     {
         results.Add(true);
     }
     else if (bpmnEvent.GetType().Equals(typeof(Task)))
     {
         Task task = (Task)bpmnEvent;
         try
         {
             graph.Execute(labelId[task.name]);
             task.outgoing.ForEach(x => RunStates(trail.GetSequenceFlow(x), graph));
         }
         catch (Exception)
         {
             results.Add(false);
         }
     }
     else if (bpmnEvent.GetType().Equals(typeof(ParallelGateway)))
     {
         ((ParallelGateway)bpmnEvent).outgoing.ForEach(x => RunStates(trail.GetSequenceFlow(x), graph));
     }
     else if (bpmnEvent.GetType().Equals(typeof(ExclusiveGateway)))
     {
         ((ExclusiveGateway)bpmnEvent).outgoing.ForEach(x => RunStates(trail.GetSequenceFlow(x), graph));
     }
 }
Beispiel #2
0
        // Skal gennemgå hele trace fra ende til anden ikke gennemgå grafen
        private void FindEvent(string bpmnSeqId, List <string> trace)
        {
            string targetId = trail.GetSequenceFlow(bpmnSeqId).targetRef;

            if (trail.EndEventExists(targetId) && traceStatus[trace] == trace.Count)
            {
                bpmnElements.Add(targetId);
                return;
            }
            else if (trail.ExclusiveGatewayExists(targetId))
            {
                bpmnElements.Add(targetId);
                trail.GetExclusiveGateWay(targetId).outgoing.ForEach(x => FindEvent(x, trace));
            }
            else if (trail.ParallelGatewayExists(targetId))
            {
                bpmnElements.Add(targetId);
                trail.GetParallelGateWay(targetId).outgoing.ForEach(x => FindEvent(x, trace));
            }
            else if (trail.TaskExists(targetId))
            {
                if (trace.Count > traceStatus[trace])
                {
                    Task   task = trail.GetTask(targetId);
                    string curr = string.Empty;
                    for (int i = 0; i <= traceStatus[trace]; i++)
                    {
                        curr += trace[i];
                    }
                    if (labelId[task.name].Equals(trace[traceStatus[trace]]))
                    {
                        bpmnElements.Add(task.id);
                        traceStatus[trace]++;
                        foreach (string id in task.outgoing)
                        {
                            FindEvent(id, trace);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private BPMNTrail FixMergeGateLocationsInRepeatedSequences(List <string> repSeq, Tuple <int, List <int> > startLocs, List <string> trace, BPMNTrail workingTrail)
        {
            string        idString  = string.Empty;
            List <string> repSeqIds = new List <string>();
            List <string> ids       = new List <string>();

            for (int i = 0; i < repSeq.Count + startLocs.Item1; i++)
            {
                idString += trace[i];
                if (i >= startLocs.Item1)
                {
                    repSeqIds.Add(idString);
                }
            }
            if (!(repSeqIds[0] + repSeqIds[0]).Equals(repSeqIds[1]))
            {
                foreach (int pos in startLocs.Item2)
                {
                    idString = string.Empty;
                    for (int i = 0; i < pos + repSeq.Count; i++)
                    {
                        idString += trace[i];
                        if (i >= pos)
                        {
                            ids.Add(idString);
                        }
                    }
                }

                Task             current     = workingTrail.GetTask(repSeqIds.Last <string>());
                Task             helperTask1 = null;
                Task             helperTask2 = null;
                ExclusiveGateway eg          = null;
                SequenceFlow     seqFlow     = null;
                int    index  = 0;
                string nextId = ids[0];
                string helper = string.Empty;
                while (!current.id.Equals(ids.Last <string>()))
                {
                    helper = workingTrail.GetSequenceFlow(current.outgoing[0]).targetRef;
                    if (helper.Equals(nextId))
                    {
                        if (!nextId.Equals(ids.Last <string>()))
                        {
                            nextId = ids[index += 1];
                        }
                        current = workingTrail.GetTask(helper);
                    }
                    else if (workingTrail.ExclusiveGatewayExists(helper))
                    {
                        eg = workingTrail.GetExclusiveGateWay(helper);
                        foreach (string s in eg.outgoing)
                        {
                            helper = workingTrail.GetSequenceFlow(s).targetRef;
                            if (helper.Equals(nextId))
                            {
                                seqFlow     = workingTrail.GetSequenceFlow(s);
                                helperTask1 = workingTrail.GetTask(helper);
                                helperTask2 = workingTrail.GetTaskByNameIfIdInList(helperTask1.name, repSeqIds);
                                if (!repSeqIds.Contains(current.id))
                                {
                                    workingTrail.MoveMergeGate(eg.id, workingTrail.GetSequenceFlowByTargetRefId(helperTask2.id).sourceRef, helperTask1.id);
                                }
                                if (!nextId.Equals(ids.Last <string>()))
                                {
                                    nextId = ids[index += 1];
                                }
                                current = helperTask1;
                                break;
                            }
                        }
                    }
                }
            }

            return(workingTrail);
        }