Пример #1
0
        public bool UpdateRolePermission(string type, string id, string isActive)
        {
            bool result = false;

            if (type == "system")
            {
                IQueryable <AUTH_ROLE_SYSTEM> queryRoleSystem = RoleSystemRepository.GetQueryable();
                //Guid sid = new Guid(id);
                //string sid = id;
                var system = queryRoleSystem.FirstOrDefault(i => i.ROLE_SYSTEM_ID == id);
                system.IS_ACTIVE = isActive.ToString();
                RoleSystemRepository.SaveChanges();
                result = true;
            }
            else if (type == "module")
            {
                IQueryable <AUTH_ROLE_MODULE> queryRoleModule = RoleModuleRepository.GetQueryable();
                //Guid mid = new Guid(id);
                var module = queryRoleModule.FirstOrDefault(i => i.ROLE_MODULE_ID == id);
                module.IS_ACTIVE = isActive.ToString();
                RoleModuleRepository.SaveChanges();
                result = true;
            }
            else if (type == "function")
            {
                IQueryable <AUTH_ROLE_FUNCTION> queryRoleFunction = RoleFunctionRepository.GetQueryable();
                //Guid fid = new Guid(id);
                var system = queryRoleFunction.FirstOrDefault(i => i.ROLE_FUNCTION_ID == id);
                system.IS_ACTIVE = isActive.ToString();
                RoleSystemRepository.SaveChanges();
                result = true;
            }
            return(result);
        }
Пример #2
0
        public bool UpdateRolePermission(string type, string id, bool isActive)
        {
            bool result = false;

            if (type == "system")
            {
                IQueryable <THOK.Authority.DbModel.RoleSystem> queryRoleSystem = RoleSystemRepository.GetQueryable();
                Guid sid    = new Guid(id);
                var  system = queryRoleSystem.FirstOrDefault(i => i.RoleSystemID == sid);
                system.IsActive = isActive;
                RoleSystemRepository.SaveChanges();
                result = true;
            }
            else if (type == "module")
            {
                IQueryable <THOK.Authority.DbModel.RoleModule> queryRoleModule = RoleModuleRepository.GetQueryable();
                Guid mid    = new Guid(id);
                var  module = queryRoleModule.FirstOrDefault(i => i.RoleModuleID == mid);
                module.IsActive = isActive;
                RoleModuleRepository.SaveChanges();
                result = true;
            }
            else if (type == "function")
            {
                IQueryable <THOK.Authority.DbModel.RoleFunction> queryRoleFunction = RoleFunctionRepository.GetQueryable();
                Guid fid    = new Guid(id);
                var  system = queryRoleFunction.FirstOrDefault(i => i.RoleFunctionID == fid);
                system.IsActive = isActive;
                RoleSystemRepository.SaveChanges();
                result = true;
            }
            return(result);
        }
Пример #3
0
        private void SetFunTree(Tree childTree, Module item, RoleModule roleModules)
        {
            var function = FunctionRepository.GetQueryable().Where(f => f.Module.ModuleID == item.ModuleID);
            IQueryable <THOK.Authority.DbModel.RoleFunction> queryRoleFunction = RoleFunctionRepository.GetQueryable();
            HashSet <Tree> functionTreeSet = new HashSet <Tree>();

            foreach (var func in function)
            {
                Tree funcTree     = new Tree();
                var  roleFunction = queryRoleFunction.FirstOrDefault(rf => rf.Function.FunctionID == func.FunctionID && rf.RoleModule.RoleModuleID == roleModules.RoleModuleID);
                funcTree.id         = roleFunction.RoleFunctionID.ToString();
                funcTree.text       = "功能:" + func.FunctionName;
                funcTree.@checked   = roleFunction == null ? false : roleFunction.IsActive;
                funcTree.attributes = "function";
                functionTreeSet.Add(funcTree);
            }
            childTree.children = functionTreeSet.ToArray();
        }
Пример #4
0
 private void InitRoleFunctions(RoleModule roleModule)
 {
     foreach (var function in roleModule.Module.Functions)
     {
         var roleFunctions = roleModule.RoleFunctions.Where(rf => rf.Function.FunctionID == function.FunctionID);
         if (roleFunctions.Count() == 0)
         {
             RoleFunction rf = new RoleFunction()
             {
                 RoleFunctionID = Guid.NewGuid(),
                 RoleModule     = roleModule,
                 Function       = function,
                 IsActive       = false
             };
             roleModule.RoleSystem.IsActive = false;
             SetParentRoleModuleIsActiveFalse(roleModule);
             roleModule.IsActive = false;
             RoleFunctionRepository.Add(rf);
             RoleFunctionRepository.SaveChanges();
         }
     }
 }
Пример #5
0
        private void SetFunTree(Tree childTree, AUTH_MODULE item, AUTH_ROLE_MODULE roleModules)
        {
            var function = FunctionRepository.GetQueryable().Where(f => f.AUTH_MODULE.MODULE_ID == item.MODULE_ID);
            IQueryable <AUTH_ROLE_FUNCTION> queryRoleFunction = RoleFunctionRepository.GetQueryable();
            HashSet <Tree> functionTreeSet = new HashSet <Tree>();

            foreach (var func in function)
            {
                Tree funcTree     = new Tree();
                var  roleFunction = queryRoleFunction.FirstOrDefault(rf => rf.AUTH_FUNCTION.FUNCTION_ID == func.FUNCTION_ID && rf.AUTH_ROLE_MODULE.ROLE_MODULE_ID == roleModules.ROLE_MODULE_ID);
                if (roleFunction != null)
                {
                    funcTree.id   = roleFunction.ROLE_FUNCTION_ID.ToString();
                    funcTree.text = "功能:" + func.FUNCTION_NAME;
                    int a = Convert.ToInt32(roleFunction.IS_ACTIVE);
                    funcTree.@checked   = roleFunction == null ? false : Convert.ToBoolean(a);
                    funcTree.attributes = "function";
                    functionTreeSet.Add(funcTree);
                }
            }
            childTree.children = functionTreeSet.ToArray();
        }
Пример #6
0
 private void InitRoleFunctions(AUTH_ROLE_MODULE roleModule)
 {
     foreach (var function in roleModule.AUTH_MODULE.AUTH_FUNCTION)
     {
         var roleFunctions = roleModule.AUTH_ROLE_FUNCTION.Where(rf => rf.AUTH_FUNCTION.FUNCTION_ID == function.FUNCTION_ID);
         if (roleFunctions.Count() == 0)
         {
             AUTH_ROLE_FUNCTION rf = new AUTH_ROLE_FUNCTION()
             {
                 //ROLE_FUNCTION_ID = Guid.NewGuid().ToString(),
                 ROLE_FUNCTION_ID = RoleFunctionRepository.GetNewID("AUTH_ROLE_FUNCTION", "ROLE_FUNCTION_ID"),
                 AUTH_ROLE_MODULE = roleModule,
                 AUTH_FUNCTION    = function,
                 // IS_ACTIVE = false.ToString()
                 IS_ACTIVE = "0"
             };
             roleModule.AUTH_ROLE_SYSTEM.IS_ACTIVE = "0";
             SetParentRoleModuleIsActiveFalse(roleModule);
             roleModule.IS_ACTIVE = "0";
             RoleFunctionRepository.Add(rf);
             RoleFunctionRepository.SaveChanges();
         }
     }
 }
 public RoleFunctionRepositoryTests()
 {
     _target = new RoleFunctionRepository(_dataAccess);
 }