Beispiel #1
0
        /// <summary>
        /// 获取菜单树列表
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="checkedmenu"></param>
        /// <returns></returns>
        public List <TreeNode> GetMenuTree(long parent, long?checkedmenu)
        {
            var tree  = new List <TreeNode>();
            var menus = sysMenuDal.GetAllMenus().Where(x => x.ID != 0).ToList();

            GetMenuTree(tree, menus, parent, checkedmenu);
            return(tree);
        }
Beispiel #2
0
        /// <summary>
        /// 获取用户的菜单和权限集合
        /// </summary>
        /// <param name="user">用户</param>
        /// <param name="role">指定角色</param>
        /// <returns></returns>
        public List <TreeNode> GetUserRoleMenuPrivilegeTree(long corpType)
        {
            var tree          = new List <TreeNode>();
            var corpTypeMenus = new List <SysMenu>();

            if (corpType == 0)
            {
                corpTypeMenus = sysMenuDal.GetAllMenus().Where(x => x.ID != 0 && x.Canceler == null).ToList();
            }
            else
            {
                corpTypeMenus = sysMenuDal.GetAllMenus().Where(x => x.ID != 0 && x.Canceler == null && x.Name != "系统数据").ToList();
            }
            //勾选角色的菜单
            var roleMenus = new List <SysMenu>();

            var list = sysMenuTemplateDal.GetCorpList(corpType).Select(x => x.Menu).ToList();

            roleMenus = new USP.Context.USPEntities().SysMenu.Where(x => list.Contains(x.ID)).ToList();
            GetCorpTypeMenuTree(tree, corpTypeMenus, roleMenus, 0);

            return(tree);
        }