Exemplo n.º 1
0
            internal void Clone(WorkflowPoolEntity pool, Dictionary <IWorkflowNodeEntity, IWorkflowNodeEntity> nodes)
            {
                var oldLane = this.lane.Entity;
                WorkflowLaneEntity newLane = new WorkflowLaneEntity
                {
                    Pool          = pool,
                    Name          = oldLane.Name,
                    BpmnElementId = oldLane.BpmnElementId,
                    Actors        = oldLane.Actors.ToMList(),
                    ActorsEval    = oldLane.ActorsEval.Clone(),
                    Xml           = oldLane.Xml,
                }.Save();

                var newActivities = this.activities.Values.Select(a => a.Entity).ToDictionary(a => a, a => new WorkflowActivityEntity
                {
                    Lane              = newLane,
                    Name              = a.Name,
                    BpmnElementId     = a.BpmnElementId,
                    Xml               = a.Xml,
                    Type              = a.Type,
                    ViewName          = a.ViewName,
                    RequiresOpen      = a.RequiresOpen,
                    Reject            = a.Reject,
                    Timeout           = a.Timeout,
                    EstimatedDuration = a.EstimatedDuration,
                    Jumps             = a.Jumps.Select(j => j.Clone()).ToMList(),
                    Script            = a.Script?.Clone(),
                    SubWorkflow       = a.SubWorkflow?.Clone(),
                    UserHelp          = a.UserHelp,
                    Comments          = a.Comments,
                });

                newActivities.Values.SaveList();
                nodes.AddRange(newActivities.ToDictionary(kvp => (IWorkflowNodeEntity)kvp.Key, kvp => (IWorkflowNodeEntity)kvp.Value));

                var newEvents = this.events.Values.Select(e => e.Entity).ToDictionary(e => e, e => new WorkflowEventEntity
                {
                    Lane          = newLane,
                    Name          = e.Name,
                    BpmnElementId = e.BpmnElementId,
                    Type          = e.Type,
                    Xml           = e.Xml,
                });

                newEvents.Values.SaveList();
                nodes.AddRange(newEvents.ToDictionary(kvp => (IWorkflowNodeEntity)kvp.Key, kvp => (IWorkflowNodeEntity)kvp.Value));

                var newGateways = this.gateways.Values.Select(g => g.Entity).ToDictionary(g => g, g => new WorkflowGatewayEntity
                {
                    Lane          = newLane,
                    Name          = g.Name,
                    BpmnElementId = g.BpmnElementId,
                    Type          = g.Type,
                    Direction     = g.Direction,
                    Xml           = g.Xml,
                });

                newGateways.Values.SaveList();
                nodes.AddRange(newGateways.ToDictionary(kvp => (IWorkflowNodeEntity)kvp.Key, kvp => (IWorkflowNodeEntity)kvp.Value));
            }
Exemplo n.º 2
0
        public void ApplyChanges(WorkflowModel model, WorkflowReplacementModel replacements)
        {
            var document = XDocument.Parse(model.DiagramXml);

            var participants    = document.Descendants(bpmn + "collaboration").Elements(bpmn + "participant").ToDictionaryEx(a => a.Attribute("id").Value);
            var processElements = document.Descendants(bpmn + "process").ToDictionaryEx(a => a.Attribute("id").Value);
            var diagramElements = document.Descendants(bpmndi + "BPMNPlane").Elements().ToDictionaryEx(a => a.Attribute("bpmnElement").Value, "bpmnElement");

            if (participants.Count != processElements.Count)
            {
                throw new InvalidOperationException(WorkflowValidationMessage.ParticipantsAndProcessesAreNotSynchronized.NiceToString());
            }

            Locator locator  = new Workflow.Locator(this, diagramElements, model, replacements);
            var     oldPools = this.pools.Values.ToDictionaryEx(a => a.pool.bpmnElementId, "pools");

            Synchronizer.Synchronize(participants, oldPools,
                                     (id, pa) =>
            {
                var wp = new WorkflowPoolEntity {
                    Xml = new WorkflowXmlEmbedded(), Workflow = this.workflow
                }.ApplyXml(pa, locator);
                var pb = new PoolBuilder(wp, Enumerable.Empty <LaneBuilder>(), Enumerable.Empty <XmlEntity <WorkflowConnectionEntity> >());
                this.pools.Add(wp.ToLite(), pb);
                pb.ApplyChanges(processElements.GetOrThrow(pa.Attribute("processRef").Value), locator);
            },
                                     (id, pb) =>
            {
                this.pools.Remove(pb.pool.Entity.ToLite());
                pb.DeleteAll(locator);
            },
                                     (id, pa, pb) =>
            {
                var wp = pb.pool.Entity.ApplyXml(pa, locator);
                pb.ApplyChanges(processElements.GetOrThrow(pa.Attribute("processRef").Value), locator);
            });

            var messageFlows    = document.Descendants(bpmn + "collaboration").Elements(bpmn + "messageFlow").ToDictionaryEx(a => a.Attribute("id").Value);
            var oldMessageFlows = this.messageFlows.ToDictionaryEx(a => a.bpmnElementId, "messageFlows");

            Synchronizer.Synchronize(messageFlows, oldMessageFlows,
                                     (id, mf) =>
            {
                var wc = new WorkflowConnectionEntity {
                    Xml = new WorkflowXmlEmbedded()
                }.ApplyXml(mf, locator);
                this.messageFlows.Add(new XmlEntity <WorkflowConnectionEntity>(wc));
            },
                                     (id, omf) =>
            {
                this.messageFlows.Remove(omf);
                omf.Entity.Delete(WorkflowConnectionOperation.Delete);
            },
                                     (id, mf, omf) =>
            {
                omf.Entity.ApplyXml(mf, locator);
            });
        }
Exemplo n.º 3
0
            internal void Clone(WorkflowEntity wf, Dictionary <IWorkflowNodeEntity, IWorkflowNodeEntity> nodes)
            {
                var oldPool = this.pool.Entity;
                var newPool = new WorkflowPoolEntity
                {
                    Workflow      = wf,
                    Name          = oldPool.Name,
                    BpmnElementId = oldPool.BpmnElementId,
                    Xml           = oldPool.Xml,
                }.Save();

                foreach (var lb in this.lanes.Values)
                {
                    lb.Clone(newPool, nodes);
                }
            }
Exemplo n.º 4
0
 public static IQueryable <WorkflowConnectionEntity> WorkflowConnections(this WorkflowPoolEntity e)
 {
     return(PoolConnectionsExpression.Evaluate(e));
 }
Exemplo n.º 5
0
 public static IQueryable <WorkflowLaneEntity> WorkflowLanes(this WorkflowPoolEntity e)
 {
     return(PoolLanesExpression.Evaluate(e));
 }
Exemplo n.º 6
0
 public static IQueryable <WorkflowConnectionEntity> WorkflowConnections(this WorkflowPoolEntity e) =>
 As.Expression(() => Database.Query <WorkflowConnectionEntity>().Where(a => a.From.Lane.Pool.Is(e) && a.To.Lane.Pool.Is(e)));
Exemplo n.º 7
0
 public static IQueryable <WorkflowLaneEntity> WorkflowLanes(this WorkflowPoolEntity e) =>
 As.Expression(() => Database.Query <WorkflowLaneEntity>().Where(a => a.Pool.Is(e)));
Exemplo n.º 8
0
        private List <XmlEntity <WorkflowConnectionEntity> > sequenceFlows; //Contains all the connections internal to the pool INCLUDING the internals to each lane

        public PoolBuilder(WorkflowPoolEntity p, IEnumerable <LaneBuilder> laneBuilders, IEnumerable <XmlEntity <WorkflowConnectionEntity> > sequenceFlows)
        {
            this.pool          = new XmlEntity <WorkflowPoolEntity>(p);
            this.lanes         = laneBuilders.ToDictionary(a => a.lane.Entity.ToLite());
            this.sequenceFlows = sequenceFlows.ToList();
        }