Exemple #1
0
 public void AddExclusiveGateway(string id, Boolean converging)
 {
     if (!IsIdInUse(id))
     {
         ExclusiveGateway exclusiveGateway = new ExclusiveGateway
         {
             id = id,
             gatewayDirection = (converging ? "Converging" : "Diverging")
         };
         trail.process.exclusiveGateways.Add(exclusiveGateway);
         BPMNShape bPMNShape = new BPMNShape
         {
             id          = id + "_shape",
             bpmnElement = id
         };
         bPMNShape.bounds.X      = placeX + "";
         bPMNShape.bounds.Y      = placeY + "";
         bPMNShape.bounds.Width  = GHW + "";
         bPMNShape.bounds.Height = GHW + "";
         trail.diagram.bpmnPlane.bpmnShapes.Add(bPMNShape);
         UpdatePlacement();
     }
     else
     {
         throw new Exception("Id in use.");
     }
 }
Exemple #2
0
 public void RemoveEventWithSequences(string eventId)
 {
     if (StartEventExists(eventId))
     {
         StartEvent se = GetStartEvent(eventId);
         RemoveEventOutGoing(se.outgoing);
         trail.process.startEvents.RemoveAll(y => y.id.Equals(se.id));
         trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(se.id + "_shape"));
     }
     if (EndEventExists(eventId))
     {
         EndEvent ee = GetEndEvent(eventId);
         RemoveEventInGoing(ee.incoming);
         trail.process.endEvents.RemoveAll(y => y.id.Equals(ee.id));
         trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(ee.id + "_shape"));
     }
     if (TaskExists(eventId))
     {
         Task task = GetTask(eventId);
         RemoveEventOutGoing(task.outgoing);
         RemoveEventInGoing(task.incoming);
         trail.process.tasks.RemoveAll(y => y.id.Equals(task.id));
         trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(task.id + "_shape"));
     }
     if (ParallelGatewayExists(eventId))
     {
         ParallelGateway pg = GetParallelGateWay(eventId);
         RemoveEventOutGoing(pg.outgoing);
         RemoveEventInGoing(pg.incoming);
         trail.process.parallelGateways.RemoveAll(y => y.id.Equals(pg.id));
         trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(pg.id + "_shape"));
     }
     if (ExclusiveGatewayExists(eventId))
     {
         ExclusiveGateway eg = GetExclusiveGateWay(eventId);
         RemoveEventOutGoing(eg.outgoing);
         RemoveEventInGoing(eg.incoming);
         trail.process.exclusiveGateways.RemoveAll(y => y.id.Equals(eg.id));
         trail.diagram.bpmnPlane.bpmnShapes.RemoveAll(y => y.id.Equals(eg.id + "_shape"));
     }
 }
Exemple #3
0
        public void AddSequenceFlow(string id, string sourceId, string targetId)
        {
            if (!trail.process.sequenceFlows.Exists(seq => seq.sourceRef.Equals(sourceId) && seq.targetRef.Equals(targetId) && seq.id.Equals(id)))
            {
                SequenceFlow sequenceFlow = new SequenceFlow
                {
                    id        = id,
                    sourceRef = sourceId,
                    targetRef = targetId
                };
                trail.process.sequenceFlows.Add(sequenceFlow);
                string sourceType = "";
                string targetType = "";
                int    x_target = 0, x_source = 0, y_target = 0, y_source = 0;
                Bounds b;
                if (StartEventExists(sourceId))
                {
                    StartEvent se = GetStartEvent(sourceId);
                    se.outgoing.Add(id);
                    sourceType = "se";
                    b          = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(se.id + "_shape")).bounds;
                    x_source   = int.Parse(b.X);
                    y_source   = int.Parse(b.Y);
                }
                else if (StartEventExists(targetId))
                {
                    Console.Write("Cannot target start events");
                }
                if (EndEventExists(targetId))
                {
                    EndEvent ee = GetEndEvent(targetId);
                    ee.incoming.Add(id);
                    targetType = "se";
                    b          = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(ee.id + "_shape")).bounds;
                    x_target   = int.Parse(b.X);
                    y_target   = int.Parse(b.Y);
                }
                else if (EndEventExists(sourceId))
                {
                    Console.Write("Cannot use end events as source");
                }
                if (TaskExists(sourceId))
                {
                    Task task = GetTask(sourceId);
                    task.outgoing.Add(id);
                    sourceType = "task";
                    b          = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(task.id + "_shape")).bounds;
                    x_source   = int.Parse(b.X);
                    y_source   = int.Parse(b.Y);
                }
                else if (TaskExists(targetId))
                {
                    Task task = GetTask(targetId);
                    task.incoming.Add(id);
                    targetType = "task";
                    b          = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(task.id + "_shape")).bounds;
                    x_target   = int.Parse(b.X);
                    y_target   = int.Parse(b.Y);
                }
                if (ParallelGatewayExists(sourceId))
                {
                    ParallelGateway par = GetParallelGateWay(sourceId);
                    par.outgoing.Add(id);
                    sourceType = "gate";
                    b          = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(par.id + "_shape")).bounds;
                    x_source   = int.Parse(b.X);
                    y_source   = int.Parse(b.Y);
                }
                else if (ParallelGatewayExists(targetId))
                {
                    ParallelGateway par = GetParallelGateWay(targetId);
                    par.incoming.Add(id);
                    targetType = "gate";
                    b          = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(par.id + "_shape")).bounds;
                    x_target   = int.Parse(b.X);
                    y_target   = int.Parse(b.Y);
                }
                if (ExclusiveGatewayExists(sourceId))
                {
                    ExclusiveGateway exc = GetExclusiveGateWay(sourceId);
                    exc.outgoing.Add(id);
                    sourceType = "gate";
                    b          = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(exc.id + "_shape")).bounds;
                    x_source   = int.Parse(b.X);
                    y_source   = int.Parse(b.Y);
                }
                else if (ExclusiveGatewayExists(targetId))
                {
                    ExclusiveGateway exc = GetExclusiveGateWay(targetId);
                    exc.incoming.Add(id);
                    targetType = "gate";
                    b          = trail.diagram.bpmnPlane.bpmnShapes.Find(x => x.id.Equals(exc.id + "_shape")).bounds;
                    x_target   = int.Parse(b.X);
                    y_target   = int.Parse(b.Y);
                }
                BPMNEdge bPMNEdge = new BPMNEdge
                {
                    id          = id + "_edge",
                    bpmnElement = id
                };
                Waypoint first = new Waypoint {
                    X = "0", Y = "0"
                };
                Waypoint second = new Waypoint {
                    X = "0", Y = "0"
                };
                switch (sourceType)
                {
                case "se":
                    first.Y = SEHW / 2 + y_source + "";
                    first.X = x_source + "";
                    break;

                case "task":
                    first.Y = TH / 2 + y_source + "";
                    first.X = x_source + "";
                    break;

                case "gate":
                    first.Y = GHW / 2 + y_source + "";
                    first.X = x_source + "";
                    break;

                default:
                    break;
                }
                switch (targetType)
                {
                case "se":
                    second.Y = SEHW / 2 + y_target + "";
                    second.X = SEHW + x_target + "";
                    break;

                case "task":
                    second.Y = TH / 2 + y_target + "";
                    second.X = TW + x_target + "";
                    break;

                case "gate":
                    second.Y = GHW / 2 + y_target + "";
                    second.X = GHW + x_target + "";
                    break;

                default:
                    break;
                }
                bPMNEdge.waypoint.Add(first);
                bPMNEdge.waypoint.Add(second);
                trail.diagram.bpmnPlane.bpmnEdges.Add(bPMNEdge);
            }
        }
Exemple #4
0
        public void MoveMergeGate(string mergeGateId, string elementIdToMoveTo, string elementIdToMoveFrom)
        {
            ExclusiveGateway eg            = GetExclusiveGateWay(mergeGateId);
            dynamic          moveToElement = null;

            if (TaskExists(elementIdToMoveTo))
            {
                moveToElement = GetTask(elementIdToMoveTo);
            }
            else if (ExclusiveGatewayExists(elementIdToMoveTo))
            {
                moveToElement = GetExclusiveGateWay(elementIdToMoveTo);
            }
            dynamic moveFromElement = null;

            if (TaskExists(elementIdToMoveFrom))
            {
                moveFromElement = GetTask(elementIdToMoveFrom);
            }
            else if (ExclusiveGatewayExists(elementIdToMoveFrom))
            {
                moveFromElement = GetExclusiveGateWay(elementIdToMoveFrom);
            }

            if (moveToElement != null && moveFromElement != null)
            {
                string idFromMoveToElement = GetSequenceFlow(moveToElement.outgoing[0]).id;
                string idToMergeGate       = GetSequenceFlow(eg.incoming[0]).id;
                string idToMoveFromElement = GetSequenceFlow(moveFromElement.incoming[0]).id;

                string idOfEventBeforeMergeGate = GetSequenceFlow(idToMergeGate).sourceRef;
                string idAfterMoveToEvent       = GetSequenceFlow(idFromMoveToElement).targetRef;

                List <string> ls1 = new List <string>
                {
                    idFromMoveToElement,
                    idToMergeGate,
                    idToMoveFromElement
                };
                List <string> ls2 = new List <string>
                {
                    idFromMoveToElement + "_edge",
                    idToMergeGate + "_edge",
                    idToMoveFromElement + "_edge"
                };

                trail.process.sequenceFlows.RemoveAll(x => ls1.Contains(x.id));
                trail.diagram.bpmnPlane.bpmnEdges.RemoveAll(x => ls2.Contains(x.id));

                trail.process.tasks.ForEach(x =>
                {
                    x.incoming.RemoveAll(y => ls1.Contains(y));
                    x.outgoing.RemoveAll(y => ls1.Contains(y));
                });
                trail.process.exclusiveGateways.ForEach(x =>
                {
                    x.incoming.RemoveAll(y => ls1.Contains(y));
                    x.outgoing.RemoveAll(y => ls1.Contains(y));
                });
                trail.process.parallelGateways.ForEach(x =>
                {
                    x.incoming.RemoveAll(y => ls1.Contains(y));
                    x.outgoing.RemoveAll(y => ls1.Contains(y));
                });

                AddSequenceFlow(idFromMoveToElement + "neu", moveToElement.id, eg.id);
                AddSequenceFlow(idToMergeGate + "neu", eg.id, idAfterMoveToEvent);
                AddSequenceFlow(idToMoveFromElement + "neu", idOfEventBeforeMergeGate, moveFromElement.id);
            }
        }