示例#1
0
        public ActionResult MenuAction(int id)
        {
            List <Entity.Path>   userPaths   = userService.GetPersonaliztionPaths(id);
            List <Entity.Action> pathActons  = roleService.GetActionsByPathIds(userPaths.Select(rp => rp.Id).ToList());
            List <Entity.Action> roleActions = roleService.GetActionsByRole(id);

            DhtmlxTreeView treeView = new DhtmlxTreeView();

            foreach (var item in userPaths.Where(m => !m.IsCategory))
            {
                DhtmlxTreeViewItem categoryItem = new DhtmlxTreeViewItem("Path{0}".Fmt(item.Id), item.Name, false, false, DhtmlxTreeViewCheckbox.hidden);
                bool hasAction = false;
                foreach (var subItem in pathActons.Where(ra => ra.PathId == item.Id))
                {
                    bool hasPath = roleActions.Exists(r => r.Id == subItem.Id);

                    DhtmlxTreeViewItem subTreeItem = new DhtmlxTreeViewItem(subItem.Id.ToString(), subItem.Name, false, hasPath, DhtmlxTreeViewCheckbox.NotSet);
                    categoryItem.AddTreeViewItem(subTreeItem);
                    hasAction = true;
                }
                if (hasAction)
                {
                    treeView.AddTreeViewItem(categoryItem);
                }
            }

            string str = treeView.BuildDhtmlXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }
示例#2
0
        public ActionResult NameCate()
        {
            XElement rootElem = BuildItemCodeTree(itemNameService);

            var itemTypes = itemNameService.GetAllTypeCodes();
            var itemCodes = itemNameService.GetAllItemCodes();

            DhtmlxTreeView treeView = new DhtmlxTreeView();

            bool isOpen = true;

            foreach (var itemType in itemTypes)
            {
                DhtmlxTreeViewItem typeItem = new DhtmlxTreeViewItem(itemType.CheckItemCode, "{0}({1})".Fmt(itemType.CheckItemName, itemType.CheckItemCode), isOpen, false, DhtmlxTreeViewCheckbox.NotSet);
                //isOpen = false;

                foreach (var codeItem in itemCodes.Where(f => f.itemcode != null && f.itemcode.Contains(itemType.CheckItemCode)))
                {
                    if (codeItem != null)
                    {
                        typeItem.AddTreeViewItem(codeItem.itemcode, "{0}".Fmt(codeItem.itemcode));
                    }
                }

                treeView.AddTreeViewItem(typeItem);
            }
            string str = treeView.BuildDhtmlXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }
        public ActionResult Category()
        {
            List <Path> paths = rep.GetByCondition(r => r.IsCategory);

            DhtmlxTreeView     treeView = new DhtmlxTreeView();
            DhtmlxTreeViewItem item     = new DhtmlxTreeViewItem("Main", "模块类别", true, false, DhtmlxTreeViewCheckbox.NotSet);

            foreach (var menuItem in paths.OrderBy(p => p.OrderNo))
            {
                item.AddTreeViewItem(menuItem.Id.ToString(), menuItem.Name);
            }
            treeView.AddTreeViewItem(item);

            string str = treeView.BuildDhtmlXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }
示例#4
0
        public ActionResult Category()
        {
            List <SysDict> sysDicts = rep.GetByCondition(r => r.CategoryId < 0);

            DhtmlxTreeView     treeView = new DhtmlxTreeView();
            DhtmlxTreeViewItem item     = new DhtmlxTreeViewItem("Dict", "字典类别", true, false, DhtmlxTreeViewCheckbox.NotSet);

            foreach (var dictItem in sysDicts)
            {
                item.AddTreeViewItem(dictItem.Id, dictItem.Name);
            }
            treeView.AddTreeViewItem(item);

            string str = treeView.BuildDhtmlXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }
示例#5
0
        public ActionResult Menu(int id)
        {
            List <Entity.Path> rolePaths = userService.GetPersonaliztionPaths(id);

            var            menus    = menuRep.GetByCondition(m => m.Status == 1);
            DhtmlxTreeView treeView = new DhtmlxTreeView();

            foreach (var item in menus.Where(m => m.IsCategory))
            {
                DhtmlxTreeViewItem categoryItem = new DhtmlxTreeViewItem(item.Id.ToString(), item.Name, false, false, DhtmlxTreeViewCheckbox.hidden);
                foreach (var subItem in menus.Where(su => su.CategoryId == item.Id))
                {
                    bool hasPath = rolePaths.Exists(r => r.Id == subItem.Id);

                    DhtmlxTreeViewItem subTreeItem = new DhtmlxTreeViewItem(subItem.Id.ToString(), subItem.Name, false, hasPath, DhtmlxTreeViewCheckbox.NotSet);
                    categoryItem.AddTreeViewItem(subTreeItem);
                }
                treeView.AddTreeViewItem(categoryItem);
            }

            string str = treeView.BuildDhtmlXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }
示例#6
0
        public ActionResult Areas(int id)
        {
            var allArea   = sysDictService.GetDictsByKey("CustomArea");
            var userAreas = userService.GetUserAreas(id);

            DhtmlxTreeView     treeView = new DhtmlxTreeView();
            DhtmlxTreeViewItem item     = new DhtmlxTreeViewItem("Main", "地区", true, false, DhtmlxTreeViewCheckbox.hidden);

            foreach (var area in allArea)
            {
                bool isCheck = false;
                if (userAreas.Count > 0 && userAreas.Count(r => r.Area == area.Name) > 0)
                {
                    isCheck = true;
                }
                DhtmlxTreeViewItem subTreeItem = new DhtmlxTreeViewItem("{0}|{1}".Fmt(area.Name, area.Id), area.Name, false, isCheck, DhtmlxTreeViewCheckbox.NotSet);
                item.AddTreeViewItem(subTreeItem);
            }
            treeView.AddTreeViewItem(item);

            string str = treeView.BuildDhtmlXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }