Ejemplo 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();
            }
    }
Ejemplo n.º 2
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);
                }
        }