예제 #1
0
        public static CasePlanInstanceResult ToDto(CasePlanInstanceAggregate casePlanInstance)
        {
            var children = casePlanInstance.GetFlatListCasePlanItems().Select(_ => CasePlanItemInstanceResult.ToDto(_)).ToList();

            foreach (var elt in casePlanInstance.Children.Where(_ => _.Type == CasePlanElementInstanceTypes.STAGE))
            {
                foreach (var childEltId in elt.Children.Select(_ => _.EltId))
                {
                    foreach (var child in children.Where(_ => _.EltId == childEltId))
                    {
                        child.ParentEltId = elt.EltId;
                    }
                }
            }

            return(new CasePlanInstanceResult
            {
                Id = casePlanInstance.AggregateId,
                CaseFileId = casePlanInstance.CaseFileId,
                CasePlanId = casePlanInstance.CasePlanId,
                Name = casePlanInstance.Name,
                State = casePlanInstance.State == null ? string.Empty : Enum.GetName(typeof(CaseStates), casePlanInstance.State),
                Roles = casePlanInstance.Roles.Select(_ => CasePlanInstanceRoleResult.ToDto(_)).ToList(),
                CreateDateTime = casePlanInstance.CreateDateTime,
                UpdateDateTime = casePlanInstance.UpdateDateTime,
                Children = children,
                Files = casePlanInstance.Files.Select(_ => CasePlanInstanceFileItemResult.ToDTO(_)).ToList(),
                WorkerTasks = casePlanInstance.WorkerTasks.Select(_ => WorkerTaskResult.ToDTO(_)).ToList(),
                ExecutionContext = casePlanInstance.ExecutionContext == null ? new Dictionary <string, string>() : casePlanInstance.ExecutionContext.Variables.ToDictionary(k => k.Key, k => k.Value)
            });
        }
 public static CasePlanInstanceResult ToDto(CasePlanInstanceAggregate casePlanInstance)
 {
     return(new CasePlanInstanceResult
     {
         Id = casePlanInstance.AggregateId,
         CasePlanId = casePlanInstance.CasePlanId,
         Name = casePlanInstance.Name,
         State = casePlanInstance.State == null ? string.Empty : Enum.GetName(typeof(CaseStates), casePlanInstance.State),
         Roles = casePlanInstance.Roles.Select(_ => CasePlanInstanceRoleResult.ToDto(_)).ToList(),
         CreateDateTime = casePlanInstance.CreateDateTime,
         UpdateDateTime = casePlanInstance.UpdateDateTime,
         Children = casePlanInstance.GetFlatListCasePlanItems().Select(_ => CasePlanItemInstanceResult.ToDto(_)).ToList(),
         Files = casePlanInstance.Files.Select(_ => CasePlanInstanceFileItemResult.ToDTO(_)).ToList(),
         ExecutionContext = casePlanInstance.ExecutionContext == null ? new Dictionary <string, string>() : casePlanInstance.ExecutionContext.Variables.ToDictionary(k => k.Key, k => k.Value)
     });
 }