コード例 #1
0
        public DirectedGraph GenerateGraph()
        {
            DirectedGraph dg = new DirectedGraph { Nodes = new List<DirectedGraphNode>() };
            var root = new DirectedGraphNode { Id = this.buildServer.TeamProjectCollection.Name, Label = this.buildServer.TeamProjectCollection.Name, Category1 = ProjectCollectionCategory };
            dg.Nodes.Add(root);
            dg.Links = new List<DirectedGraphLink>();
            var hosts = new List<DirectedGraphNode>();

            dg.Styles.Add(CreateStyle(BuildControllerCategory, BuildControllerCategoryLabel, "LightGreen"));
            dg.Styles.Add(CreateStyle(DisabledBuildControllerCategory, DisabledBuildControllerCategoryLabel, "Purple"));
            dg.Styles.Add(CreateStyle(ServiceHostCategory, ServiceHostCategoryLabel, "Yellow"));
            dg.Styles.Add(CreateStyle(BuildAgentCategory, BuildAgentCategoryLabel, "Green"));
            dg.Styles.Add(CreateStyle(DisabledBuildAgentCategory, DisabledBuildAgentCategoryLabel, "Red"));
            dg.Styles.Add(CreateStyle(ProjectCollectionCategory, ProjectCollectionCategoryLabel, "Orange"));
            dg.Styles.Add(CreateStyle(BuildAgentTagCategory, BuildAgentTagCategoryLabel, "LightBlue"));

            foreach (var controller in this.buildServer.QueryBuildControllers(true))
            {
                DirectedGraphNode hostNode;
                var host = controller.ServiceHost.Name;
                if (hosts.Any(h => h.Label == host))
                {
                    hostNode = hosts.First(h => h.Label == host);
                }
                else
                {
                    hostNode = CreateServiceHostNode(host, host);
                    hosts.Add(hostNode);
                    dg.Nodes.Add(hostNode);
                    var l = new DirectedGraphLink { Source = root.Label, Target = hostNode.Label };
                    dg.Links.Add(l);
                }

                var controllerNode = CreateControllerNode(controller);
                dg.Nodes.Add(controllerNode);

                var link = new DirectedGraphLink { Source = hostNode.Id, Target = controllerNode.Id, Category1 = "Contains" };
                dg.Links.Add(link);

                foreach (var a in controller.Agents)
                {
                    var agentNode = CreateBuildAgentNode(GetBuildAgentID(a), a.Name, a.Enabled);
                    host = a.ServiceHost.Name;

                    if (hosts.Any(h => h.Label == host))
                    {
                        hostNode = hosts.First(h => h.Label == host);
                        dg.Nodes.Add(agentNode);
                        link = new DirectedGraphLink { Source = controllerNode.Id, Target = agentNode.Id };
                        dg.Links.Add(link);
                    }
                    else
                    {
                        hostNode = CreateServiceHostNode(host, host);
                        dg.Nodes.Add(hostNode);
                        hosts.Add(hostNode);
                        dg.Nodes.Add(agentNode);
                        link = new DirectedGraphLink { Source = controllerNode.Id, Target = hostNode.Id };
                        dg.Links.Add(link);
                    }

                    link = new DirectedGraphLink { Source = hostNode.Id, Target = agentNode.Id, Category1 = "Contains" };
                    dg.Links.Add(link);

                    foreach (var tag in a.Tags)
                    {
                        var tagNode = CreateTagNode(tag);
                        dg.Nodes.Add(tagNode);
                        link = new DirectedGraphLink { Source = agentNode.Id, Target = tagNode.Id, Category1 = "Contains" };
                        dg.Links.Add(link);
                    }
                }
            }

            return dg;
        }
コード例 #2
0
 public static bool LoadFromFile(string fileName, out DirectedGraph obj)
 {
     System.Exception exception = null;
     return LoadFromFile(fileName, out obj, out exception);
 }
コード例 #3
0
 public static bool LoadFromFile(string fileName, out DirectedGraph obj, out System.Exception exception)
 {
     return LoadFromFile(fileName, Encoding.UTF8, out obj, out exception);
 }
コード例 #4
0
 public static bool LoadFromFile(string fileName, System.Text.Encoding encoding, out DirectedGraph obj, out System.Exception exception)
 {
     exception = null;
     obj = default(DirectedGraph);
     try
     {
         obj = LoadFromFile(fileName, encoding);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }
コード例 #5
0
 public static bool Deserialize(string xml, out DirectedGraph obj)
 {
     System.Exception exception = null;
     return Deserialize(xml, out obj, out exception);
 }
コード例 #6
0
 public static bool Deserialize(string xml, out DirectedGraph obj, out System.Exception exception)
 {
     exception = null;
     obj = default(DirectedGraph);
     try
     {
         obj = Deserialize(xml);
         return true;
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return false;
     }
 }