Exemple #1
0
 public bool CanForwardToOther(string userId, int roleId, string perReviewId)
 {
     PerformanceReviewDao perDao = new PerformanceReviewDao();
     PerformanceReview pr = perDao.GetById(perReviewId);
     if (pr.AssignRole == roleId && pr.AssignID.Equals(userId))
         return true;
     return false;
 }
Exemple #2
0
        /// <summary>
        /// Check moving request
        /// </summary>
        /// <param name="userID">int</param>
        /// <param name="request">FlowType</param>
        /// <param name="id">int</param>
        /// <param name="action">ActionType</param>
        /// <param name="role">int</param>
        /// <returns>bool</returns>
        public static bool CheckMovingRequest(int userID, Constants.FlowType request, string id, Constants.ActionType action, int role, bool isPortal = false)
        {
            bool allow = false;
            try
            {
                string srole = role.ToString();
                switch (request)
                {

                    case Constants.FlowType.FLOW_JOB_REQUEST:
                        JobRequestDao jobDao = new JobRequestDao();
                        JobRequest job = jobDao.GetById(int.Parse(id));
                        switch (action)
                        {

                            case Constants.ActionType.List:
                                if (job.InvolveRole.Contains(srole))
                                    allow = true;
                                break;
                            case Constants.ActionType.Update:
                                if (job.AssignRole.Equals(role) && job.AssignID.Equals(userID))
                                    allow = true;
                                break;
                        }

                        break;
                    case Constants.FlowType.FLOW_JOB_REQUEST_ITEM:
                        JobRequestItemDao jobItemDao = new JobRequestItemDao();
                        JobRequestItem jobItem = jobItemDao.GetByID(id);
                        switch (action)
                        {

                            case Constants.ActionType.Update:
                                if (jobItem.JobRequest.AssignRole.Equals(role) && jobItem.JobRequest.AssignID.Equals(userID))
                                    allow = true;
                                break;
                        }

                        break;
                    case Constants.FlowType.FLOW_PURCHASE_REQUEST:
                        PurchaseRequestDao purDao = new PurchaseRequestDao();
                        PurchaseRequest pur = purDao.GetByID(int.Parse(id));
                        switch (action)
                        {

                            case Constants.ActionType.List:
                                if (pur.InvolveRole.Contains(srole))
                                    allow = true;
                                break;
                            case Constants.ActionType.Update:
                                string loginName = new UserAdminDao().GetById(userID).UserName;
                                if (pur.WFStatusID == Constants.STATUS_OPEN)
                                {
                                    if (purDao.HasEditPermision(pur.ID, loginName, role))
                                        allow = true;
                                    else if (role != Constants.PR_REQUESTOR_ID && purDao.IsAssigned(pur, userID, role))
                                        allow = true;
                                }
                                break;
                        }

                        break;
                    case Constants.FlowType.FLOW_PURCHASE_REQUEST_US:
                        PurchaseRequestDao purUSDao = new PurchaseRequestDao();
                        PurchaseRequest purUS = purUSDao.GetByID(int.Parse(id));
                        switch (action)
                        {

                            case Constants.ActionType.List:
                                if (purUS.InvolveRole.Contains(srole))
                                    allow = true;
                                break;
                            case Constants.ActionType.Update:
                                string loginName = new UserAdminDao().GetById(userID).UserName;
                                if (purUS.WFStatusID == Constants.STATUS_OPEN)
                                {
                                    if (purUSDao.HasEditPermisionUS(purUS.ID, loginName, role))
                                        allow = true;
                                    else if (role != Constants.PR_REQUESTOR_ID_US && purUSDao.IsAssigned(purUS, userID, role))
                                        allow = true;
                                }
                                break;
                        }

                        break;
                    case Constants.FlowType.FLOW_PERFORMANCE_REVIEW:
                        PerformanceReviewDao perDao = new PerformanceReviewDao();
                        PerformanceReview per = perDao.GetById(id);
                        CommonDao comm = new CommonDao();
                        int userAdminId = GetUserAdminIdFromEmpId(userID);
                        List<int> roles = comm.GetRoleListInt(userAdminId, Constants.WORK_FLOW_PERFORMANCE_REVIEW);
                        switch (action)
                        {

                            case Constants.ActionType.List:
                                if (isPortal)
                                {
                                    if (roles.Contains(role))
                                        allow = true;
                                }
                                else if (per.InvolveRole.Contains(srole))
                                    allow = true;

                                break;
                            case Constants.ActionType.Update:
                                if (isPortal)
                                {
                                    if (roles.Contains(role) && per.AssignID.Equals(userID.ToString()) && per.AssignRole.Equals(role))
                                        allow = true;
                                }
                                else if (roles.Contains(per.AssignRole) && per.AssignID.Equals(userID.ToString()))
                                    allow = true;

                                break;
                        }

                        break;
                }
            }
            catch
            { }
            return allow;
        }