Exemplo n.º 1
0
        private bool CheckUserRoleForDocumentType(int idRole, DocumentTypeKey documentType, OperationAction action)
        {
            var deploymentMode = ConfigurationManager.AppSettings["DeploymentMode"];

            var role = _userRoleRepository.GetById(idRole);

            if (deploymentMode == "franchisee" &&
                !string.IsNullOrEmpty(role.AppRoleName) && role.AppRoleName.Equals("GlobalAdmin", StringComparison.InvariantCultureIgnoreCase) &&
                _listUserRoleFunction.Any(p => p.DocumentTypeId == (int)documentType && p.DocumentType.Type.Equals(deploymentMode, StringComparison.CurrentCultureIgnoreCase)))
            {
                return(true);
            }


            if (_listDocumentType.Count == 0 || _listUserRoleFunction.Count == 0)
            {
                _listUserRoleFunction = _userRoleFunctionRepository.ListAll();
                _listDocumentType     = _userRoleRepository.GetAllDocumentType();
            }
            return((from urf in _listUserRoleFunction
                    join document in _listDocumentType.Where(p => p.Type.Equals(deploymentMode, StringComparison.CurrentCultureIgnoreCase)) on urf.DocumentTypeId equals document.Id into temp
                    from docType in temp
                    where docType.Id == (int)documentType && urf.UserRoleId == idRole && urf.SecurityOperationId == (int)action
                    select urf).Any());
        }
Exemplo n.º 2
0
        public bool VerifyAccess(DocumentTypeKey documentType, OperationAction action,
                                 out List <UserRoleFunction> permissionOfThisView)
        {
            var principal     = _oxProjectContext.User as IQuickspatchPrincipal;
            var hasPermission = false;

            permissionOfThisView = null;

            if (principal != null && principal.User != null)
            {
                var userRoleId = principal.User.UserRoleId.GetValueOrDefault();

                var userGroupRights = MenuExtractData.Instance.LoadUserSecurityRoleFunction(userRoleId,
                                                                                            (int)documentType);
                if (userGroupRights == null || userGroupRights.Count == 0)
                {
                    userGroupRights = _userRoleFunctionRepostory.LoadUserSecurityRoleFunction(userRoleId, (int)documentType);
                }

                if (userGroupRights != null)
                {
                    hasPermission        = userGroupRights.Any(r => r.SecurityOperationId == (int)action);
                    permissionOfThisView = userGroupRights.ToList();
                }
            }

            return(hasPermission);
        }
Exemplo n.º 3
0
        private bool CheckModuleFranchisee(int idRole, DocumentTypeKey documentType)
        {
            var deploymentMode = ConfigurationManager.AppSettings["DeploymentMode"];
            var role           = _userRoleRepository.GetById(idRole);

            if (deploymentMode == "camino" ||
                (deploymentMode == "franchisee" && !string.IsNullOrEmpty(role.AppRoleName) &&
                 role.AppRoleName.Equals("GlobalAdmin", StringComparison.InvariantCultureIgnoreCase)))
            {
                return(true);
            }

            var listDocumentTypeAvailable = ModuleForFranchisee.ListModuleDocumentTypeOperations.Select(p => p.DocumentTypeId).Distinct();

            return(listDocumentTypeAvailable.Any(p => p.Equals((int)documentType)));
        }