コード例 #1
0
        public IActionResult LoadMenu()
        {
            SmartHttpResult result = new SmartHttpResult();

            try
            {
                var entityList = DAL.SystemManage.SmartMenu.getMenuByUserName(HttpContext.User.Identity.Name);
                List <Models.JsonTreeNode> menuList = new List <Models.JsonTreeNode>();
                foreach (var entity in entityList)
                {
                    if (entity.ParentIdx == null)
                    {
                        Models.JsonTreeNode node = new Models.JsonTreeNode();
                        //node.Idx = entity.Idx;
                        node.text = entity.ModuleName;
                        node.link = entity.Link;
                        node.icon = entity.Icon;
                        Common.Helper.SmartMenuTreeHelper.LoadTree(entityList.ToList(), node, entity.Idx);
                        menuList.Add(node);
                    }
                }
                result.Set(true, menuList);
            }
            catch (Exception err)
            {
                result.Set(false, err.Message);
            }
            return(JsonEx(result));
        }
コード例 #2
0
        public static void LoadModuleTree(List <Models.SystemManage.SmartMenuModel> all, Models.JsonTreeNode menuNode, long Idx)
        {
            var linq = from child in all where child.ParentIdx == Idx orderby child.SortOrder select child;

            menuNode.children = new List <Models.JsonTreeNode>();
            foreach (var entity in linq)
            {
                Models.JsonTreeNode node = new Models.JsonTreeNode();
                //node.Idx = entity.Idx;
                node.text = entity.ModuleName;
                node.icon = entity.Icon;
                LoadTree(all, node, entity.Idx);
                menuNode.group = true;
                menuNode.children.Add(node);
            }
        }