Exemplo n.º 1
0
        private static List <EasyUiTreeNode> LoadTree(PageItemDataAccess access, int parent, List <RolePowerData> powers)
        {
            var data = access.All(p => p.ParentId == parent);

            return(data.Select(item => new EasyUiTreeNode
            {
                ID = item.ID,
                Text = item.Name,
                Title = item.Caption,
                Memo = item.Memo,
                IsOpen = true,
                IsSelect = powers.Any(p => p.PageItemId == item.ID),
                Children = LoadTree(access, item.ID, powers)
            }).ToList());
        }
Exemplo n.º 2
0
        private void LoadPowers()
        {
            var pAccess = new RolePowerDataAccess();
            var powers  = pAccess.All(p => p.RoleId == ContextDataId);
            var iAccess = new PageItemDataAccess();

            SetCustomJsonResult(
                new List <EasyUiTreeNode>
            {
                new EasyUiTreeNode
                {
                    ID       = 0,
                    Text     = "微信预约系统",
                    Title    = "微信预约系统",
                    IsOpen   = true,
                    IsSelect = true,
                    Children = LoadTree(iAccess, 0, powers)
                }
            });
        }
Exemplo n.º 3
0
        /// <summary>
        ///     生成角色菜单
        /// </summary>
        static List <EasyUiTreeNode> CreateMenu(RedisProxy proxy)
        {
            var root = new EasyUiTreeNode
            {
                ID       = 0,
                IsOpen   = true,
                Text     = ConfigurationManager.AppSettings["ProjectName"],
                IsFolder = true
            };
            var access = new PageItemDataAccess();
            var pages  = access.All(p => p.ItemType <= PageItemType.Page);

            foreach (var folder in pages.Where(p => p.ItemType == PageItemType.Root).OrderBy(p => p.Index))
            {
                var node = new EasyUiTreeNode
                {
                    IsOpen     = true,
                    Text       = folder.Caption,
                    Icon       = "icon-item",
                    Attributes = "home.aspx",
                    Tag        = folder.ExtendValue,
                    IsFolder   = true
                };
                foreach (var page in pages.Where(p => p.ParentId == folder.Id && p.ItemType <= PageItemType.Page).OrderBy(p => p.Index))
                {
                    CreateRoleMenu(node, pages, page);
                }
                if (node.HaseChildren)
                {
                    root.Children.Add(node);
                }
            }
            var result = root.Children.OrderByDescending(p => p.ID).ToList( );

            proxy.Set(DataKeyBuilder.ToKey("auth", "menu", 0), result);
            return(result);
        }