Пример #1
0
        //yxk 2015-11-25
        /// <summary>
        /// 获取当前节点的所有父节点,包含当前节点
        /// </summary>
        /// <param name="curNode"></param>
        /// <param name="listModuleId"></param>
        /// <returns></returns>
        private RightTree GetParentsTreeNodes(RightTree curNode, List <int> listModuleId)
        {
            RightTree partreeNode = null;
            int       moduId      = Convert.ToInt32(curNode.id);
            var       curmodu     = _moduleContract.Modules.Where(c => c.Id == moduId && c.IsDeleted == false && c.IsEnabled == true && listModuleId.Contains(c.Id)).FirstOrDefault();

            if (curmodu == null)
            {
                return(null);
            }
            else if (curmodu.ParentId != null)
            {
                partreeNode = _moduleContract.Modules.Where(c => c.Id == curmodu.ParentId && c.IsDeleted == false && c.IsEnabled == true && listModuleId.Contains(c.Id)).Select(c => new RightTree()
                {
                    id       = "" + c.Id,
                    text     = c.ModuleName,
                    url      = "",
                    _checked = false
                }).FirstOrDefault();
                if (partreeNode.children == null)
                {
                    partreeNode.children = new List <RightTree>();
                }
                partreeNode.children.Add(curNode);
                GetParentsTreeNodes(partreeNode, listModuleId);
                return(partreeNode);
            }
            else
            {
                return(partreeNode);
            }
        }
Пример #2
0
        private RightTree GetNode(List <int> moduleIds)
        {
            RightTree retree = new RightTree()
            {
                id       = "0",
                _checked = false,
                text     = "选择权限",
                url      = "",
                children = new List <RightTree>()
            };
            var parmodules = _moduleContract.Modules.Where(c => c.ParentId == null && c.IsEnabled == true && c.IsDeleted == false);

            if (parmodules.IsNotNullOrEmptyThis())
            {
                foreach (var item in parmodules)
                {
                    retree.children.Add(new RightTree()
                    {
                        id       = item.Id + "",
                        text     = item.ModuleName,
                        _checked = false,
                        _isShow  = false,
                        url      = "",
                        children = GetChild(item.Id, moduleIds),
                    });
                }
            }
            return(retree);
        }
Пример #3
0
        private List <RightTree> GetChild(int parid, List <ARolePermissionRelation> rolepers, List <Module> listmodules)
        {
            List <RightTree> li = new List <RightTree>();

            var mods     = listmodules.Where(c => c.ParentId == parid);
            var listpers = CacheAccess.GetPermissions(_permissionContract).Where(c => c.IsEnabled == true && c.IsDeleted == false).ToList();

            foreach (var c in mods)
            {
                var tr = new RightTree()
                {
                    id       = c.Id + "",
                    text     = c.ModuleName,
                    url      = "",
                    children = GetPermiss(c.Id, rolepers, listpers),
                    _checked = false,
                    msg      = c.Description
                };

                tr._checked = tr.children.Any(x => x._checked);
                tr._isShow  = tr.children.Any(x => x._isShow);
                li.Add(tr);
            }

            return(li);
        }
Пример #4
0
        private RightTree GetNode(List <ARolePermissionRelation> rolepers)
        {
            RightTree retree = new RightTree()
            {
                id       = "0",
                _checked = false,
                text     = "选择权限",
                url      = "",
                children = new List <RightTree>()
            };
            var listmodules = CacheAccess.GetModules(_moduleContract).Where(w => w.IsEnabled && !w.IsDeleted).ToList();
            var parmodules  = listmodules.Where(c => c.ParentId == null).ToList();

            foreach (var item in parmodules)
            {
                var tre = new RightTree()
                {
                    id       = item.Id + "",
                    text     = item.ModuleName,
                    url      = "",
                    children = GetChild(item.Id, rolepers, listmodules),
                    _checked = false,
                    msg      = item.Description
                };
                tre._checked = tre.children.Any(c => c._checked);
                tre._isShow  = tre.children.Any(x => x._isShow);
                retree.children.Add(tre);
            }
            retree._checked = retree.children.Any(x => x._checked);
            retree._isShow  = retree.children.Any(x => x._isShow);
            return(retree);
        }
Пример #5
0
        public IEnumerable <TItem> PreOrder(TItem node)
        {
            if (node != null)
            {
                yield return(node);

                if (LeftTree != null)
                {
                    foreach (var x in LeftTree.PreOrder(LeftTree.Node))
                    {
                        yield return(x);
                    }
                }
                if (RightTree != null)
                {
                    foreach (var x in RightTree.PreOrder(RightTree.Node))
                    {
                        yield return(x);
                    }
                }
            }
        }
Пример #6
0
        //yxk 2015-11-25
        /// <summary>
        /// 获取当前节点的所有子节点,包含当前节点
        /// </summary>
        /// <param name="curNode"></param>
        /// <param name="listModuleId"></param>
        /// <returns></returns>
        private RightTree GetChildTreeNodes(RightTree curNode, List <int> listModuleId)
        {
            int moduId           = Convert.ToInt32(curNode.id);
            List <RightTree> tre = _moduleContract.Modules.Where(c => c.ParentId == moduId && listModuleId.Contains(c.Id)).Select(c => new RightTree()
            {
                id       = "" + c.Id,
                text     = c.ModuleName,
                url      = "",
                _checked = false
            }).ToList();

            if (tre != null)
            {
                curNode.children = tre;
            }

            foreach (var chTre in tre)
            {
                GetChildTreeNodes(chTre, listModuleId);
            }
            return(curNode);
        }