Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        private void SetTree(Tree tree, Module module, RoleSystem roleSystems)
        {
            IQueryable <THOK.Authority.DbModel.RoleModule> queryRoleModule = RoleModuleRepository.GetQueryable();
            HashSet <Tree> childTreeSet = new HashSet <Tree>();
            var            modules      = from m in module.Modules
                                          orderby m.ShowOrder
                                          select m;

            foreach (var item in modules)
            {
                if (item != module)
                {
                    Tree   childTree   = new Tree();
                    string moduleID    = item.ModuleID.ToString();
                    var    roleModules = queryRoleModule.FirstOrDefault(i => i.Module.ModuleID == new Guid(moduleID) && i.RoleSystem.RoleSystemID == roleSystems.RoleSystemID);
                    childTree.id         = roleModules.RoleModuleID.ToString();
                    childTree.text       = "模块:" + item.ModuleName;
                    childTree.@checked   = roleModules == null ? false : roleModules.IsActive;
                    childTree.attributes = "module";
                    childTreeSet.Add(childTree);
                    if (item.Modules.Count > 0)
                    {
                        SetTree(childTree, item, roleSystems);
                    }
                    if (item.Functions.Count > 0)
                    {
                        SetFunTree(childTree, item, roleModules);
                    }
                }
            }
            tree.children = childTreeSet.ToArray();
        }
Exemplo n.º 4
0
        private void SetMenu(Menu menu, Module module)
        {
            IQueryable <THOK.Authority.DbModel.RoleModule> queryRoleModule = RoleModuleRepository.GetQueryable();
            HashSet <Menu> childMenuSet = new HashSet <Menu>();
            var            modules      = from m in module.Modules
                                          orderby m.ShowOrder
                                          select m;

            foreach (var item in modules)
            {
                if (item != module)
                {
                    Menu childMenu = new Menu();
                    childMenu.ModuleID         = item.ModuleID.ToString();
                    childMenu.ModuleName       = item.ModuleName;
                    childMenu.SystemID         = item.System.SystemID.ToString();
                    childMenu.SystemName       = item.System.SystemName;
                    childMenu.ParentModuleID   = item.ParentModule.ModuleID.ToString();
                    childMenu.ParentModuleName = item.ParentModule.ModuleName;
                    childMenu.ModuleURL        = item.ModuleURL;
                    childMenu.iconCls          = item.IndicateImage;
                    childMenu.ShowOrder        = item.ShowOrder;
                    childMenuSet.Add(childMenu);
                    if (item.Modules.Count > 0)
                    {
                        SetMenu(childMenu, item);
                    }
                }
            }
            menu.children = childMenuSet.ToArray();
        }
Exemplo n.º 5
0
        private void SetTree(Tree tree, AUTH_MODULE module, AUTH_ROLE_SYSTEM roleSystems)
        {
            IQueryable <AUTH_ROLE_MODULE> queryRoleModule = RoleModuleRepository.GetQueryable();
            HashSet <Tree> childTreeSet = new HashSet <Tree>();
            var            modules      = from m in module.AUTH_MODULES
                                          orderby m.SHOW_ORDER
                                          select m;

            foreach (var item in modules)
            {
                if (item != module)
                {
                    Tree   childTree = new Tree();
                    string moduleID  = item.MODULE_ID.ToString();
                    //var roleModules = queryRoleModule.FirstOrDefault(i => i.Module.ModuleID == new Guid(moduleID) && i.RoleSystem.RoleSystemID == roleSystems.RoleSystemID);
                    var roleModules = queryRoleModule.FirstOrDefault(i => i.AUTH_MODULE.MODULE_ID == moduleID && i.AUTH_ROLE_SYSTEM.ROLE_SYSTEM_ID == roleSystems.ROLE_SYSTEM_ID);

                    childTree.id   = roleModules.ROLE_MODULE_ID.ToString();
                    childTree.text = "模块:" + item.MODULE_NAME;
                    int a = Convert.ToInt32(roleModules.IS_ACTIVE);
                    childTree.@checked   = roleModules == null ? false : Convert.ToBoolean(a);
                    childTree.attributes = "module";
                    childTreeSet.Add(childTree);
                    if (item.AUTH_MODULES.Count > 0)
                    {
                        SetTree(childTree, item, roleSystems);
                    }
                    if (item.AUTH_FUNCTION.Count > 0)
                    {
                        SetFunTree(childTree, item, roleModules);
                    }
                }
            }
            tree.children = childTreeSet.ToArray();
        }
Exemplo n.º 6
0
        private void SetMenu(Menu menu, AUTH_MODULE module)
        {
            IQueryable <AUTH_ROLE_MODULE> queryRoleModule = RoleModuleRepository.GetQueryable();
            HashSet <Menu> childMenuSet = new HashSet <Menu>();
            var            modules      = from m in module.AUTH_MODULES
                                          orderby m.SHOW_ORDER
                                          select m;

            foreach (var item in modules)
            {
                if (item != module)
                {
                    Menu childMenu = new Menu();
                    childMenu.ModuleID         = item.MODULE_ID;
                    childMenu.ModuleName       = item.MODULE_NAME;
                    childMenu.SystemID         = item.AUTH_SYSTEM.SYSTEM_ID;
                    childMenu.SystemName       = item.AUTH_SYSTEM.SYSTEM_NAME;
                    childMenu.ParentModuleID   = item.PARENT_AUTH_MODULE.MODULE_ID;
                    childMenu.ParentModuleName = item.PARENT_AUTH_MODULE.MODULE_NAME;
                    childMenu.ModuleURL        = item.MODULE_URL;
                    childMenu.iconCls          = item.INDICATE_IMAGE;
                    childMenu.ShowOrder        = Convert.ToInt32(item.SHOW_ORDER);
                    childMenuSet.Add(childMenu);
                    if (item.AUTH_MODULES.Count > 0)
                    {
                        SetMenu(childMenu, item);
                    }
                }
            }
            menu.children = childMenuSet.ToArray();
        }
Exemplo n.º 7
0
        private void GetChildMenu(Menu moduleMenu, UserSystem userSystem, Module module)
        {
            IQueryable <THOK.Authority.DbModel.RoleModule> queryRoleModule = RoleModuleRepository.GetQueryable();
            HashSet <Menu> childMenuSet = new HashSet <Menu>();
            var            userModules  = from um in userSystem.UserModules
                                          where um.Module.ParentModule == module
                                          orderby um.Module.ShowOrder
                                          select um;

            foreach (var userModule in userModules)
            {
                var childModule = userModule.Module;
                if (childModule != module)
                {
                    var roles = userSystem.User.UserRoles.Select(ur => ur.Role);
                    if (userModule.IsActive || userModule.UserFunctions.Any(uf => uf.IsActive) ||
                        userModule.Module.RoleModules.Any(rm => roles.Any(r => r.RoleID == rm.RoleSystem.Role.RoleID &&
                                                                          (rm.IsActive || rm.RoleFunctions.Any(rf => rf.IsActive)))) ||
                        userModule.Module.Modules
                        .Any(m => m.UserModules.Any(um => um.UserSystem.User.UserID == userModule.UserSystem.User.UserID &&
                                                    (um.IsActive || um.UserFunctions.Any(uf => uf.IsActive)))) ||
                        userModule.Module.Modules
                        .Any(m => m.RoleModules.Any(rm => roles.Any(r => r.RoleID == rm.RoleSystem.Role.RoleID &&
                                                                    (rm.IsActive || rm.RoleFunctions.Any(rf => rf.IsActive))))) ||
                        userModule.UserSystem.User.UserName == "Admin"
                        )
                    {
                        Menu childMenu = new Menu();
                        childMenu.ModuleID         = childModule.ModuleID.ToString();
                        childMenu.ModuleName       = childModule.ModuleName;
                        childMenu.SystemID         = childModule.System.SystemID.ToString();
                        childMenu.SystemName       = childModule.System.SystemName;
                        childMenu.ParentModuleID   = childModule.ParentModule.ModuleID.ToString();
                        childMenu.ParentModuleName = childModule.ParentModule.ModuleName;
                        childMenu.ModuleURL        = childModule.ModuleURL;
                        childMenu.iconCls          = childModule.IndicateImage;
                        childMenu.ShowOrder        = childModule.ShowOrder;
                        childMenuSet.Add(childMenu);
                        if (childModule.Modules.Count > 0)
                        {
                            GetChildMenu(childMenu, userSystem, childModule);
                        }
                    }
                }
            }
            moduleMenu.children = childMenuSet.ToArray();
        }
Exemplo n.º 8
0
        private void GetChildMenu(Menu moduleMenu, AUTH_USER_SYSTEM userSystem, AUTH_MODULE module)
        {
            IQueryable <AUTH_ROLE_MODULE> queryRoleModule = RoleModuleRepository.GetQueryable();
            HashSet <Menu> childMenuSet = new HashSet <Menu>();
            var            userModules  = from um in userSystem.AUTH_USER_MODULE
                                          where um.AUTH_MODULE.PARENT_AUTH_MODULE == module
                                          orderby um.AUTH_MODULE.SHOW_ORDER
                                          select um;

            foreach (var userModule in userModules)
            {
                var childModule = userModule.AUTH_MODULE;
                if (childModule != module)
                {
                    var roles = userSystem.AUTH_USER.AUTH_USER_ROLE.Select(ur => ur.AUTH_ROLE);
                    if (userModule.IS_ACTIVE == "1" || userModule.AUTH_USER_FUNCTION.Any(uf => uf.IS_ACTIVE == "1") ||
                        userModule.AUTH_MODULE.AUTH_ROLE_MODULE.Any(rm => roles.Any(r => r.ROLE_ID == rm.AUTH_ROLE_SYSTEM.AUTH_ROLE.ROLE_ID &&
                                                                                    (rm.IS_ACTIVE == "1" || rm.AUTH_ROLE_FUNCTION.Any(rf => rf.IS_ACTIVE == "1")))) ||
                        userModule.AUTH_MODULE.AUTH_MODULES
                        .Any(m => m.AUTH_USER_MODULE.Any(um => um.AUTH_USER_SYSTEM.AUTH_USER.USER_ID == userModule.AUTH_USER_SYSTEM.AUTH_USER.USER_ID &&
                                                         (um.IS_ACTIVE == "1" || um.AUTH_USER_FUNCTION.Any(uf => uf.IS_ACTIVE == "1")))) ||
                        userModule.AUTH_MODULE.AUTH_MODULES
                        .Any(m => m.AUTH_ROLE_MODULE.Any(rm => roles.Any(r => r.ROLE_ID == rm.AUTH_ROLE_SYSTEM.AUTH_ROLE.ROLE_ID &&
                                                                         (rm.IS_ACTIVE == "1" || rm.AUTH_ROLE_FUNCTION.Any(rf => rf.IS_ACTIVE == "1"))))) ||
                        userModule.AUTH_USER_SYSTEM.AUTH_USER.USER_NAME == "Admin"
                        )
                    {
                        Menu childMenu = new Menu();
                        childMenu.ModuleID         = childModule.MODULE_ID;
                        childMenu.ModuleName       = childModule.MODULE_NAME;
                        childMenu.SystemID         = childModule.AUTH_SYSTEM.SYSTEM_ID;;
                        childMenu.SystemName       = childModule.AUTH_SYSTEM.SYSTEM_NAME;
                        childMenu.ParentModuleID   = childModule.PARENT_AUTH_MODULE.MODULE_ID;
                        childMenu.ParentModuleName = childModule.PARENT_AUTH_MODULE.MODULE_NAME;
                        childMenu.ModuleURL        = childModule.MODULE_URL;
                        childMenu.iconCls          = childModule.INDICATE_IMAGE;
                        childMenu.ShowOrder        = Convert.ToInt32(childModule.SHOW_ORDER);
                        childMenuSet.Add(childMenu);
                        if (childModule.AUTH_MODULES.Count > 0)
                        {
                            GetChildMenu(childMenu, userSystem, childModule);
                        }
                    }
                }
            }
            moduleMenu.children = childMenuSet.ToArray();
        }
Exemplo n.º 9
0
        public object GetRoleSystemDetails(string roleID, string cityID, string systemID)
        {
            IQueryable <AUTH_SYSTEM>      querySystem     = SystemRepository.GetQueryable();
            IQueryable <AUTH_MODULE>      queryModule     = ModuleRepository.GetQueryable();
            IQueryable <AUTH_ROLE_SYSTEM> queryRoleSystem = RoleSystemRepository.GetQueryable();
            IQueryable <AUTH_ROLE_MODULE> queryRoleModule = RoleModuleRepository.GetQueryable();
            var            systems           = querySystem.Single(i => i.SYSTEM_ID == systemID);
            var            roleSystems       = queryRoleSystem.FirstOrDefault(i => i.AUTH_SYSTEM.SYSTEM_ID == systemID && i.AUTH_ROLE.ROLE_ID == roleID && i.AUTH_CITY.CITY_ID == cityID);
            HashSet <Tree> RolesystemTreeSet = new HashSet <Tree>();
            Tree           roleSystemTree    = new Tree();

            roleSystemTree.id   = roleSystems.ROLE_SYSTEM_ID.ToString();
            roleSystemTree.text = "系统:" + systems.SYSTEM_NAME;
            int a = Convert.ToInt32(roleSystems.IS_ACTIVE);

            roleSystemTree.@checked   = Convert.ToBoolean(a);
            roleSystemTree.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 roleModules = queryRoleModule.FirstOrDefault(i => i.Module.ModuleID == new Guid(moduleID) && i.RoleSystem.RoleSystemID == roleSystems.RoleSystemID);
                var roleModules = queryRoleModule.FirstOrDefault(i => i.AUTH_MODULE.MODULE_ID == moduleID && i.AUTH_ROLE_SYSTEM.ROLE_SYSTEM_ID == roleSystems.ROLE_SYSTEM_ID);
                moduleTree.id   = roleModules.ROLE_MODULE_ID.ToString();
                moduleTree.text = "模块:" + item.MODULE_NAME;
                string b = roleModules.IS_ACTIVE == "1" ? "true" : "false";
                moduleTree.@checked   = bool.Parse(b);
                moduleTree.attributes = "module";

                moduleTreeSet.Add(moduleTree);
                SetTree(moduleTree, item, roleSystems);
                moduleTreeSet.Add(moduleTree);
            }
            roleSystemTree.children = moduleTreeSet.ToArray();
            RolesystemTreeSet.Add(roleSystemTree);
            return(RolesystemTreeSet.ToArray());
        }
Exemplo n.º 10
0
        public object GetRoleSystemDetails(string roleID, string cityID, string systemID)
        {
            IQueryable <THOK.Authority.DbModel.System>     querySystem     = SystemRepository.GetQueryable();
            IQueryable <THOK.Authority.DbModel.Module>     queryModule     = ModuleRepository.GetQueryable();
            IQueryable <THOK.Authority.DbModel.RoleSystem> queryRoleSystem = RoleSystemRepository.GetQueryable();
            IQueryable <THOK.Authority.DbModel.RoleModule> queryRoleModule = RoleModuleRepository.GetQueryable();
            var            systems           = querySystem.Single(i => i.SystemID == new Guid(systemID));
            var            roleSystems       = queryRoleSystem.FirstOrDefault(i => i.System.SystemID == new Guid(systemID) && i.Role.RoleID == new Guid(roleID) && i.City.CityID == new Guid(cityID));
            HashSet <Tree> RolesystemTreeSet = new HashSet <Tree>();
            Tree           roleSystemTree    = new Tree();

            roleSystemTree.id         = roleSystems.RoleSystemID.ToString();
            roleSystemTree.text       = "系统:" + systems.SystemName;
            roleSystemTree.@checked   = roleSystems.IsActive;
            roleSystemTree.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    roleModules = queryRoleModule.FirstOrDefault(i => i.Module.ModuleID == new Guid(moduleID) && i.RoleSystem.RoleSystemID == roleSystems.RoleSystemID);
                moduleTree.id         = roleModules.RoleModuleID.ToString();
                moduleTree.text       = "模块:" + item.ModuleName;
                moduleTree.@checked   = roleModules.IsActive;
                moduleTree.attributes = "module";

                moduleTreeSet.Add(moduleTree);
                SetTree(moduleTree, item, roleSystems);
                moduleTreeSet.Add(moduleTree);
            }
            roleSystemTree.children = moduleTreeSet.ToArray();
            RolesystemTreeSet.Add(roleSystemTree);
            return(RolesystemTreeSet.ToArray());
        }
Exemplo n.º 11
0
        public object GetUserMenus(string userName, string cityID, string systemID)
        {
            if (String.IsNullOrEmpty(userName))
            {
                throw new ArgumentException("值不能为NULL或为空。", "userName");
            }
            if (String.IsNullOrEmpty(cityID))
            {
                throw new ArgumentException("值不能为NULL或为空。", "cityID");
            }
            if (String.IsNullOrEmpty(systemID))
            {
                throw new ArgumentException("值不能为NULL或为空。", "systemId");
            }

            IQueryable <THOK.Authority.DbModel.User>       queryUser       = UserRepository.GetQueryable();
            IQueryable <THOK.Authority.DbModel.City>       queryCity       = CityRepository.GetQueryable();
            IQueryable <THOK.Authority.DbModel.System>     querySystem     = SystemRepository.GetQueryable();
            IQueryable <THOK.Authority.DbModel.RoleModule> queryRoleModule = RoleModuleRepository.GetQueryable();

            Guid gSystemID = new Guid(systemID);
            Guid gCityID   = new Guid(cityID);
            var  user      = queryUser.Single(u => u.UserName == userName);
            var  city      = queryCity.Single(c => c.CityID == gCityID);
            var  system    = querySystem.Single(s => s.SystemID == gSystemID);

            InitUserSystem(user, city, system);

            var userSystem = (from us in user.UserSystems
                              where us.User.UserID == user.UserID &&
                              us.City.CityID == city.CityID &&
                              us.System.SystemID == system.SystemID
                              select us).Single();

            HashSet <Menu> systemMenuSet = new HashSet <Menu>();
            Menu           systemMenu    = new Menu();

            systemMenu.ModuleID   = userSystem.System.SystemID.ToString();
            systemMenu.ModuleName = userSystem.System.SystemName;
            systemMenu.SystemID   = userSystem.System.SystemID.ToString();
            systemMenu.SystemName = userSystem.System.SystemName;

            var userModules = from um in userSystem.UserModules
                              where um.Module.ModuleID == um.Module.ParentModule.ModuleID
                              orderby um.Module.ShowOrder
                              select um;

            HashSet <Menu> moduleMenuSet = new HashSet <Menu>();

            foreach (var userModule in userModules)
            {
                var roles = user.UserRoles.Select(ur => ur.Role);
                foreach (var role in roles)
                {
                    InitRoleSystem(role, city, system);
                }

                if (userModule.IsActive ||
                    userModule.Module.RoleModules.Any(rm => roles.Any(r => r.RoleID == rm.RoleSystem.Role.RoleID &&
                                                                      rm.IsActive)) ||
                    userModule.Module.Modules
                    .Any(m => m.UserModules.Any(um => um.UserSystem.User.UserID == userModule.UserSystem.User.UserID &&
                                                (um.IsActive || um.UserFunctions.Any(uf => uf.IsActive)))) ||
                    userModule.Module.Modules
                    .Any(m => m.RoleModules.Any(rm => roles.Any(r => r.RoleID == rm.RoleSystem.Role.RoleID &&
                                                                (rm.IsActive || rm.RoleFunctions.Any(rf => rf.IsActive))))) ||
                    user.UserName == "Admin"
                    )
                {
                    var  module     = userModule.Module;
                    Menu moduleMenu = new Menu();
                    moduleMenu.ModuleID         = module.ModuleID.ToString();
                    moduleMenu.ModuleName       = module.ModuleName;
                    moduleMenu.SystemID         = module.System.SystemID.ToString();
                    moduleMenu.SystemName       = module.System.SystemName;
                    moduleMenu.ParentModuleID   = module.ParentModule.ModuleID.ToString();
                    moduleMenu.ParentModuleName = module.ParentModule.ModuleName;
                    moduleMenu.ModuleURL        = module.ModuleURL;
                    moduleMenu.iconCls          = module.IndicateImage;
                    moduleMenu.ShowOrder        = module.ShowOrder;
                    GetChildMenu(moduleMenu, userSystem, module);
                    moduleMenuSet.Add(moduleMenu);
                }
            }
            systemMenu.children = moduleMenuSet.ToArray();
            systemMenuSet.Add(systemMenu);
            return(systemMenuSet.ToArray());
        }
Exemplo n.º 12
0
        public object GetUserMenus(string userName, string cityID, string systemID)
        {
            if (String.IsNullOrEmpty(userName))
            {
                throw new ArgumentException("值不能为NULL或为空。", "userName");
            }
            if (String.IsNullOrEmpty(cityID))
            {
                throw new ArgumentException("值不能为NULL或为空。", "cityID");
            }
            if (String.IsNullOrEmpty(systemID))
            {
                throw new ArgumentException("值不能为NULL或为空。", "systemId");
            }

            IQueryable <AUTH_USER>        queryUser       = UserRepository.GetQueryable();
            IQueryable <AUTH_CITY>        queryCity       = CityRepository.GetQueryable();
            IQueryable <AUTH_SYSTEM>      querySystem     = SystemRepository.GetQueryable();
            IQueryable <AUTH_ROLE_MODULE> queryRoleModule = RoleModuleRepository.GetQueryable();

            //Guid gSystemID = new Guid(systemID);
            //Guid gCityID = new Guid(cityID);
            var user   = queryUser.Single(u => u.USER_NAME == userName);
            var city   = queryCity.Single(c => c.CITY_ID.Trim() == cityID);
            var system = querySystem.Single(s => s.SYSTEM_ID.Trim() == systemID);
            // InitUserSystem(user, city, system);

            var userSystem = (from us in user.AUTH_USER_SYSTEM
                              where us.AUTH_USER.USER_ID == user.USER_ID &&
                              us.AUTH_CITY.CITY_ID == city.CITY_ID &&
                              us.AUTH_SYSTEM.SYSTEM_ID == system.SYSTEM_ID
                              select us).Single();

            HashSet <Menu> systemMenuSet = new HashSet <Menu>();
            Menu           systemMenu    = new Menu();

            systemMenu.ModuleID   = userSystem.AUTH_SYSTEM.SYSTEM_ID;
            systemMenu.ModuleName = userSystem.AUTH_SYSTEM.SYSTEM_NAME;
            systemMenu.SystemID   = userSystem.AUTH_SYSTEM.SYSTEM_ID;
            systemMenu.SystemName = userSystem.AUTH_SYSTEM.SYSTEM_NAME;

            var userModules = from um in userSystem.AUTH_USER_MODULE
                              where um.AUTH_MODULE.MODULE_ID == um.AUTH_MODULE.PARENT_AUTH_MODULE.MODULE_ID
                              orderby um.AUTH_MODULE.SHOW_ORDER
                              select um;

            HashSet <Menu> moduleMenuSet = new HashSet <Menu>();

            foreach (var userModule in userModules)
            {
                var roles = user.AUTH_USER_ROLE.Select(ur => ur.AUTH_ROLE);
                //foreach (var role in roles)
                //{
                //   InitRoleSystem(role, city, system);
                //}

                if (userModule.IS_ACTIVE == "1" ||
                    userModule.AUTH_MODULE.AUTH_ROLE_MODULE.Any(rm => roles.Any(r => r.ROLE_ID == rm.AUTH_ROLE_SYSTEM.AUTH_ROLE.ROLE_ID &&
                                                                                rm.IS_ACTIVE == "1")) ||
                    userModule.AUTH_MODULE.AUTH_MODULES
                    .Any(m => m.AUTH_USER_MODULE.Any(um => um.AUTH_USER_SYSTEM.AUTH_USER.USER_ID == userModule.AUTH_USER_SYSTEM.AUTH_USER.USER_ID &&
                                                     (um.IS_ACTIVE == "1" || um.AUTH_USER_FUNCTION.Any(uf => uf.IS_ACTIVE == "1")))) ||
                    userModule.AUTH_MODULE.AUTH_MODULES
                    .Any(m => m.AUTH_ROLE_MODULE.Any(rm => roles.Any(r => r.ROLE_ID == rm.AUTH_ROLE_SYSTEM.AUTH_ROLE.ROLE_ID &&
                                                                     (rm.IS_ACTIVE == "1" || rm.AUTH_ROLE_FUNCTION.Any(rf => rf.IS_ACTIVE == "1"))))) ||
                    user.USER_NAME == "Admin"
                    )
                {
                    var  module     = userModule.AUTH_MODULE;
                    Menu moduleMenu = new Menu();
                    moduleMenu.ModuleID         = module.MODULE_ID.ToString();
                    moduleMenu.ModuleName       = module.MODULE_NAME;
                    moduleMenu.SystemID         = module.AUTH_SYSTEM.SYSTEM_ID;
                    moduleMenu.SystemName       = module.AUTH_SYSTEM.SYSTEM_NAME;
                    moduleMenu.ParentModuleID   = module.PARENT_AUTH_MODULE.MODULE_ID;
                    moduleMenu.ParentModuleName = module.PARENT_AUTH_MODULE.MODULE_NAME;
                    moduleMenu.ModuleURL        = module.MODULE_URL;
                    moduleMenu.iconCls          = module.INDICATE_IMAGE;
                    moduleMenu.ShowOrder        = Convert.ToInt32(module.SHOW_ORDER);
                    GetChildMenu(moduleMenu, userSystem, module);
                    moduleMenuSet.Add(moduleMenu);
                }
            }
            systemMenu.children = moduleMenuSet.ToArray();
            systemMenuSet.Add(systemMenu);
            return(systemMenuSet.ToArray());
        }