Beispiel #1
0
        public static BizFlow BuildBizFlow(this BizFlowInfo bfi)
        {
            if (bfi == null || bfi.BizFlow == null)
            {
                return(null);
            }
            BizFlow flow = bfi.BizFlow;

            flow.States       = bfi.FlowStates.Where(o => o.FlowId == flow.FlowId).OrderBy(o => o.Code).ToArray();
            flow.Operations   = bfi.FlowOperations.Where(o => o.FlowId == flow.FlowId).OrderBy(o => o.Code).ToArray();
            flow.Incomes      = bfi.FlowIncomes.Where(o => o.FlowId == flow.FlowId).OrderBy(o => o.Code).ToArray();
            flow.Outcomes     = bfi.FlowOutcomes.Where(o => o.FlowId == flow.FlowId).OrderBy(o => o.Code).ToArray();
            flow.NextBizFlows = bfi.NextBizFlows.ToArray();

            flow.States.ForEach(it =>
            {
                it.Operations = bfi.StateOperations.Where(op => op.StateId == it.StateId).ToArray();
                it.Incomes    = bfi.StateIncomes.Where(op => op.StateId == it.StateId).ToArray();
                it.Outcomes   = bfi.StateOutcomes.Where(op => op.StateId == it.StateId).ToArray();

                it.Operations.ForEach(o =>
                {
                    o.Operation = flow.Operations.FirstOrDefault(op => op.OperationId == o.OperationId);
                });

                it.Incomes.ForEach(o =>
                {
                    o.Income = flow.Incomes.FirstOrDefault(d => d.IncomeId == o.IncomeId);
                });

                it.Outcomes.ForEach(o =>
                {
                    o.Outcome = flow.Outcomes.FirstOrDefault(d => d.OutcomeId == o.OutcomeId);
                });
            });

            return(flow);
        }
 private BizFlowInfo GetBizFlow(BizFlow flow)
 {
     if (flow != null)
     {
         BizFlowInfo bfi = new BizFlowInfo();
         bfi.BizFlow = flow;
         bfi.FlowStates = repoFlowState.Query(o => o.FlowId == flow.FlowId).ToArray();
         bfi.FlowOperations = repoFlowOp.Query(o => o.FlowId == flow.FlowId).ToArray();
         bfi.FlowIncomes = repoFlowIncome.Query(o => o.FlowId == flow.FlowId).ToArray();
         bfi.FlowOutcomes = repoFlowOutcome.Query(o => o.FlowId == flow.FlowId).ToArray();
         bfi.StateOperations = repoStateOp.Query(o => o.State.FlowId == flow.FlowId).ToArray();
         bfi.StateIncomes = repoStateIncome.Query(o => o.State.FlowId == flow.FlowId).ToArray();
         bfi.StateOutcomes = repoStateOutcome.Query(o => o.State.FlowId == flow.FlowId).ToArray();
         bfi.NextBizFlows = repoNextFlow.Query(o => o.FlowId == flow.FlowId).ToArray();
         bfi.NextBizFlows.ForEach(n =>
         {
             n.FromBizFlow = bfi.BizFlow;
             n.ToBizFlow = repoBizFlow.Query(o => o.FlowId == n.NextFlowId).FirstOrDefault();
         });
         return bfi;
     }
     return null;
 }