Exemple #1
0
        public ActionResult GetMenuByRole()
        {
            //select rm.menuId from Employee e inner join RoleMenu rm on e.roleId=rm.roleId
            RoleMenuBLL rm       = new RoleMenuBLL();
            int         roleId   = ((Employee)Session["employee"]).roleId;
            RoleMenu    roleMenu = rm.GetEntityById(roleId);
            string      menuJson = "";

            if (roleMenu != null && roleMenu.menuId != null && !roleMenu.Equals(""))
            {
                string[] menuIds = roleMenu.menuId.Split(',');
                int[]    ids     = new int[menuIds.Count()];//当前用户所属角色所有的菜单id
                for (int i = 0; i < menuIds.Count(); i++)
                {
                    ids[i] = Convert.ToInt32(menuIds[i]);
                }
                MenuBLL         rmBll    = new MenuBLL();
                List <Menu>     menuList = rmBll.GetEntitys(t => ids.Contains(t.Id), true, t => t.sort).ToList();
                List <MenuTree> list     = new List <MenuTree>();
                foreach (Menu menu in menuList)
                {
                    if (menu.parent == 0)
                    {
                        MenuTree mtree = new MenuTree();
                        mtree.text       = menu.text;
                        mtree.Id         = menu.Id;
                        mtree.leaf       = menu.leaf;
                        mtree.view       = menu.view;
                        mtree.sort       = menu.sort;
                        mtree.parent     = menu.parent;
                        mtree.expanded   = menu.expanded;
                        mtree.iconCls    = menu.iconCls;
                        mtree.controller = menu.controller;
                        mtree.xtypes     = menu.xtypes;
                        List <Menu> _clist = new List <Menu>();
                        foreach (Menu _menu in menuList)
                        {
                            if (_menu.parent == menu.Id)
                            {
                                _clist.Add(new Menu {
                                    text = _menu.text, Id = _menu.Id, leaf = _menu.leaf, iconCls = _menu.iconCls, view = _menu.view, sort = _menu.sort, parent = _menu.parent, controller = _menu.controller, xtypes = _menu.xtypes
                                });
                            }
                        }
                        mtree.children = _clist;
                        list.Add(mtree);
                    }
                }
                menuJson  = Common.Common.JsonSerialize(list);
                menuJson  = "{checked:false,children:" + menuJson;
                menuJson += "}";
            }

            return(Content(menuJson));
        }
Exemple #2
0
        public ActionResult GetAllMenu()
        {
            MenuBLL         mbll     = new MenuBLL();
            List <Menu>     menuList = mbll.GetEntitys(t => t.sort);
            string          menuJson = "";
            List <MenuTree> list     = new List <MenuTree>();

            foreach (Menu menu in menuList)
            {
                if (menu.parent == 0)
                {
                    MenuTree mtree = new MenuTree();
                    mtree.text       = menu.text;
                    mtree.Id         = menu.Id;
                    mtree.leaf       = menu.leaf;
                    mtree.view       = menu.view;
                    mtree.sort       = menu.sort;
                    mtree.parent     = menu.parent;
                    mtree.expanded   = menu.expanded;
                    mtree.iconCls    = menu.iconCls;
                    mtree.controller = menu.controller;
                    mtree.xtypes     = menu.xtypes;
                    List <Menu> _clist = new List <Menu>();
                    foreach (Menu _menu in menuList)
                    {
                        if (_menu.parent == menu.Id)
                        {
                            _clist.Add(new Menu {
                                text = _menu.text, Id = _menu.Id, leaf = _menu.leaf, iconCls = _menu.iconCls, view = _menu.view, sort = _menu.sort, parent = _menu.parent, controller = _menu.controller, xtypes = _menu.xtypes
                            });
                        }
                    }
                    mtree.children = _clist;
                    list.Add(mtree);
                }
            }
            menuJson  = Common.Common.JsonSerialize(list);
            menuJson  = "{text:'',children:" + menuJson;
            menuJson += "}";

            return(Content(Common.Common.JsonSerialize(list)));
        }
Exemple #3
0
        public ActionResult GetAllMenu()
        {
            MenuBLL mbll = new MenuBLL();
            List<Menu> menuList = mbll.GetEntitys(t => t.sort);
            string menuJson = "";
            List<MenuTree> list = new List<MenuTree>();
            foreach (Menu menu in menuList)
            {
                if (menu.parent == 0)
                {
                    MenuTree mtree = new MenuTree();
                    mtree.text = menu.text;
                    mtree.Id = menu.Id;
                    mtree.leaf = menu.leaf;
                    mtree.view = menu.view;
                    mtree.sort = menu.sort;
                    mtree.parent = menu.parent;
                    mtree.expanded = menu.expanded;
                    mtree.iconCls = menu.iconCls;
                    mtree.controller = menu.controller;
                    mtree.xtypes = menu.xtypes;
                    List<Menu> _clist = new List<Menu>();
                    foreach (Menu _menu in menuList)
                    {
                        if (_menu.parent == menu.Id)
                        {
                            _clist.Add(new Menu { text = _menu.text, Id = _menu.Id, leaf = _menu.leaf, iconCls = _menu.iconCls, view = _menu.view,sort=_menu.sort,parent=_menu.parent,controller=_menu.controller,xtypes=_menu.xtypes });
                        }
                    }
                    mtree.children = _clist;
                    list.Add(mtree);
                }
            }
            menuJson = Common.Common.JsonSerialize(list);
            menuJson = "{text:'',children:" + menuJson;
            menuJson += "}";

            return Content(Common.Common.JsonSerialize(list));
        }
Exemple #4
0
        public ActionResult GetMenuByRole()
        {
            //select rm.menuId from Employee e inner join RoleMenu rm on e.roleId=rm.roleId
            RoleMenuBLL rm = new RoleMenuBLL();
            int roleId = ((Employee)Session["employee"]).roleId;
            RoleMenu roleMenu = rm.GetEntityById(roleId);
            string menuJson = "";
            if (roleMenu != null && roleMenu.menuId != null && !roleMenu.Equals(""))
            {
                string[] menuIds = roleMenu.menuId.Split(',');
                int[] ids = new int[menuIds.Count()];//当前用户所属角色所有的菜单id
                for (int i = 0; i < menuIds.Count(); i++)
                {
                    ids[i] = Convert.ToInt32(menuIds[i]);
                }
                MenuBLL rmBll = new MenuBLL();
                List<Menu> menuList = rmBll.GetEntitys(t => ids.Contains(t.Id),true,t=>t.sort).ToList();
                List<MenuTree> list = new List<MenuTree>();
                foreach (Menu menu in menuList)
                {
                    if (menu.parent == 0)
                    {
                        MenuTree mtree = new MenuTree();
                        mtree.text = menu.text;
                        mtree.Id = menu.Id;
                        mtree.leaf = menu.leaf;
                        mtree.view = menu.view;
                        mtree.sort = menu.sort;
                        mtree.parent = menu.parent;
                        mtree.expanded = menu.expanded;
                        mtree.iconCls = menu.iconCls;
                        mtree.controller = menu.controller;
                        mtree.xtypes = menu.xtypes;
                        List<Menu> _clist = new List<Menu>();
                        foreach (Menu _menu in menuList)
                        {
                            if (_menu.parent == menu.Id)
                            {
                                _clist.Add(new Menu { text = _menu.text, Id = _menu.Id, leaf = _menu.leaf, iconCls = _menu.iconCls, view = _menu.view, sort = _menu.sort, parent = _menu.parent, controller = _menu.controller, xtypes = _menu.xtypes });
                            }
                        }
                        mtree.children = _clist;
                        list.Add(mtree);
                    }
                }
                menuJson = Common.Common.JsonSerialize(list);
                menuJson = "{checked:false,children:" + menuJson;
                menuJson += "}";
            }

            return Content(menuJson);
        }