コード例 #1
0
        //private MenuTree BuildChildTree(int parentId)
        //{
        //    MenuTree cRoot = new MenuTree();

        //    Menu cRootM = GetItemById(parentId);
        //    cRoot.Menu_Id = cRootM.Menu_Id;
        //    cRoot.Menu_Name = cRootM.Menu_Name;
        //    cRoot.Menu_Icon = cRootM.Menu_Icon;
        //    cRoot.Link_Url = cRootM.Link_Url;

        //    List<Menu> childs = GetChildsMenu(parentId);
        //    foreach(Menu m in childs)
        //    {
        //        MenuTree mt = BuildChildTree(m.Menu_Id);
        //        cRoot.childs.Add(mt);
        //    }
        //    return cRoot;

        //}
        //public MenuTree BuildMenuTree()
        //{
        //    Menu root = GetRootItem();

        //    return BuildChildTree(root.Menu_Id);
        //}

        private void BuildMenuList_inter(MenuListNode1 parent, List <MenuListNode1> list)
        {
            List <Equip_Archi> childs = GetChildsMenu(parent.EA_Id);

            foreach (Equip_Archi m in childs)
            {
                MenuListNode1 mn = new MenuListNode1();
                mn.EA_Id     = m.EA_Id;
                mn.EA_Name   = m.EA_Name;
                mn.EA_Code   = m.EA_Code;
                mn.EA_Title  = m.EA_Title;
                mn.Parent_id = parent.EA_Id;
                mn.level     = parent.level + 1;
                parent.Childs.Add(mn.EA_Id);
                list.Add(mn);
                BuildMenuList_inter(mn, list);
                mn.Childs.ForEach(i => parent.Childs.Add(i));
            }
        }
コード例 #2
0
        public List <MenuListNode1> BuildMenuList()
        {
            Equip_Archi   root = GetRootItem();
            MenuListNode1 rmn  = new MenuListNode1();

            rmn.EA_Id    = root.EA_Id;
            rmn.EA_Name  = root.EA_Name;
            rmn.EA_Code  = root.EA_Code;
            rmn.EA_Title = root.EA_Title;
            rmn.level    = -1;

            List <MenuListNode1> list = new List <MenuListNode1>();

            BuildMenuList_inter(rmn, list);
            foreach (MenuListNode1 mn in list)
            {
                if (mn.Parent_id == root.EA_Id)
                {
                    mn.Parent_id = 0;
                }
            }
            return(list);
        }