private bool UpdateUserPermission(string type, string id, bool isActive) { bool result = false; if (type == "system") { IQueryable <THOK.Authority.DbModel.UserSystem> queryUserSystem = UserSystemRepository.GetQueryable(); Guid sid = new Guid(id); var system = queryUserSystem.FirstOrDefault(i => i.UserSystemID == sid); system.IsActive = isActive; RoleSystemRepository.SaveChanges(); result = true; } else if (type == "module") { IQueryable <THOK.Authority.DbModel.UserModule> queryUserModule = UserModuleRepository.GetQueryable(); Guid mid = new Guid(id); var module = queryUserModule.FirstOrDefault(i => i.UserModuleID == mid); module.IsActive = isActive; RoleModuleRepository.SaveChanges(); result = true; } else if (type == "function") { IQueryable <THOK.Authority.DbModel.UserFunction> queryUserFunction = UserFunctionRepository.GetQueryable(); Guid fid = new Guid(id); var system = queryUserFunction.FirstOrDefault(i => i.UserFunctionID == fid); system.IsActive = isActive; RoleSystemRepository.SaveChanges(); result = true; } return(result); }
public object GetDetails(string userName, string systemID, string cityID) { //Guid cityid = new Guid(cityID); //Guid systemid = new Guid(systemID); //var user = UserRepository.GetQueryable().FirstOrDefault(u => u.USER_NAME == userName); //var userSystemId = UserSystemRepository.GetQueryable().Where(us => us.USER_USER_ID == user.USER_ID // && us.AUTH_SYSTEM.SYSTEM_ID == systemID && us.CITY_CITY_ID == cityID).Select(us => us.USER_SYSTEM_ID); ////string userSystemId = userSystemIds.Single().Trim(); //var userSystems = UserSystemRepository.GetQueryable().Where(us => !userSystemId.Any(uid => uid == us.USER_SYSTEM_ID) // && us.USER_USER_ID == user.USER_ID && us.AUTH_CITY.CITY_ID == cityID); //var userSystem = userSystems.Where(u => userSystems.Any(us => us.AUTH_USER_MODULE.Any(um => um.AUTH_USER_FUNCTION.Any(uf => // uf.USER_MODULE_USER_MODULE_ID== um.USER_MODULE_ID && uf.IS_ACTIVE == "1") || um.IS_ACTIVE == "1") || us.IS_ACTIVE == "1")) // .Select(us => new {us.AUTH_SYSTEM.SYSTEM_ID, us.AUTH_SYSTEM.SYSTEM_NAME, us.AUTH_SYSTEM.DESCRIPTION, Status =us.AUTH_CITY.IS_ACTIVE=="0" ? "启用" : "禁用" }); //return userSystem.ToArray(); var user = UserRepository.GetQueryable().FirstOrDefault(u => u.USER_NAME == userName); var userSystem = UserSystemRepository.GetQueryable(); var system = SystemRepository.GetQueryable(); var qq = from a in system from b in userSystem where (a.SYSTEM_ID == b.SYSTEM_SYSTEM_ID) select new{ a.SYSTEM_NAME, a.DESCRIPTION, STATUS = a.STATUS == "1"?"启用":"未启用", b.CITY_CITY_ID, b.SYSTEM_SYSTEM_ID, b.USER_USER_ID, b.IS_ACTIVE }; var userUseSysem = qq.Where(p => p.CITY_CITY_ID == cityID && !p.SYSTEM_SYSTEM_ID.Contains(systemID) && p.IS_ACTIVE == "1" && p.USER_USER_ID == user.USER_ID); return(userUseSysem.Distinct().ToArray()); }
private bool UpdateUserPermission(string type, string id, string isActive) { bool result = false; if (type == "system") { IQueryable <AUTH_USER_SYSTEM> queryUserSystem = UserSystemRepository.GetQueryable(); //Guid sid = new Guid(id); var system = queryUserSystem.FirstOrDefault(i => i.USER_SYSTEM_ID == id); system.IS_ACTIVE = isActive; RoleSystemRepository.SaveChanges(); result = true; } else if (type == "module") { IQueryable <AUTH_USER_MODULE> queryUserModule = UserModuleRepository.GetQueryable(); // Guid mid = new Guid(id); var module = queryUserModule.FirstOrDefault(i => i.USER_MODULE_ID == id); module.IS_ACTIVE = isActive; RoleModuleRepository.SaveChanges(); result = true; } else if (type == "function") { IQueryable <AUTH_USER_FUNCTION> queryUserFunction = UserFunctionRepository.GetQueryable(); //Guid fid = new Guid(id); var system = queryUserFunction.FirstOrDefault(i => i.USER_FUNCTION_ID == id); system.IS_ACTIVE = isActive; RoleSystemRepository.SaveChanges(); result = true; } return(result); }
public object GetDetails(string userName, string cityID, string systemID) { //Guid cityid = new Guid(cityID); //Guid systemid = new Guid(systemID); var user = UserRepository.GetQueryable().FirstOrDefault(u => u.USER_NAME == userName); var userSystem = UserSystemRepository.GetQueryable().Where(us => us.USER_USER_ID == user.USER_ID && us.SYSTEM_SYSTEM_ID == systemID && us.CITY_CITY_ID == cityID).Select(us => us.USER_SYSTEM_ID); var usersystems = UserSystemRepository.GetQueryable().Where(us => !userSystem.Any(uid => uid == us.USER_SYSTEM_ID) && us.USER_USER_ID == user.USER_ID && us.SYSTEM_SYSTEM_ID == systemID).Select(us => new { us.AUTH_CITY.CITY_ID, us.AUTH_CITY.CITY_NAME, us.AUTH_CITY.DESCRIPTION, IS_ACTIVE = us.AUTH_CITY.IS_ACTIVE == "1" ? "启用" : "禁用" }); return(usersystems.ToArray()); }
public object GetDetails(string userName, string cityID, string systemID) { Guid cityid = new Guid(cityID); Guid systemid = new Guid(systemID); var user = UserRepository.GetQueryable().FirstOrDefault(u => u.UserName == userName); var userSystem = UserSystemRepository.GetQueryable().Where(us => us.User_UserID == user.UserID && us.System_SystemID == systemid && us.City_CityID == cityid).Select(us => us.UserSystemID); var usersystems = UserSystemRepository.GetQueryable().Where(us => !userSystem.Any(uid => uid == us.UserSystemID) && us.User_UserID == user.UserID && us.System_SystemID == systemid).Select(us => new { us.City.CityID, us.City.CityName, us.City.Description, Status = us.City.IsActive ? "启用" : "禁用" }); return(usersystems.ToArray()); }
public object GetDetails(string userName, string systemID, string cityID) { Guid cityid = new Guid(cityID); Guid systemid = new Guid(systemID); var user = UserRepository.GetQueryable().FirstOrDefault(u => u.UserName == userName); var userSystemId = UserSystemRepository.GetQueryable().Where(us => us.User_UserID == user.UserID && us.System.SystemID == systemid && us.City_CityID == cityid).Select(us => us.UserSystemID); var userSystems = UserSystemRepository.GetQueryable().Where(us => !userSystemId.Contains(us.UserSystemID) && us.User_UserID == user.UserID && us.City.CityID == cityid); var userSystem = userSystems.Where(us => us.UserModules.Any(um => um.UserFunctions.Any(uf => uf.IsActive == true))) .Select(us => new { us.System.SystemID, us.System.SystemName, us.System.Description, Status = us.City.IsActive ? "启用" : "禁用" }); return(userSystem.ToArray()); }
public object GetUserSystemDetails(string userID, string cityID, string systemID) { IQueryable <AUTH_SYSTEM> querySystem = SystemRepository.GetQueryable(); IQueryable <AUTH_MODULE> queryModule = ModuleRepository.GetQueryable(); IQueryable <AUTH_USER_SYSTEM> queryUserSystem = UserSystemRepository.GetQueryable(); IQueryable <AUTH_USER_MODULE> queryUserModule = UserModuleRepository.GetQueryable(); var systems = querySystem.Single(i => i.SYSTEM_ID == systemID); var userSystems = queryUserSystem.FirstOrDefault(i => i.AUTH_SYSTEM.SYSTEM_ID == systemID && i.AUTH_USER.USER_ID == userID && i.AUTH_CITY.CITY_ID == cityID); HashSet <Tree> userSystemTreeSet = new HashSet <Tree>(); Tree userSystemTree = new Tree(); userSystemTree.id = userSystems.USER_SYSTEM_ID.ToString(); userSystemTree.text = "系统:" + systems.SYSTEM_NAME; userSystemTree.@checked = userSystems.IS_ACTIVE == "1"?true:false; userSystemTree.attributes = "system"; var modules = queryModule.Where(m => m.AUTH_SYSTEM.SYSTEM_ID == systems.SYSTEM_ID && m.MODULE_ID == m.PARENT_AUTH_MODULE.MODULE_ID) .OrderBy(m => m.SHOW_ORDER) .Select(m => m); HashSet <Tree> moduleTreeSet = new HashSet <Tree>(); foreach (var item in modules) { Tree moduleTree = new Tree(); string moduleID = item.MODULE_ID.ToString(); //var userModules = queryUserModule.FirstOrDefault(i => i.Module.ModuleID == new Guid(moduleID) && i.UserSystem.UserSystemID == userSystems.UserSystemID); var userModules = queryUserModule.FirstOrDefault(i => i.AUTH_MODULE.MODULE_ID == moduleID && i.AUTH_USER_SYSTEM.USER_SYSTEM_ID == userSystems.USER_SYSTEM_ID); moduleTree.id = userModules.USER_MODULE_ID.ToString(); moduleTree.text = "模块:" + item.MODULE_NAME; int a = Convert.ToInt32(userModules.IS_ACTIVE); moduleTree.@checked = Convert.ToBoolean(a); moduleTree.attributes = "module"; moduleTreeSet.Add(moduleTree); SetModuleTree(moduleTree, item, userSystems); moduleTreeSet.Add(moduleTree); } userSystemTree.children = moduleTreeSet.ToArray(); userSystemTreeSet.Add(userSystemTree); return(userSystemTreeSet.ToArray()); }
public object GetUserSystemDetails(string userID, string cityID, string systemID) { IQueryable <THOK.Authority.DbModel.System> querySystem = SystemRepository.GetQueryable(); IQueryable <THOK.Authority.DbModel.Module> queryModule = ModuleRepository.GetQueryable(); IQueryable <THOK.Authority.DbModel.UserSystem> queryUserSystem = UserSystemRepository.GetQueryable(); IQueryable <THOK.Authority.DbModel.UserModule> queryUserModule = UserModuleRepository.GetQueryable(); var systems = querySystem.Single(i => i.SystemID == new Guid(systemID)); var userSystems = queryUserSystem.FirstOrDefault(i => i.System.SystemID == new Guid(systemID) && i.User.UserID == new Guid(userID) && i.City.CityID == new Guid(cityID)); HashSet <Tree> userSystemTreeSet = new HashSet <Tree>(); Tree userSystemTree = new Tree(); userSystemTree.id = userSystems.UserSystemID.ToString(); userSystemTree.text = "系统:" + systems.SystemName; userSystemTree.@checked = userSystems.IsActive; userSystemTree.attributes = "system"; var modules = queryModule.Where(m => m.System.SystemID == systems.SystemID && m.ModuleID == m.ParentModule.ModuleID) .OrderBy(m => m.ShowOrder) .Select(m => m); HashSet <Tree> moduleTreeSet = new HashSet <Tree>(); foreach (var item in modules) { Tree moduleTree = new Tree(); string moduleID = item.ModuleID.ToString(); var userModules = queryUserModule.FirstOrDefault(i => i.Module.ModuleID == new Guid(moduleID) && i.UserSystem.UserSystemID == userSystems.UserSystemID); moduleTree.id = userModules.UserModuleID.ToString(); moduleTree.text = "模块:" + item.ModuleName; moduleTree.@checked = userModules.IsActive; moduleTree.attributes = "module"; moduleTreeSet.Add(moduleTree); SetModuleTree(moduleTree, item, userSystems); moduleTreeSet.Add(moduleTree); } userSystemTree.children = moduleTreeSet.ToArray(); userSystemTreeSet.Add(userSystemTree); return(userSystemTreeSet.ToArray()); }