public ActivityDTO ToActivityDTO(Activity item, bool withDetails)
        {
            ActivityDTO result = new ActivityDTO();

            result.ID           = item.ID;
            result.Name         = item.Name;
            result.ActivityType = (ActivityType)item.ActivityTypeID;
            result.ProcessID    = item.ProcessID;
            result.Description  = item.Description;

            if (withDetails)
            {
                BizTarget   bizTarget   = new BizTarget();
                BizRoleType bizRoleType = new BizRoleType();
                foreach (var target in item.ActivityTarget)
                {
                    ActivityTargetDTO at = new ActivityTargetDTO();
                    at.ID         = target.ID;
                    at.TargetType = (TargetType)target.TargetType;
                    foreach (var role in target.ActivityTarget_RoleType)
                    {
                        at.RoleTypes.Add(bizRoleType.ToRoleTypeDTO(role.RoleType));
                    }
                    result.Targets.Add(at);
                }
            }

            return(result);
        }
Beispiel #2
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);
        }