Exemplo n.º 1
0
            public static CasePlanItemInstanceResult ToDto(CaseEltInstance casePlanItemInstance)
            {
                string stateStr = null, formId = null;

                if (casePlanItemInstance.IsTaskOrStage())
                {
                    stateStr = casePlanItemInstance.TakeStageState == null ? null : Enum.GetName(typeof(TaskStageStates), casePlanItemInstance.TakeStageState);
                }

                if (casePlanItemInstance.IsMilestone())
                {
                    stateStr = casePlanItemInstance.MilestoneState == null ? null : Enum.GetName(typeof(MilestoneEventStates), casePlanItemInstance.MilestoneState);
                }

                if (casePlanItemInstance.Type == CasePlanElementInstanceTypes.HUMANTASK)
                {
                    formId = casePlanItemInstance.GetFormId();
                }

                return(new CasePlanItemInstanceResult
                {
                    Id = casePlanItemInstance.Id,
                    Name = casePlanItemInstance.Name,
                    NbOccurrence = casePlanItemInstance.NbOccurrence,
                    EltId = casePlanItemInstance.EltId,
                    State = stateStr,
                    FormId = formId,
                    Type = Enum.GetName(typeof(CasePlanElementInstanceTypes), casePlanItemInstance.Type).ToUpperInvariant(),
                    TransitionHistories = casePlanItemInstance.TransitionHistories.Select(_ => TransitionHistoryResult.ToDto(_)).ToList()
                });
            }
            public static CasePlanItemInstanceResult ToDto(BaseCasePlanItemInstance casePlanItemInstance)
            {
                string stateStr = null, formId = null;

                if (casePlanItemInstance is BaseTaskOrStageElementInstance)
                {
                    var state = ((BaseTaskOrStageElementInstance)casePlanItemInstance).State;
                    stateStr = state == null ? null : Enum.GetName(typeof(TaskStageStates), state);
                }

                if (casePlanItemInstance is BaseMilestoneOrTimerElementInstance)
                {
                    var state = ((BaseMilestoneOrTimerElementInstance)casePlanItemInstance).State;
                    stateStr = state == null ? null : Enum.GetName(typeof(MilestoneEventStates), state);
                }

                if (casePlanItemInstance is HumanTaskElementInstance)
                {
                    var humanTaskInstance = casePlanItemInstance as HumanTaskElementInstance;
                    formId = humanTaskInstance.FormId;
                }

                return(new CasePlanItemInstanceResult
                {
                    Id = casePlanItemInstance.Id,
                    Name = casePlanItemInstance.Name,
                    NbOccurrence = casePlanItemInstance.NbOccurrence,
                    EltId = casePlanItemInstance.EltId,
                    State = stateStr,
                    FormId = formId,
                    Type = Enum.GetName(typeof(CasePlanElementInstanceTypes), casePlanItemInstance.Type).ToUpperInvariant(),
                    TransitionHistories = casePlanItemInstance.TransitionHistories.Select(_ => TransitionHistoryResult.ToDto(_)).ToList()
                });
            }