예제 #1
0
        private void BindHierarchies()
        {
            // Get all hierarchies on root level.
            List <object[]> hierarchies = Global.Core.Hierarchies.GetValues(
                new string[] { "Id", "Name" },
                new string[] { "IdHierarchy" },
                new object[] { null }
                );

            treeView = new WebUtilities.Controls.TreeView("tvHierarchies");

            // Run through all hierarchies on root level.
            foreach (object[] hierarchy in hierarchies)
            {
                TreeViewNode node = RenderHierarchyTreeViewNode(
                    treeView,
                    hierarchy,
                    ""
                    );
                node.Attributes.Add("id", "tnHierarchy" + hierarchy[0]);

                treeView.Nodes.Add(node);

                Page.ClientScript.RegisterStartupScript(
                    this.GetType(),
                    "LoadHierarchyVariables" + hierarchy[0],
                    "LoadVariables(document.getElementById('cphContent__tvnHierarchy" + hierarchy[0] + "'), '" + hierarchy[0] + "');",
                    true
                    );
            }

            pnlHierarchies.Controls.Add(treeView);
        }
예제 #2
0
        private TreeViewNode RenderHierarchyTreeViewNode(WebUtilities.Controls.TreeView treeView, object[] hierarchy, string path)
        {
            path += "/" + (string)hierarchy[1];

            // Create a new tree view node for
            // the hierarchy on root level.
            TreeViewNode node = new TreeViewNode(treeView, "tvnHierarchy" + hierarchy[0].ToString(), "");

            node.CssClass = "BackgroundColor5";
            node.Label    = (string)hierarchy[1];

            node.Attributes.Add(
                "Path",
                path
                );
            node.OnClientClick = string.Format(
                "LoadVariables(this, '{0}');",
                hierarchy[0]
                );

            // Get all hierarchies of the workgroups where the user
            // is assigned to where the hierarchy is the parent.
            List <object[]> childHierarchies = Global.Core.Hierarchies.ExecuteReader(string.Format(
                                                                                         "SELECT Id, Name FROM [Hierarchies] WHERE IdHierarchy='{1}' AND Id IN (SELECT IdHierarchy FROM WorkgroupHierarchies " +
                                                                                         "WHERE IdWorkgroup IN (SELECT IdWorkgroup FROM UserWorkgroups WHERE IdUser='******'))",
                                                                                         Global.IdUser.Value,
                                                                                         hierarchy[0]
                                                                                         ));

            // Run through all available child hierarchies of the hierarchy.
            foreach (object[] childHierarchy in childHierarchies)
            {
                node.AddChild(RenderHierarchyTreeViewNode(
                                  treeView,
                                  childHierarchy,
                                  path
                                  ));
            }

            return(node);
        }