private void GetTreeNodeList(List<BaseDeptLayer> _layerlist, BaseDeptLayer _layer, treeNode _node)
 {
     List<BaseDeptLayer> list = _layerlist.FindAll(x => x.PId == _layer.LayerId);
     if (list.Count > 0)
     {
         _node.children = new List<treeNode>();
         for (int i = 0; i < list.Count; i++)
         {
             treeNode node = new treeNode(list[i].LayerId, list[i].Name);
             GetTreeNodeList(_layerlist, list[i], node);
             _node.children.Add(node);
         }
     }
 }
        public void GetMenuTree()
        {
            try
            {
                List<BaseModule> moduleList = NewObject<BaseModule>().getlist<BaseModule>();
                List<BaseMenu> menuList = NewObject<BaseMenu>().getlist<BaseMenu>();

                //AbstractModule module = NewObject<AbstractModule>();
                //List<AbstractModule> moduleList = module.GetModuleList();
                //AbstractMenu menu = NewObject<AbstractMenu>();
                //List<AbstractMenu> menuList = menu.GetMenuList();

                List<treeNode> tree = new List<treeNode>();

                for (int i = 0; i < moduleList.Count; i++)
                {
                    treeNode node = new treeNode(moduleList[i].ModuleId, moduleList[i].Name);
                    node.state = "open";
                    node.attributes = new Dictionary<string, object>();
                    node.attributes.Add("ismodule", true);
                    node.attributes.Add("moduleid", moduleList[i].ModuleId);
                    List<BaseMenu> menus = menuList.FindAll(x => (x.ModuleId == moduleList[i].ModuleId && x.PMenuId == -1)).OrderBy(x => x.SortId).ToList();
                    if (menus.Count > 0)
                    {
                        node.children = new List<treeNode>();
                        for (int j = 0; j < menus.Count; j++)
                        {
                            treeNode nodemenu = new treeNode(menus[j].MenuId, menus[j].Name);
                            //nodemenu.check = menugroup.FindIndex(x => x.MenuId == menus[j].MenuId) >= 0 ? true : false;
                            GetTreeNodeList(menuList, menus[j].MenuId, nodemenu);
                            nodemenu.attributes = new Dictionary<string, object>();
                            if (string.IsNullOrEmpty(menus[j].FunName) && string.IsNullOrEmpty(menus[j].FunWcfName) && string.IsNullOrEmpty(menus[j].UrlName))
                                nodemenu.attributes.Add("isclass", true);
                            else
                                nodemenu.attributes.Add("ismenu", true);
                            nodemenu.attributes.Add("moduleid", menus[j].ModuleId);
                            node.children.Add(nodemenu);
                        }
                    }

                    tree.Add(node);
                }

                JsonResult = ToTreeJson(tree);
            }
            catch (Exception ex)
            {
                JsonResult = ex.Message;
            }
        }
 private void GetTreeNodeList(List<BaseMenu> _menuList, List<BaseMenu> menugroup, int PId, treeNode _node)
 {
     List<BaseMenu> menus = _menuList.FindAll(x => x.PMenuId == PId).OrderBy(x => x.SortId).ToList();
     if (menus.Count > 0)
     {
         _node.children = new List<treeNode>();
         for (int i = 0; i < menus.Count; i++)
         {
             treeNode nodemenu = new treeNode(menus[i].MenuId, menus[i].Name);
             nodemenu.check = menugroup.FindIndex(x => x.MenuId == menus[i].MenuId) >= 0 ? true : false;
             GetTreeNodeList(_menuList, menugroup, menus[i].MenuId, nodemenu);
             _node.children.Add(nodemenu);
         }
     }
 }
        public void GetGroupMenu()
        {
            try
            {
                int groupid = Convert.ToInt32(ParamsData["groupId"]);

                List<BaseModule> moduleList = NewObject<BaseModule>().getlist<BaseModule>();
                List<BaseMenu> menuList = NewObject<BaseMenu>().getlist<BaseMenu>();

                Menu menu = NewObject<Menu>();
                List<BaseMenu> _menugroup = menu.GetGroupMenuList(groupid);
                List<BaseMenu> menugroup = new List<BaseMenu>();
                for (int i = 0; i < _menugroup.Count; i++)
                {
                    if (menuList.FindIndex(x => x.PMenuId == _menugroup[i].MenuId) == -1)
                        menugroup.Add(_menugroup[i]);
                }
                List<treeNode> tree = new List<treeNode>();

                for (int i = 0; i < moduleList.Count; i++)
                {
                    treeNode node = new treeNode(moduleList[i].ModuleId, moduleList[i].Name);
                    node.state = "open";
                    node.attributes = new Dictionary<string, object>();
                    node.attributes.Add("ismodule", true);
                    List<BaseMenu> menus = menuList.FindAll(x => (x.ModuleId == moduleList[i].ModuleId && x.PMenuId == -1)).OrderBy(x => x.SortId).ToList();
                    if (menus.Count > 0)
                    {
                        node.children = new List<treeNode>();
                        for (int j = 0; j < menus.Count; j++)
                        {
                            treeNode nodemenu = new treeNode(menus[j].MenuId, menus[j].Name);
                            nodemenu.check = menugroup.FindIndex(x => x.MenuId == menus[j].MenuId) >= 0 ? true : false;
                            GetTreeNodeList(menuList, menugroup, menus[j].MenuId, nodemenu);
                            node.children.Add(nodemenu);
                        }
                    }

                    tree.Add(node);
                }

                JsonResult = ToTreeJson(tree);
            }
            catch (Exception ex)
            {
                JsonResult = ex.Message;
            }
        }
        public void GetDeptLayers()
        {
            List<BaseDeptLayer> layerlist = NewObject<BaseDeptLayer>().getlist<BaseDeptLayer>();

            List<BaseDeptLayer> root = layerlist.FindAll(x => x.PId == 0);
            List<treeNode> tree = new List<treeNode>();
            for (int i = 0; i < root.Count; i++)
            {
                treeNode node = new treeNode(root[i].LayerId, root[i].Name);
                GetTreeNodeList(layerlist, root[i], node);
                tree.Add(node);

            }

            JsonResult = ToTreeJson(tree);
        }
 private void GetTreeNodeList(List<BaseMenu> _menuList, int PId, treeNode _node)
 {
     List<BaseMenu> menus = _menuList.FindAll(x => x.PMenuId == PId).OrderBy(x => x.SortId).ToList();
     if (menus.Count > 0)
     {
         _node.children = new List<treeNode>();
         for (int i = 0; i < menus.Count; i++)
         {
             treeNode nodemenu = new treeNode(menus[i].MenuId, menus[i].Name);
             //nodemenu.check = menugroup.FindIndex(x => x.MenuId == menus[i].MenuId) >= 0 ? true : false;
             GetTreeNodeList(_menuList, menus[i].MenuId, nodemenu);
             nodemenu.attributes = new Dictionary<string, object>();
             if (string.IsNullOrEmpty(menus[i].FunName) && string.IsNullOrEmpty(menus[i].FunWcfName) && string.IsNullOrEmpty(menus[i].UrlName))
                 nodemenu.attributes.Add("isclass", true);
             else
                 nodemenu.attributes.Add("ismenu", true);
             nodemenu.attributes.Add("moduleid", menus[i].ModuleId);
             _node.children.Add(nodemenu);
         }
     }
 }