public void FindVisiblity(int workerID,
                                  ref VisibilityStatus regionVisiblity,
                                  ref VisibilityStatus programVisiblity,
                                  ref VisibilityStatus subProgramVisiblity,
                                  ref VisibilityStatus caseVisiblity)
        {
            //List<WorkerRolePermissionNew> permissionList = context.WorkerInRoleNew.Join(context.WorkerRolePermissionNew, left => left.WorkerRoleID, right => right.WorkerRoleID, (left, right) => new { left, right }).
            //    Where(item => item.left.WorkerID == workerID).Select(item => item.right).ToList();

            //int count = permissionList.Where(item => item.Permission == 1 || item.Permission == 2 || item.Permission == 3 || item.Permission == 4 || item.Permission == 5 || item.Permission == 6 || item.Permission == 7 || item.Permission == 8).Count();
            //if (count > 0 && (regionVisiblity == VisibilityStatus.None || regionVisiblity == VisibilityStatus.UnDefined))
            //{
            //regionVisiblity = VisibilityStatus.Assigned;
            //}

            //count = permissionList.Where(item => item.Permission == 1 || item.Permission == 2 || item.Permission == 5 || item.Permission == 6 || item.Permission == 3 || item.Permission == 4 || item.Permission == 7 || item.Permission == 8).Count();
            //if (count > 0 && (programVisiblity == VisibilityStatus.None || programVisiblity == VisibilityStatus.UnDefined))
            //{
            //programVisiblity = VisibilityStatus.Assigned;
            //subProgramVisiblity = VisibilityStatus.Assigned;
            //}

            ////Case Visibility
            //count = permissionList.Where(item => item.Permission == 1 || item.Permission == 3 || item.Permission == 5 || item.Permission == 7).Count();
            //if (count > 0)
            //{
            //    caseVisiblity = VisibilityStatus.All;
            //}
            //count = permissionList.Where(item => item.Permission == 2 || item.Permission == 4 || item.Permission == 6 || item.Permission == 8).Count();
            //if (count > 0 && (caseVisiblity == VisibilityStatus.None || caseVisiblity == VisibilityStatus.UnDefined))
            //{
            //caseVisiblity = VisibilityStatus.Assigned;

            if (CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1)
            {
                regionVisiblity     = VisibilityStatus.All;
                programVisiblity    = VisibilityStatus.All;
                subProgramVisiblity = VisibilityStatus.All;
                caseVisiblity       = VisibilityStatus.All;
            }
            else
            {
                regionVisiblity     = VisibilityStatus.Assigned;
                programVisiblity    = VisibilityStatus.Assigned;
                subProgramVisiblity = VisibilityStatus.Assigned;
                caseVisiblity       = VisibilityStatus.Assigned;
            }
            //}
        }
        public void FindVisiblity(int workerID,
                                  ref VisibilityStatus regionVisiblity,
                                  ref VisibilityStatus programVisiblity,
                                  ref VisibilityStatus subProgramVisiblity,
                                  ref VisibilityStatus caseVisiblity)
        {
            List <WorkerRolePermission> permissionList = context.WorkerInRole.Join(context.WorkerRolePermission, left => left.WorkerRoleID, right => right.WorkerRoleID, (left, right) => new { left, right }).
                                                         Where(item => item.left.WorkerID == workerID).Select(item => item.right).ToList();
            //Region Visibility
            //int count = permissionList.Where(item => item.Permission == 1 || item.Permission == 2 || item.Permission == 3 || item.Permission == 4).Count();
            //if (count > 0)
            //{
            //    regionVisiblity = VisibilityStatus.All;
            //}
            int count = permissionList.Where(item => item.Permission == 1 || item.Permission == 2 || item.Permission == 3 || item.Permission == 4 || item.Permission == 5 || item.Permission == 6 || item.Permission == 7 || item.Permission == 8).Count();

            if (count > 0 && (regionVisiblity == VisibilityStatus.None || regionVisiblity == VisibilityStatus.UnDefined))
            {
                regionVisiblity = VisibilityStatus.Assigned;
            }

            //Program and SubProgram Visibility
            //count = permissionList.Where(item => item.Permission == 1 || item.Permission == 2 || item.Permission == 5 || item.Permission == 6).Count();
            //if (count > 0)
            //{
            //    programVisiblity = VisibilityStatus.All;
            //    subProgramVisiblity = VisibilityStatus.All;
            //}
            count = permissionList.Where(item => item.Permission == 1 || item.Permission == 2 || item.Permission == 5 || item.Permission == 6 || item.Permission == 3 || item.Permission == 4 || item.Permission == 7 || item.Permission == 8).Count();
            if (count > 0 && (programVisiblity == VisibilityStatus.None || programVisiblity == VisibilityStatus.UnDefined))
            {
                programVisiblity    = VisibilityStatus.Assigned;
                subProgramVisiblity = VisibilityStatus.Assigned;
            }

            //Case Visibility
            count = permissionList.Where(item => item.Permission == 1 || item.Permission == 3 || item.Permission == 5 || item.Permission == 7).Count();
            if (count > 0)
            {
                caseVisiblity = VisibilityStatus.All;
            }
            count = permissionList.Where(item => item.Permission == 2 || item.Permission == 4 || item.Permission == 6 || item.Permission == 8).Count();
            if (count > 0 && (caseVisiblity == VisibilityStatus.None || caseVisiblity == VisibilityStatus.UnDefined))
            {
                caseVisiblity = VisibilityStatus.Assigned;
            }
        }
示例#3
0
    void UpdateVisiblilityStatus()
    {
        visibility = GetVisibilityStatus();
        if (ItemJustBecomeVisible())
        {
            PerformVisitStartedActions();
        }

        if (ItemJustBecomeInvisible())
        {
            PerformVisitCompleteActions();
        }

        if (IsSure(visibility))
        {
            lastSureStatus = visibility;
        }
    }
示例#4
0
 public static bool IsVisible(this VisibilityStatus visibility)
 {
     return(visibility == VisibilityStatus.VISIBLE);
 }
示例#5
0
 static bool IsSure(VisibilityStatus status)
 {
     return(status == VisibilityStatus.HiddenForSure || status == VisibilityStatus.VisibleForSure);
 }
        public Worker AuthenticateWorker(string userName, string password, bool rememberMe, bool isExternalLogin = false)
        {
            try
            {
                if (userName.IsNullOrEmpty())
                {
                    throw new CustomException(CustomExceptionType.CommonArgumentNullException, "Enter user name");
                }
                if (password.IsNullOrEmpty())
                {
                    throw new CustomException(CustomExceptionType.CommonArgumentNullException, "Enter password");
                }
                string errorMessage = string.Empty;
                if (workerRepository != null)
                {
                    string originalPassword = password;
                    password = CryptographyHelper.Encrypt(password);
                    Worker loggedInWorker = workerRepository.Find(userName, password);
                    if (loggedInWorker != null)
                    {
                        if (loggedInWorker.IsActive)
                        {
                            if (loggedInWorker.AllowLogin)
                            {
                                loggedInWorker.ConfirmPassword = loggedInWorker.Password;
                                loggedInWorker.LastLoginDate   = DateTime.Now;
                                workerRepository.InsertOrUpdate(loggedInWorker);
                                workerRepository.Save();
                                if (!isExternalLogin)
                                {
                                    WebHelper.CurrentSession.Content.LoggedInWorker = loggedInWorker;
                                    List <int> roleIDs   = null;
                                    List <int> regionIDs = null;

                                    roleIDs   = workerinrolenewRepository.FindAllActiveWorkerInRoleByWorkerID();
                                    regionIDs = workerinrolenewRepository.FindAllActiveRegionByWorkerID();
                                    //List<WorkerInRole> workerRoles = workerinroleRepository.FindAllActiveByWorkerID(loggedInWorker.ID);

                                    //if (workerRoles != null)
                                    //{
                                    //    foreach (WorkerInRole workerRole in workerRoles)
                                    //    {
                                    //        if (!roleIDs.Contains(workerRole.WorkerRoleID.ToString()))
                                    //        {
                                    //            roleIDs = roleIDs.Concate(',', workerRole.WorkerRoleID.ToString());
                                    //        }
                                    //        if (!regionIDs.Contains(workerRole.RegionID.ToString()))
                                    //        {
                                    //            regionIDs = regionIDs.Concate(',', workerRole.RegionID.ToString());
                                    //        }
                                    //    }
                                    //}

                                    if (roleIDs == null)
                                    {
                                        throw new CustomException(CustomExceptionType.CommonArgumentNullException, "There is no role assigned to the user");
                                    }
                                    WebHelper.CurrentSession.Content.LoggedInWorkerRoleIDs   = roleIDs;
                                    WebHelper.CurrentSession.Content.LoggedInWorkerRegionIDs = regionIDs;
                                    VisibilityStatus regionVisiblity     = VisibilityStatus.UnDefined;
                                    VisibilityStatus programVisiblity    = VisibilityStatus.UnDefined;
                                    VisibilityStatus subProgramVisiblity = VisibilityStatus.UnDefined;
                                    VisibilityStatus caseVisiblity       = VisibilityStatus.UnDefined;
                                    //workerRolePermissionRepository.FindVisiblity(loggedInWorker.ID, ref regionVisiblity, ref programVisiblity, ref subProgramVisiblity, ref caseVisiblity);
                                    workerRolePermissionNewRepository.FindVisiblity(loggedInWorker.ID, ref regionVisiblity, ref programVisiblity, ref subProgramVisiblity, ref caseVisiblity);
                                    WebHelper.CurrentSession.Content.RegionVisibility     = regionVisiblity;
                                    WebHelper.CurrentSession.Content.ProgramVisibility    = programVisiblity;
                                    WebHelper.CurrentSession.Content.SubProgramVisibility = subProgramVisiblity;
                                    WebHelper.CurrentSession.Content.CaseVisibility       = caseVisiblity;

                                    CookieHelper newCookieHelper = new CookieHelper();
                                    newCookieHelper.SetLoginCookie(userName, loggedInWorker.ID.ToString(), rememberMe);
                                    if (rememberMe)
                                    {
                                        newCookieHelper.RememberMe(userName, originalPassword);
                                    }
                                    else
                                    {
                                        newCookieHelper.ForgetMe();
                                    }
                                }
                                //loggedInWorker = setUserPermission(loggedInWorker);
                                return(loggedInWorker);
                            }
                            else
                            {
                                throw new CustomException(CustomExceptionType.CommonArgumentNullException, "User access has been blocked by administrator");
                            }
                        }
                        else
                        {
                            throw new CustomException(CustomExceptionType.CommonArgumentNullException, "User has not been activated yet");
                        }
                    }
                    else
                    {
                        throw new CustomException(CustomExceptionType.CommonArgumentNullException, "Invalid user name/password");
                    }
                }
                return(null);
            }
            catch (CustomException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new CustomException(CustomExceptionType.UserLoginUnknownError, Constants.Messages.UserLogin_UnknownError, ex);
            }
        }
	void init_status(VisibilityStatus initial = VisibilityStatus.FollowParent){
		if (obs_status == null)
			obs_status = new ReactiveProperty<VisibilityStatus>(initial);
	}
示例#8
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            object objCurrentControllerName = string.Empty;

            this.RouteData.Values.TryGetValue("controller", out objCurrentControllerName);
            object objCurrentActionName = string.Empty;

            this.RouteData.Values.TryGetValue("action", out objCurrentActionName);
            object currentAreaName = string.Empty;

            this.RouteData.Values.TryGetValue("Areas", out currentAreaName);
            if (this.RouteData.DataTokens.ContainsKey("area"))
            {
                currentAreaName = this.RouteData.DataTokens["area"].ToString();
            }
            string currentActionName     = objCurrentActionName.ToString(true);
            string currentControllerName = objCurrentControllerName.ToString(true);

            ViewBag.HasAccessToOtherConfigurationData = false;
            ViewBag.CurrentActionName     = currentActionName;
            ViewBag.CurrentControllerName = currentControllerName;
            ViewBag.CurrentAreaName       = currentAreaName;

            ViewBag.HasAccessToWorkerModule         = false;
            ViewBag.HasAccessToReportModule         = false;
            ViewBag.HasAccessToAdminModule          = false;
            ViewBag.HasAccessToCaseManagementModule = true;
            ViewBag.IsRegionalAdministrator         = false;

            if (CurrentLoggedInWorker != null)
            {
                ViewBag.CurrentWorkerID = CurrentLoggedInWorker.ID;
                //ViewBag.CurrentWorkerRoleID = CurrentLoggedInWorker.UserRoleID;
                ViewBag.CurrentWorkerName = CurrentLoggedInWorker.FirstName + " " + CurrentLoggedInWorker.LastName;
            }
            currentActionName = currentActionName.ToLower();
            if (!currentActionName.Contains("ajax"))
            {
                //<JL:Comment:06/13/2017>
                //if (WebHelper.CurrentSession.Content.RegionVisibility == VisibilityStatus.UnDefined && workerRolePermissionRepository != null)
                if (WebHelper.CurrentSession.Content.RegionVisibility == VisibilityStatus.UnDefined && workerRolePermissionNewRepository != null)
                {
                    VisibilityStatus regionVisiblity     = VisibilityStatus.UnDefined;
                    VisibilityStatus programVisiblity    = VisibilityStatus.UnDefined;
                    VisibilityStatus subProgramVisiblity = VisibilityStatus.UnDefined;
                    VisibilityStatus caseVisiblity       = VisibilityStatus.UnDefined;
                    workerRolePermissionNewRepository.FindVisiblity(CurrentLoggedInWorker.ID, ref regionVisiblity, ref programVisiblity, ref subProgramVisiblity, ref caseVisiblity);
                    WebHelper.CurrentSession.Content.RegionVisibility     = regionVisiblity;
                    WebHelper.CurrentSession.Content.ProgramVisibility    = programVisiblity;
                    WebHelper.CurrentSession.Content.SubProgramVisibility = subProgramVisiblity;
                    WebHelper.CurrentSession.Content.CaseVisibility       = caseVisiblity;
                }
            }

            ViewBag.CurrentLoggedInWorkerRoleIDs = CurrentLoggedInWorkerRoleIDs;

            if (CurrentLoggedInWorkerRoleIDs != null && CurrentLoggedInWorkerRoleIDs.IndexOf(1) != -1)
            {
                ViewBag.HasAccessToWorkerModule = true;
                ViewBag.HasAccessToReportModule = true;
                ViewBag.HasAccessToAdminModule  = true;
            }

            //<JL:Add:06/11/2017>
            if (workerroleactionpermissionnewRepository != null)
            {
                bool HasWorkerMenuPermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.WorkerManagement, Constants.Controllers.Worker, string.Empty, true);
                if (HasWorkerMenuPermission)
                {
                    ViewBag.HasAccessToWorkerModule = true;
                }
                bool HasReportMenuPermission = workerroleactionpermissionnewRepository.HasPermission(CurrentLoggedInWorkerRoleIDs, Constants.Areas.Reporting, Constants.Controllers.Report, string.Empty, true);
                if (HasReportMenuPermission)
                {
                    ViewBag.HasAccessToReportModule = true;
                }
            }
            //</JL:Add:06/11/2017>

            if (CurrentLoggedInWorkerRoleIDs != null && CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) != -1)
            {
                ViewBag.HasAccessToWorkerModule           = true;
                ViewBag.HasAccessToReportModule           = true;
                ViewBag.HasAccessToAdminModule            = false;
                ViewBag.HasAccessToCaseManagementModule   = false;
                ViewBag.IsRegionalAdministrator           = true;
                ViewBag.HasAccessToOtherConfigurationData = true;
            }

            base.OnActionExecuting(filterContext);
        }