Ejemplo n.º 1
0
        private List <TreeViewNode> RecursiveChild(
            MenuPrefixNode orgPrefixNode,
            string parentKey,
            Dictionary <string, AuthItem> authItemColl)
        {
            //準備回傳的
            List <TreeViewNode> retColl = new List <TreeViewNode>();

            if (orgPrefixNode.MenuNodeCollection == null)
            {
                orgPrefixNode.MenuNodeCollection = new List <MenuControllerNode>();
            }


            //進入點
            var entryNodeColl = new List <TreeViewNode>();

            foreach (MenuControllerNode groupController in orgPrefixNode.MenuNodeCollection)
            {
                entryNodeColl.Add(ToNode(groupController, orgPrefixNode.Name, true, authItemColl));
            }



            TreeViewNode root = ToNode(orgPrefixNode, parentKey);

            if (entryNodeColl.Count >= 1)
            {
                root.nodes = entryNodeColl;
            }

            if (orgPrefixNode.Child != null)
            {
                foreach (MenuPrefixNode childItem in orgPrefixNode.Child)
                {
                    var childNodeColl = RecursiveChild(childItem, orgPrefixNode.Name, authItemColl);


                    if (root.nodes == null)
                    {
                        root.nodes = childNodeColl;
                    }
                    else
                    {
                        root.nodes.AddRange(childNodeColl);
                    }
                }
            }


            if (root.nodes != null && root.nodes.Count >= 1)
            {
                retColl.Add(root);
            }



            return(retColl);
        }
        private DynamicNode ToNode(MenuPrefixNode prefix, string parentKey)
        {
            var ret = new DynamicNode(prefix.Name, parentKey, prefix.Name, prefix.Description);

            ret.Clickable = false;
            ret.Attributes.Add("IconCss", prefix.IconCss ?? "icon-double-angle-right");
            return(ret);
        }
Ejemplo n.º 3
0
        private TreeViewNode ToNode(MenuPrefixNode prefix, string parentKey)
        {
            var ret = new TreeViewNode(prefix.Name, prefix.Name, false, null);

            return(ret);
        }
        private List <DynamicNode> RecursiveChild(
            MenuPrefixNode orgPrefixNode,
            string parentKey,
            Dictionary <string, AuthItem> authItemColl)
        {
            //準備回傳的
            List <DynamicNode> retColl = new List <DynamicNode>();

            if (orgPrefixNode.MenuNodeCollection == null)
            {
                orgPrefixNode.MenuNodeCollection = new List <MenuControllerNode>();
            }

            var parentDynamicNodeColl = new List <DynamicNode>();

            foreach (MenuControllerNode groupController in orgPrefixNode.MenuNodeCollection)
            {
                //使用者有權限
                if (authItemColl.ContainsKey(groupController.GroupName))
                {
                    var childDynamicNodeColl = new List <DynamicNode>();

                    //細項
                    foreach (var actionNode in groupController.subNode)
                    {
                        childDynamicNodeColl.Add(ToNode(actionNode, groupController.Name, true));
                    }

                    parentDynamicNodeColl.Add(ToNode(groupController, orgPrefixNode.Name, false));

                    //有明細才要加入parentNode
                    if (childDynamicNodeColl.Count >= 1)
                    {
                        parentDynamicNodeColl.AddRange(childDynamicNodeColl);
                    }
                }
            }

            if (parentDynamicNodeColl.Count >= 1)
            {
                retColl.AddRange(parentDynamicNodeColl);
            }



            if (orgPrefixNode.Child != null)
            {
                foreach (MenuPrefixNode childItem in orgPrefixNode.Child)
                {
                    var childNodeColl = RecursiveChild(childItem, orgPrefixNode.Name, authItemColl);
                    if (childNodeColl.Count >= 1)
                    {
                        retColl.AddRange(childNodeColl);
                    }
                }
            }

            if (retColl.Count >= 1)
            {
                retColl.Add(ToNode(orgPrefixNode, parentKey));
            }


            return(retColl);
        }