Exemplo n.º 1
0
        public TransitionActionDTO ToTransitionAction(DR_Requester requester, TransitionAction dbTransitionAction, bool withDetails)
        {
            BizAction      bizAction      = new BizAction();
            BizFormula     bizFormula     = new BizFormula();
            BizEntityGroup bizEntityGroup = new BizEntityGroup();
            BizTransition  bizTransition  = new BizTransition();
            var            result         = new TransitionActionDTO();

            result.ID = dbTransitionAction.ID;
            if (dbTransitionAction.ActionTypeID != null)
            {
                result.ActionType = (ActionType)dbTransitionAction.ActionTypeID;
            }
            else
            {
                result.ActionType = ActionType.Approve;
            }
            result.MultipleUserEnabled = dbTransitionAction.MultipleUserEnabled;

            result.Name = dbTransitionAction.Name;
            if (withDetails)
            {
                //   result.Action = bizAction.ToActionDTO(dbTransitionAction.Action);
                result.Transition = bizTransition.ToSimpleTransitionDTO(dbTransitionAction.Transition);

                BizTarget   bizTarget   = new BizTarget();
                BizRoleType bizRoleType = new BizRoleType();
                foreach (var target in dbTransitionAction.TransitionActionTarget)
                {
                    TransitionActionTargetDTO at = new TransitionActionTargetDTO();
                    at.ID = target.ID;
                    //     at.CanSendOtherOrganizations = target.CanSendOtherOrganizations==true;
                    at.TargetType = (TargetType)target.TargetType;
                    if (target.RoleTypeID != null)
                    {
                        at.RoleTypeID = target.RoleTypeID.Value;
                        at.RoleType   = bizRoleType.ToRoleTypeDTO(target.RoleType);
                    }
                    result.Targets.Add(at);
                }

                foreach (var sbsf in dbTransitionAction.TransitionAction_Formula)
                {
                    var sf = new TransitionActionFormulaDTO();
                    sf.FormulaID = sbsf.FormulaID;
                    sf.Message   = sbsf.Message;
                    sf.TrueFalse = sbsf.TrueFalse;
                    result.Formulas.Add(sf);
                }
                foreach (var entityGroup in dbTransitionAction.TransitionAction_EntityGroup)
                {
                    result.EntityGroups.Add(bizEntityGroup.ToEntityGroupDTO(requester, entityGroup.EntityGroup, withDetails));
                }
            }
            return(result);
        }
        public ProcessDTO ToProcessDTO(DR_Requester requester, Process item, bool withDetails)
        {
            ProcessDTO result = new ProcessDTO();
            result.ID = item.ID;
            result.Name = item.Name;
            result.EntityID = item.TableDrivedEntityID ?? 0;
            result.TransitionFlowSTR = item.TransitionFlowSTR;
            if (withDetails)
            {
                BizRoleType bizRoleType = new BizRoleType();
                //result.AdminRoleGroup = bizRole.ToRoleGroupDTO(item.RoleGroup);

                BizAction bizAction = new BizAction();
                //foreach (var citem in item.Action)
                //{
                //    result.Actions.Add(bizAction.ToActionDTO(citem));
                //}
                BizActivity bizActivity = new BizActivity();
                foreach (var citem in item.Activity)
                {
                    result.Activities.Add(bizActivity.ToActivityDTO(citem, false));
                }
                BizEntityGroup bizEntityGroup = new BizEntityGroup();
                foreach (var citem in item.EntityGroup)
                {
                    result.EntityGroups.Add(bizEntityGroup.ToEntityGroupDTO(requester, citem, withDetails));
                }
                BizState bizState = new BizState();
                foreach (var citem in item.State)
                {
                    result.States.Add(bizState.ToStateDTO(citem, false));
                }

                //foreach (var citem in item.ProcessAdminRoleTypes)
                //{
                //    result.AdminRoleTypes.Add(bizRoleType.ToRoleTypeDTO(citem.RoleType));
                //}
                //foreach (var citem in item.RequestInitializers)
                //{
                //    result.ProcessInitializerRoleGroups.Add(bizRole.ToRoleGroupDTO(citem.RoleGroup));
                //}

            }
            return result;
        }