Esempio n. 1
0
 private treenode ToTreeNode(NavDirectory.Node n)
 {
     var tn = new treenode
     {
         id = n.Id,
         leaf = n.Children == null || n.Children.Count == 0,
         text = n.Label,
         cls = n.CssClass
     };
     if (n.Children != null)
     {
         foreach (var ch in n.Children) tn.children.Add(ToTreeNode(ch));
     }
     return tn;
 }
Esempio n. 2
0
        public NavDirectory.Node GetUserNavMenu()
        {
            var nret = new NavDirectory.Node { Id = null, Label = "rroot" };

            var user = UserSessionContext.CurrentUserInfo;
            var lst = Db.Find<NavDirectory>(x => x.ACL.In(UserSessionContext.CurrentUserInfo.GetUserACL())).ToList();
            if (lst.Count == 0)
            {
                NavDirectory n = new NavDirectory { OwnerId = user.Id, Root = new NavDirectory.Node { Id = "root", Label = "root" } };
                Db.GetCollection<NavDirectory>().Save(n);
                lst.Add(n);
            }
            lst.ForEach(x => {
                if (nret.Children == null) nret.Children = new List<NavDirectory.Node>();
                nret.Children.Add(new NavDirectory.Node
                {
                    Id = x.Id + "/" + x.Root.Id,
                    Label = x.Root.Label,
                    Ref = x.Root.Ref,
                    RefType = x.Root.RefType,
                    Children = x.Root.Children
                });
            });
            return nret;
        }