Пример #1
0
        public bool HasPermission(int caseId, List <int> workerRoleIDs, int workerID, int programID, int regionID, int subProgramID, string areaName, string controllerName, string actionName, bool useCache = false)
        {
            if (CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1 || (CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) != -1 && CurrentLoggedInWorkerRegionIDs.IndexOf(regionID) != -1))
            {
                return(true);
            }
            bool isAssigned = false;
            int  count      = context.CaseWorker.Where(item => item.CaseID == caseId && item.WorkerID == workerID).Count();

            if (count > 0)
            {
                isAssigned = true;
            }
            if (isAssigned)
            {
                return(HasPermission(workerRoleIDs, workerID, programID, regionID, subProgramID, areaName, controllerName, actionName, useCache));
            }
            return(false);
        }
        public bool HasPermission(List <int> workerRoleIDs, int workerID, int programID, int regionID, int subProgramID, int?JamatkhanaID, string areaName, string controllerName, string actionName, bool useCache = false)
        {
            //if (workerRoleIDs.Contains("1") || (workerRoleIDs.Contains(SiteConfigurationReader.RegionalManagerRoleID.ToString()) && CurrentLoggedInWorkerRegionIDs.Contains(regionID.ToString())))
            if (CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1 || (CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) != -1 && CurrentLoggedInWorkerRegionIDs.IndexOf(regionID) != -1))
            {
                return(true);
            }

            workerRoleIDs = null;

            //List<WorkerInRole> workerRoleList = context.WorkerInRole.Join(context.WorkerSubProgram, left => left.ID, right => right.WorkerInRoleID, (left, right) => new { left, right }).Where(item => item.left.WorkerID == workerID && item.left.ProgramID == programID && item.left.RegionID == regionID && item.right.SubProgramID == subProgramID).Select(item => item.left).ToList();
            workerRoleIDs = GetWorkerInRoleNew(workerID, programID, regionID, subProgramID, JamatkhanaID);
            //List<WorkerInRoleNew> workerRoleList = GetWorkerInRoleNew(workerID,programID,regionID,subProgramID);
            //if (workerRoleList != null)
            //{
            //    foreach (WorkerInRoleNew workerRole in workerRoleList)
            //    {
            //        if (!workerRoleIDs.Contains(workerRole.WorkerRoleID.ToString()))
            //        {
            //            workerRoleIDs = workerRoleIDs.Concate(',', workerRole.WorkerRoleID.ToString());
            //        }
            //    }
            //}
            return(HasPermission(workerRoleIDs, areaName, controllerName, actionName, useCache));
        }
Пример #3
0
        public bool HasPermission(List <int> workerRoleIDs, int workerID, int programID, int regionID, int subProgramID, string areaName, string controllerName, string actionName, bool useCache = false)
        {
            if (CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1 || (CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) != -1 && CurrentLoggedInWorkerRegionIDs.IndexOf(regionID) != -1))
            {
                return(true);
            }
            workerRoleIDs = null;
            List <WorkerInRole> workerRoleList = context.WorkerInRole.Join(context.WorkerSubProgram, left => left.ID, right => right.WorkerInRoleID, (left, right) => new { left, right }).Where(item => item.left.WorkerID == workerID && item.left.ProgramID == programID && item.left.RegionID == regionID && item.right.SubProgramID == subProgramID).Select(item => item.left).ToList();

            if (workerRoleList != null)
            {
                foreach (WorkerInRole workerRole in workerRoleList)
                {
                    if (workerRoleIDs.IndexOf(workerRole.WorkerRoleID) == -1)
                    {
                        workerRoleIDs.Add(workerRole.WorkerRoleID);
                    }
                }
            }
            return(HasPermission(workerRoleIDs, areaName, controllerName, actionName, useCache));
        }
        public bool HasPermission(int caseId, List <int> workerRoleIDs, int workerID, int programID, int regionID, int subProgramID, int?JamatkhanaID, string areaName, string controllerName, string actionName, bool useCache = false)
        {
            //if (workerRoleIDs.Contains("1") || (workerRoleIDs.Contains(SiteConfigurationReader.RegionalManagerRoleID.ToString()) && CurrentLoggedInWorkerRegionIDs.Contains(regionID.ToString())))
            if (CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1 || (CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) != -1 && CurrentLoggedInWorkerRegionIDs.IndexOf(regionID) != -1))
            {
                return(true);
            }

            bool isAssigned = false;

            if (HasAllCasesPermissionAction(workerRoleIDs, workerID, programID, regionID, subProgramID, JamatkhanaID, areaName, controllerName, actionName) > 0)
            {
                //return HasPermission(workerRoleIDs, workerID, programID, regionID, subProgramID, JamatkhanaID, areaName, controllerName, actionName, useCache);
                return(true);
            }
            else
            {
                int count = context.CaseWorker.Where(item => item.CaseID == caseId && item.WorkerID == workerID).Count();
                if (count > 0)
                {
                    isAssigned = true;
                }
                if (isAssigned)
                {
                    return(HasPermission(workerRoleIDs, workerID, programID, regionID, subProgramID, JamatkhanaID, areaName, controllerName, actionName, useCache));
                }
            }
            //int count = context.CaseWorker.Where(item => item.CaseID == caseId && item.WorkerID == workerID).Count();
            //if (count > 0)
            //{
            //    isAssigned = true;
            //}
            //if (isAssigned)
            //{
            //    return HasPermission(workerRoleIDs, workerID, programID, regionID, subProgramID, areaName, controllerName, actionName, useCache);
            //}

            return(false);
        }