Esempio n. 1
0
    public WorkflowBuilder(WorkflowEntity wf)
    {
        using (HeavyProfiler.Log("WorkflowBuilder"))
            using (new EntityCache())
            {
                this.workflow = wf;

                List <WorkflowConnectionEntity> connections;
                List <WorkflowEventEntity>      events;
                List <WorkflowActivityEntity>   activities;
                List <WorkflowGatewayEntity>    gateways;
                List <WorkflowLaneEntity>       lanes;
                List <WorkflowPoolEntity>       poolEntities;

                if (wf.IsNew)
                {
                    connections  = new List <WorkflowConnectionEntity>();
                    events       = new List <WorkflowEventEntity>();
                    activities   = new List <WorkflowActivityEntity>();
                    gateways     = new List <WorkflowGatewayEntity>();
                    lanes        = new List <WorkflowLaneEntity>();
                    poolEntities = new List <WorkflowPoolEntity>();
                }
                else
                {
                    connections  = wf.WorkflowConnections().ToList();
                    events       = wf.WorkflowEvents().ToList();
                    activities   = wf.WorkflowActivities().ToList();
                    gateways     = wf.WorkflowGateways().ToList();
                    lanes        = wf.WorkflowPools().SelectMany(a => a.WorkflowLanes()).ToList();
                    poolEntities = wf.WorkflowPools().ToList();
                }

                var xmlConnections = connections.Select(a => new XmlEntity <WorkflowConnectionEntity>(a)).ToList();
                var nodes          = events.Cast <IWorkflowNodeEntity>().Concat(activities).Concat(gateways).ToList();

                this.pools = (from pool in poolEntities
                              let laneBuilders = (from lane in lanes
                                                  where lane.Pool.Is(pool)
                                                  select new LaneBuilder(lane,
                                                                         activities.Where(a => a.Lane.Is(lane)),
                                                                         events.Where(a => a.Lane.Is(lane)),
                                                                         gateways.Where(a => a.Lane.Is(lane)),
                                                                         xmlConnections.Where(c => c.Entity.From.Lane.Is(lane) || c.Entity.To.Lane.Is(lane))))

                                                 let sequenceFlows = xmlConnections.Where(c => c.Entity.From.Lane.Pool.Is(pool) && c.Entity.To.Lane.Pool.Is(pool))

                                                                     select new PoolBuilder(pool, laneBuilders, sequenceFlows))
                             .ToDictionary(a => a.pool.Entity.ToLite());

                this.messageFlows = xmlConnections.Where(c => !c.Entity.From.Lane.Pool.Is(c.Entity.To.Lane.Pool)).ToList();
            }
    }
Esempio n. 2
0
        public WorkflowBuilder(WorkflowEntity wf)
        {
            using (HeavyProfiler.Log("WorkflowBuilder"))
                using (new EntityCache())
                {
                    this.workflow = wf;

                    List <WorkflowConnectionEntity> connections;
                    List <WorkflowEventEntity>      events;
                    List <WorkflowActivityEntity>   activities;
                    List <WorkflowGatewayEntity>    gateways;

                    if (wf.IsNew)
                    {
                        connections = new List <WorkflowConnectionEntity>();
                        events      = new List <WorkflowEventEntity>();
                        activities  = new List <WorkflowActivityEntity>();
                        gateways    = new List <WorkflowGatewayEntity>();
                    }
                    else
                    {
                        connections = wf.WorkflowConnections().ToList();
                        events      = wf.WorkflowEvents().ToList();
                        activities  = wf.WorkflowActivities().ToList();
                        gateways    = wf.WorkflowGateways().ToList();
                    }

                    var xmlConnections = connections.Select(a => new XmlEntity <WorkflowConnectionEntity>(a)).ToList();
                    var nodes          = events.Cast <IWorkflowNodeEntity>().Concat(activities).Concat(gateways).ToList();

                    this.pools = (from n in nodes
                                  group n by n.Lane into grLane
                                  select new LaneBuilder(grLane.Key,
                                                         grLane.OfType <WorkflowActivityEntity>(),
                                                         grLane.OfType <WorkflowEventEntity>(),
                                                         grLane.OfType <WorkflowGatewayEntity>(),
                                                         xmlConnections.Where(c => c.Entity.From.Lane.Is(grLane.Key) || c.Entity.To.Lane.Is(grLane.Key))) into lb
                                  group lb by lb.lane.Entity.Pool into grPool
                                  select new PoolBuilder(grPool.Key, grPool, xmlConnections.Where(c => c.Entity.From.Lane.Pool.Is(grPool.Key) && c.Entity.To.Lane.Pool.Is(grPool.Key))))
                                 .ToDictionary(pb => pb.pool.Entity.ToLite());

                    this.messageFlows = xmlConnections.Where(c => !c.Entity.From.Lane.Pool.Is(c.Entity.To.Lane.Pool)).ToList();
                }
        }
Esempio n. 3
0
        public WorkflowImportExport(WorkflowEntity wf)
        {
            using (HeavyProfiler.Log("WorkflowBuilder"))
                using (new EntityCache())
                {
                    this.workflow = wf;

                    this.connections = wf.IsNew ? new Dictionary <string, WorkflowConnectionEntity>() : wf.WorkflowConnections().ToDictionaryEx(a => a.BpmnElementId);
                    this.events      = wf.IsNew ? new Dictionary <string, WorkflowEventEntity>() : wf.WorkflowEvents().ToDictionaryEx(a => a.BpmnElementId);
                    this.activities  = wf.IsNew ? new Dictionary <string, WorkflowActivityEntity>() : wf.WorkflowActivities().ToDictionaryEx(a => a.BpmnElementId);
                    this.gateways    = wf.IsNew ? new Dictionary <string, WorkflowGatewayEntity>() : wf.WorkflowGateways().ToDictionaryEx(a => a.BpmnElementId);
                    this.lanes       = wf.IsNew ? new Dictionary <string, WorkflowLaneEntity>() : wf.WorkflowPools().SelectMany(a => a.WorkflowLanes()).ToDictionaryEx(a => a.BpmnElementId);
                    this.pools       = wf.IsNew ? new Dictionary <string, WorkflowPoolEntity>() : wf.WorkflowPools().ToDictionaryEx(a => a.BpmnElementId);
                }
        }