private static void FeedBuildMachineData(ICollection <BuildServiceHostDefinition> serverHosts, IBuildServer bs) { IBuildController[] controllers = bs.QueryBuildControllers(true); foreach (IBuildController controller in controllers) { BuildServiceHostDefinition buildServiceHostDefinitionForController = null; if (!serverHosts.Any(x => x.Name == controller.ServiceHost.Name)) { buildServiceHostDefinitionForController = new BuildServiceHostDefinition() { Name = controller.ServiceHost.Name, CollectionName = bs.TeamProjectCollection.Name }; serverHosts.Add(buildServiceHostDefinitionForController); } else { buildServiceHostDefinitionForController = serverHosts.FirstOrDefault(x => x.Name == controller.ServiceHost.Name); } BuildControllerDefinition buildControllerDefinition = new BuildControllerDefinition() { Name = controller.Name, RDPUri = string.Format("rdp://{0}.{1}", buildServiceHostDefinitionForController.Name, Environment.GetEnvironmentVariable("RDPDomain", EnvironmentVariableTarget.User)), Status = controller.Status.ToString() }; buildServiceHostDefinitionForController.BuildControllers.Add(buildControllerDefinition); foreach (IBuildAgent agent in controller.Agents) { BuildServiceHostDefinition buildServiceHostDefinitionForAgent = null; if (!serverHosts.Any(x => x.Name == agent.ServiceHost.Name)) { buildServiceHostDefinitionForAgent = new BuildServiceHostDefinition() { Name = agent.ServiceHost.Name, CollectionName = bs.TeamProjectCollection.Name }; serverHosts.Add(buildServiceHostDefinitionForAgent); } else { buildServiceHostDefinitionForAgent = serverHosts.FirstOrDefault(x => x.Name == agent.ServiceHost.Name); } BuildAgentDefinition buildAgentDefinition = new BuildAgentDefinition() { Name = agent.Name, Status = agent.Status.ToString(), RDPUri = string.Format("rdp://{0}.{1}", buildServiceHostDefinitionForAgent.Name, Environment.GetEnvironmentVariable("RDPDomain", EnvironmentVariableTarget.User)) }; buildServiceHostDefinitionForAgent.BuildAgents.Add(buildAgentDefinition); } } }
private IBuildController GetBuildController(IBuildServer buildServer, string buildController) { if (string.IsNullOrEmpty(buildController)) { return(buildServer.QueryBuildControllers(false).First()); } return(buildServer.GetBuildController(buildController)); }
private void cboCollectionURL_SelectionChanged(object sender, SelectionChangedEventArgs e) { cboProject.Items.Clear(); cboBuildController.Items.Clear(); if (cboCollectionURL.SelectedItem != null) { ClientCollectionSource source = cboCollectionURL.SelectedItem as ClientCollectionSource; Uri collectionUri = null; TfsTeamProjectCollection collection = null; try { collectionUri = new Uri(source.Uri); collection = new TfsTeamProjectCollection(collectionUri); ICommonStructureService commonStructure = collection.GetService <ICommonStructureService>(); foreach (ProjectInfo project in commonStructure.ListProjects()) { cboProject.Items.Add(new ComboBoxItem() { Content = project.Name, DataContext = project.Name }); } } catch (Exception ex) { cboProject.Items.Clear(); cboBuildController.Items.Clear(); MessageBox.Show(ex.Message, string.Format("Error retrieving projects from {0}", collectionUri), MessageBoxButton.OK, MessageBoxImage.Error); return; } try { IBuildServer buildServer = collection.GetService <IBuildServer>(); foreach (IBuildController buildController in buildServer.QueryBuildControllers()) { cboBuildController.Items.Add(new ComboBoxItem() { Content = buildController.Name, DataContext = buildController.Name }); } } catch (Exception ex) { cboBuildController.Items.Clear(); MessageBox.Show(ex.Message, string.Format("Error retrieving build controllers from {0}", collectionUri), MessageBoxButton.OK, MessageBoxImage.Error); return; } } }
public List <BuildController> GetBuildControlles() { List <BuildController> lst = new List <BuildController>(); foreach (IBuildController bc in buildSrv.QueryBuildControllers()) { lst.Add(new BuildController { Name = bc.Name, Enabled = bc.Enabled, StatusMsg = bc.StatusMessage, Uri = bc.Uri }); } return(lst); }
internal static void Add_BuildControllers(XlHlp.XlLocation insertAt, Options_AZDO_TFS options, IBuildServer buildServer, TeamProject teamProject) { Int64 startTicks = Log.APPLICATION("Enter", Common.LOG_CATEGORY); var buildControllers = buildServer.QueryBuildControllers(); foreach (IBuildController buildController in buildControllers) { insertAt.ClearOffsets(); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), string.Format("{0}", buildController.Name)); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), string.Format("{0}", buildController.Description)); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), string.Format("{0}", buildController.Enabled)); XlHlp.AddOffsetContentToCell(insertAt.AddOffsetColumn(), string.Format("{0}", buildController.Agents.Count)); insertAt.IncrementRows(); } Log.APPLICATION("Exit", Common.LOG_CATEGORY, startTicks); }
private IBuildController GetBuildController(IBuildServer buildServer, string buildController) { if (string.IsNullOrEmpty(buildController)) return buildServer.QueryBuildControllers(false).First(); return buildServer.GetBuildController(buildController); }