Esempio n. 1
0
        /// <summary>
        /// 获取用户的菜单
        /// </summary>
        /// <returns></returns>
        public async Task <List <MenuTreeDto> > GetMenuTreeJson()
        {
            List <MenuTreeDto> menuTreeDtos = new List <MenuTreeDto>();
            //获取用户设置的菜单
            string usermenudata = _menuManager.LoadUserSettingMenusData(AbpSession.UserId);

            //有设定的菜单
            if (!string.IsNullOrEmpty(usermenudata))
            {
                menuTreeDtos = Newtonsoft.Json.JsonConvert.DeserializeObject <List <MenuTreeDto> >(usermenudata);
            }
            //没有从默认的菜单中获取
            else
            {
                var menu     = _menuManager.LoadDefaultMenus();
                var userMenu = new List <CustomUserMenuItem>();
                //这里需要直接过滤出当前账套能使用的菜单,但是不使用权限过滤,因为权限设置页需要显示账套所有菜单
                await _menuManager.FillUserMenuItems(AbpSession.ToUserIdentifier(), menu, userMenu, false);

                menuTreeDtos = userMenu.MapTo <List <MenuTreeDto> >();
                //menuTreeDtos = menu.MapTo<List<MenuTreeDto>>();
            }
            //按照登录用户的是Host还是Tenant进行过滤
            FilterByTenancySide(menuTreeDtos, AbpSession.MultiTenancySide);

            return(menuTreeDtos);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取用户可见菜单
        /// </summary>
        /// <param name="userIdentifier"></param>
        /// <returns></returns>
        public async Task <List <CustomUserMenuItem> > GetUserMenu(Abp.UserIdentifier userIdentifier)
        {
            var userMenus = new List <CustomUserMenuItem>();
            var menus     = GetDefinitionMenu();
            await _menuManager.FillUserMenuItems(userIdentifier, menus, userMenus);

            return(userMenus);
        }