Exemple #1
0
        public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId)
        {
            if (DBAction == DBActionEnum.Save)
            {
                //Validate the object
                Validate(db, ref validationErrors);

                //Check if there were any validation errors
                if (validationErrors.Count == 0)
                {
                    if (IsNewRecord())
                    {
                        //Add
                        ID = new ENTWFItemOwnerData().Insert(db, ENTWFItemId, ENTWFOwnerGroupId, ENTUserAccountId, userAccountId);
                    }
                    else
                    {
                        //Update
                        if (!new ENTWFItemOwnerData().Update(db, ID, ENTWFItemId, ENTWFOwnerGroupId, ENTUserAccountId, userAccountId, Version))
                        {
                            UpdateFailed(ref validationErrors);
                            return(false);
                        }
                    }
                    return(true);
                }
                //Didn't pass validation.
                return(false);
            }
            throw new Exception("DBAction not Save.");
        }
Exemple #2
0
        public override bool Load(int id)
        {
            //Get the entity object from the DAL.
            var eNTWFItemOwner = new ENTWFItemOwnerData().Select(id);

            MapEntityToProperties(eNTWFItemOwner);
            return(true);
        }
Exemple #3
0
        public void InitWorkflow(string className)
        {
            //Get the workflow object by class name
            if (Workflow.LoadByObjectName(className))
            {
                //Get all unique owners for this workflow
                WFOwnerGroups.Load(Workflow.ID);

                //Add an owner group to the work flow owners
                foreach (ENTWFOwnerGroupEO entWFOwnerGroup in WFOwnerGroups)
                {
                    Nullable <int> entUserAccountId = null;

                    if (entWFOwnerGroup.IsDefaultSameAsLast)
                    {
                        //Get this user's last request and set it as the default.
                        var lastUser = new ENTWFItemOwnerData().SelectLastUserByGroupId(entWFOwnerGroup.ID, WFItem.SubmitterENTUserAccountId);
                        if ((lastUser != null) && (lastUser.ENTUserAccountId != null))
                        {
                            entUserAccountId = lastUser.ENTUserAccountId;
                        }
                    }
                    else
                    {
                        //set the owner to the default one selected for this group.
                        entUserAccountId = entWFOwnerGroup.DefaultENTUserAccountId;
                    }

                    string userName = "";
                    if (entUserAccountId != null)
                    {
                        //get the user's name
                        var userAccount = new ENTUserAccountEO();
                        userAccount.Load((int)entUserAccountId);
                        userName = userAccount.DisplayText;
                    }

                    //Add this item owner with the default user.
                    WFOwners.Add(new ENTWFItemOwnerEO {
                        ENTUserAccountId = entUserAccountId, ENTWFOwnerGroupId = entWFOwnerGroup.ID, UserName = userName
                    });
                }

                //Load the transitions based on the current state.
                WFTransitions.Load(WFItem.CurrentWFStateId);
            }
            else
            {
                throw new Exception("Workflow not set correctly.  Please associate this item with a workflow.");
            }
        }