private static IBuildDetail Arrange(MockRepository mockRepository, IEnumerable <string> existingBuildNumbers) { IBuildDetail mockBuildDetailForCurrentBuild = mockRepository.DynamicMock <IBuildDetail>(); IBuildServer mockBuildServer = mockRepository.DynamicMock <IBuildServer>(); IBuildDetailSpec mockBuildDetailSpec = mockRepository.DynamicMock <IBuildDetailSpec>(); IBuildQueryResult mockBuildQueryResult = mockRepository.DynamicMock <IBuildQueryResult>(); ArrayList previousBuildsList = new ArrayList(); foreach (string existingBuildNumber in existingBuildNumbers) { IBuildDetail mockBuildDetailForPreviousBuild = mockRepository.DynamicMock <IBuildDetail>(); previousBuildsList.Add(mockBuildDetailForPreviousBuild); Expect.Call(mockBuildDetailForPreviousBuild.BuildNumber).Return(existingBuildNumber); } IBuildDetail[] previousBuilds = (IBuildDetail[])previousBuildsList.ToArray(typeof(IBuildDetail)); mockRepository.Record(); Expect.Call(mockBuildDetailForCurrentBuild.BuildServer).Return(mockBuildServer); Expect.Call(mockBuildDetailForCurrentBuild.TeamProject).Return("TeamProjectName"); Expect.Call(mockBuildServer.CreateBuildDetailSpec("TeamProjectName")).Return(mockBuildDetailSpec); Expect.Call(mockBuildServer.QueryBuilds(mockBuildDetailSpec)).Return(mockBuildQueryResult); Expect.Call(mockBuildQueryResult.Builds).Return(previousBuilds); return(mockBuildDetailForCurrentBuild); }
public async Task RefreshAsync() { try { IsBusy = true; var contextManager = (ITeamFoundationContextManager)m_ServiceProvider.GetService(typeof(ITeamFoundationContextManager)); var buildService = (IVsTeamFoundationBuild)m_ServiceProvider.GetService(typeof(IVsTeamFoundationBuild)); var buildServer = buildService.BuildServer; var buildDetailSpec = buildServer.CreateBuildDetailSpec(contextManager.CurrentContext.TeamProjectName); buildDetailSpec.Status = BuildStatus.All ^ BuildStatus.InProgress ^ BuildStatus.NotStarted; //Only completed builds buildDetailSpec.MinFinishTime = DateTime.Now.AddHours(-1); //Performance optimizations buildDetailSpec.InformationTypes = new string[] { }; buildDetailSpec.QueryOptions = QueryOptions.None; IBuildQueryResult buildQueryResult = null; await Task.Run(() => { buildQueryResult = buildServer.QueryBuilds(buildDetailSpec); }); View.RecentlyCompletedBuildCount = buildQueryResult.Builds.Length; } finally { IsBusy = false; } }
public static TeamBuildDtoCollection GetTeamBuilds(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, string teamProjectName, IEnumerable <string> teamBuildDefinitionNames) { if (tfsConfigurationServer == null) { throw new ArgumentNullException("tfsConfigurationServer"); } if (teamBuildDefinitionNames == null) { throw new ArgumentNullException("teamBuildDefinitionNames"); } TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId); IBuildServer buildServer = tfsTeamProjectCollection.GetService <IBuildServer>(); TeamBuildDtoCollection teamBuildDtoCollection = new TeamBuildDtoCollection(); foreach (string teamBuildDefinitionName in teamBuildDefinitionNames) { IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec(teamProjectName, teamBuildDefinitionName); buildDetailSpec.Reason = BuildReason.All; buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; buildDetailSpec.QueryDeletedOption = QueryDeletedOption.ExcludeDeleted; IBuildQueryResult buildQueryResult = buildServer.QueryBuilds(buildDetailSpec); foreach (IBuildDetail buildDetail in buildQueryResult.Builds) { TeamBuildDto teamBuildDto = new TeamBuildDto(); teamBuildDto.BuildNumber = buildDetail.BuildNumber; teamBuildDto.Uri = buildDetail.Uri; teamBuildDto.DefinitionName = teamBuildDefinitionName; teamBuildDtoCollection.Add(teamBuildDto); } } return(teamBuildDtoCollection); }
public static void FeedBuildDefinition(ICollection <BuildDefinition> collection, IBuildServer bs, string projectName) { IBuildDefinition[] buildDefinitions = bs.QueryBuildDefinitions(projectName); foreach (IBuildDefinition buildDefinition in buildDefinitions) { IBuildDetailSpec buildDetailSpec = bs.CreateBuildDetailSpec(buildDefinition); buildDetailSpec.QueryDeletedOption = QueryDeletedOption.ExcludeDeleted; buildDetailSpec.MaxBuildsPerDefinition = 1; buildDetailSpec.Reason = BuildReason.All;; buildDetailSpec.Status = BuildStatus.Failed; buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; buildDetailSpec.MinFinishTime = DateTime.Now.AddMonths(-1); IBuildQueryResult overallBuildDetailsQueryResults = bs.QueryBuilds(buildDetailSpec); IBuildDetail[] buildDetails = bs.QueryBuilds(buildDefinition); int failedOrPartialCount = buildDetails.Count(x => x.Status == BuildStatus.Failed || x.Status == BuildStatus.PartiallySucceeded); IBuildDetail lastFailedBuild = buildDetails.Where(x => x.Status == BuildStatus.Failed).OrderBy(x => x.FinishTime).LastOrDefault(); IBuildDetail lastSucceededBuild = buildDetails.Where(x => x.Status == BuildStatus.Succeeded).OrderBy(x => x.FinishTime).LastOrDefault(); int buildCount = buildDetails.Count(); BuildDefinition buildDef = new BuildDefinition() { Name = buildDefinition.Name, Enabled = buildDefinition.Enabled, ContinuousIntegrationType = buildDefinition.ContinuousIntegrationType.ToString(), FailedOrPartialRatio = buildCount != 0 ? failedOrPartialCount / buildCount : 0, RetainedBuild = buildCount, LastSuccess = lastSucceededBuild != null ? lastSucceededBuild.FinishTime : DateTime.MinValue, LastFail = lastFailedBuild != null ? lastFailedBuild.FinishTime : DateTime.MinValue }; collection.Add(buildDef); } }
public void SetUp() { this.buildServerMock = MockRepository.GenerateMock <IBuildServer>(); this.buildDetailSpecMock = MockRepository.GenerateMock <IBuildDetailSpec>(); this.buildQueryResultMock = MockRepository.GenerateMock <IBuildQueryResult>(); this.communicator = new BuildCommunicator("http://www.tfs.com"); this.communicator.buildServer = buildServerMock; }
public static IBuildDetail GetBuild(string teamProject, string buildNumber) { IBuildDetailSpec buildDetailSpec = BuildServer.CreateBuildDetailSpec(teamProject); buildDetailSpec.BuildNumber = buildNumber; IBuildQueryResult buildQueryResult = BuildServer.QueryBuilds(buildDetailSpec); return(buildQueryResult.Builds.Length == 1 ? buildQueryResult.Builds[0] : null); }
private void GetLatestInfo() { this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Getting Latest Build Information for: {0}", this.BuildDefinitionName)); IBuildDetailSpec buildDetailSpec = this.buildServer.CreateBuildDetailSpec(this.TeamProject); if (this.BuildDefinitionName != null) { buildDetailSpec.DefinitionSpec.Name = this.BuildDefinitionName; } // Only get latest buildDetailSpec.MaxBuildsPerDefinition = 1; buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; if (!string.IsNullOrEmpty(this.Status)) { this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Filtering on Status: {0}", this.Status)); buildDetailSpec.Status = (BuildStatus)System.Enum.Parse(typeof(BuildStatus), this.buildStatus); } // do the search and extract the details from the singleton expected result IBuildQueryResult results = this.buildServer.QueryBuilds(buildDetailSpec); if (results.Failures.Length == 0 && results.Builds.Length >= 1) { this.buildDetails = results.Builds[0]; ITaskItem ibuildDef = new TaskItem(this.BuildDefinitionName); ibuildDef.SetMetadata("BuildDefinitionUri", this.buildDetails.BuildDefinitionUri.ToString()); ibuildDef.SetMetadata("BuildFinished", this.buildDetails.BuildFinished.ToString()); ibuildDef.SetMetadata("BuildNumber", this.buildDetails.BuildNumber ?? string.Empty); ibuildDef.SetMetadata("BuildUri", this.buildDetails.Uri.ToString()); ibuildDef.SetMetadata("CompilationStatus", this.buildDetails.CompilationStatus.ToString()); ibuildDef.SetMetadata("CompilationSuccess", this.buildDetails.CompilationStatus == BuildPhaseStatus.Succeeded ? "true" : "false"); ibuildDef.SetMetadata("DropLocation", this.buildDetails.DropLocation ?? string.Empty); ibuildDef.SetMetadata("FinishTime", this.buildDetails.FinishTime.ToString()); ibuildDef.SetMetadata("KeepForever", this.buildDetails.KeepForever.ToString()); ibuildDef.SetMetadata("LabelName", this.buildDetails.LabelName ?? string.Empty); ibuildDef.SetMetadata("LastChangedBy", this.buildDetails.LastChangedBy ?? string.Empty); ibuildDef.SetMetadata("LastChangedOn", this.buildDetails.LastChangedOn.ToString()); ibuildDef.SetMetadata("LogLocation", this.buildDetails.LogLocation ?? string.Empty); ibuildDef.SetMetadata("Quality", this.buildDetails.Quality ?? string.Empty); ibuildDef.SetMetadata("Reason", this.buildDetails.Reason.ToString()); ibuildDef.SetMetadata("RequestedBy", this.buildDetails.RequestedBy ?? string.Empty); ibuildDef.SetMetadata("RequestedFor", this.buildDetails.RequestedFor ?? string.Empty); ibuildDef.SetMetadata("SourceGetVersion", this.buildDetails.SourceGetVersion ?? string.Empty); ibuildDef.SetMetadata("StartTime", this.buildDetails.StartTime.ToString() ?? string.Empty); ibuildDef.SetMetadata("Status", this.buildDetails.Status.ToString() ?? string.Empty); ibuildDef.SetMetadata("TestStatus", this.buildDetails.TestStatus.ToString() ?? string.Empty); ibuildDef.SetMetadata("TestSuccess", this.buildDetails.TestStatus == BuildPhaseStatus.Succeeded ? "true" : "false"); this.Info = ibuildDef; this.BuildUri = this.buildDetails.Uri.ToString(); } }
async Task <IBuildDetail[]> SearchBuilds(IBuildDefinition buildDef) { List <IBuildDetail> builds = new List <IBuildDetail>(); await Task.Run(() => { IBuildDetailSpec buildDetailSpec = TfsShared.Instance.BuildServer.CreateBuildDetailSpec(buildDef); buildDetailSpec.QueryDeletedOption = SelectedQueryDeletedOption; buildDetailSpec.QueryOptions = SelectedQueryOption; IBuildQueryResult result = TfsShared.Instance.BuildServer.QueryBuilds(buildDetailSpec); builds = result.Builds.ToList(); }); return(builds.ToArray()); }
public string GetLatestBuildNumberFromAllBuildDefinitions(string teamProjectName) { IBuildDetailSpec buildDetailSpec = this.buildServer.CreateBuildDetailSpec(teamProjectName); buildDetailSpec.Reason = BuildReason.All; buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; buildDetailSpec.QueryDeletedOption = QueryDeletedOption.IncludeDeleted; buildDetailSpec.MaxBuildsPerDefinition = 1; IBuildQueryResult buildQueryResult = this.buildServer.QueryBuilds(buildDetailSpec); if (buildQueryResult.Builds.Length < 1) { return(null); } return(buildQueryResult.Builds[0].BuildNumber); }
private void updateBuildNumber(int testPlanId) { //Define the variables string serverurl = Collection; Uri configurationServerUri = new Uri(serverurl); string project = _ProjectName; int myPlansId = testPlanId; try { //Get the build uri needed from build number TfsTeamProjectCollection tfsserv = new TfsTeamProjectCollection(configurationServerUri); Uri buildUri = null; IBuildServer buildServer = (IBuildServer)tfsserv.GetService(typeof(IBuildServer)); IBuildDetailSpec detailSpec = buildServer.CreateBuildDetailSpec(project); detailSpec.MaxBuildsPerDefinition = 1; detailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; IBuildQueryResult results = buildServer.QueryBuilds(detailSpec); if (results.Builds.Length == 1) { IBuildDetail detail = results.Builds[0]; buildUri = detail.Uri; } //Update the test plan ITestManagementTeamProject proj = GetProject(serverurl, project); ITestPlan plan = proj.TestPlans.Find(myPlansId); Console.WriteLine("Test Plan: {0}", plan.Name); Console.WriteLine("Plan ID: {0}", plan.Id); Console.WriteLine("Previous Build Uri: {0}", plan.PreviousBuildUri); Console.WriteLine("Build Currently In Use: {0}", plan.BuildNumber); plan.BuildUri = buildUri; Console.WriteLine("\n Build updated in Test Plan \n"); Console.WriteLine("Build Currently In Use: {0}", plan.BuildNumber); plan.Save(); } catch (Exception e) { Console.WriteLine("\n There was an error \n"); Console.WriteLine(e); } }
private static Build GetBuild(IBuildQueryResult result) { var buildDetail = result.Builds[0]; Build webApiBuild = new Build { BuildNumber = buildDetail.BuildNumber, Uri = buildDetail.Uri, FinishTime = buildDetail.FinishTime, StartTime = buildDetail.StartTime, RequestedFor = new Microsoft.VisualStudio.Services.WebApi.IdentityRef(), Status = BuildStatusConverter.Convert(buildDetail.Status), Result = BuildStatusConverter.ConvertToBuildResult(buildDetail.Status) }; webApiBuild.RequestedFor.DisplayName = buildDetail.RequestedFor; return(webApiBuild); }
/// <summary> /// Get the label details. /// </summary> protected override void InternalExecute() { var buildServer = this.BuildServer.Get(this.ActivityContext); var teamProject = this.TeamProject.Get(this.ActivityContext); var buildName = this.BuildName.Get(this.ActivityContext); // Create a build spec to find the latest build IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec(teamProject, buildName); buildDetailSpec.MaxBuildsPerDefinition = 1; buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; // Query the build server for the latest build IBuildQueryResult results = buildServer.QueryBuilds(buildDetailSpec); // Return the build this.BuildDetail.Set(this.ActivityContext, results.Builds[0]); }
public string[] GetLatestBuildNumbersFromAllBuildDefinitions(string teamProjectName, int numberOfBuildNumbersToRetrieve) { IBuildDetailSpec buildDetailSpec = this.buildServer.CreateBuildDetailSpec(teamProjectName); buildDetailSpec.Reason = BuildReason.All; buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; buildDetailSpec.QueryDeletedOption = QueryDeletedOption.IncludeDeleted; buildDetailSpec.MaxBuildsPerDefinition = numberOfBuildNumbersToRetrieve; IBuildQueryResult buildQueryResult = this.buildServer.QueryBuilds(buildDetailSpec); ArrayList buildNumberList = new ArrayList(numberOfBuildNumbersToRetrieve); for (int i = 0; i < numberOfBuildNumbersToRetrieve && i < buildQueryResult.Builds.Length; i++) { buildNumberList.Add(buildQueryResult.Builds[i].BuildNumber); } return((string[])buildNumberList.ToArray(typeof(string))); }
private IBuildDetail GetGoodBuild() { IBuildDefinition buildDef = this.bs.GetBuildDefinition(this.teamProject, this.buildDefinition); IBuildDetailSpec buildDetailSpec = this.bs.CreateBuildDetailSpec(buildDef); buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; buildDetailSpec.Status = BuildStatus.Succeeded; if (!string.IsNullOrEmpty(this.buildQuality)) { buildDetailSpec.Quality = this.buildQuality; } IBuildQueryResult builds = this.bs.QueryBuilds(buildDetailSpec); IBuildDetail latestBuild = builds.Builds.FirstOrDefault(); return(latestBuild); }
/// <summary> /// Gets the latest build number /// </summary> /// <param name="projectName"></param> /// <returns></returns> public string GetLatestBuildNumber() { (new Logger()) .SetMessage("Querying build definitions.") .SetLoggingType(Logger.Type.Information) .Display(); IBuildServer buildServer = this.projectCollection.GetService <IBuildServer>(); IBuildDetailSpec buildSpec = buildServer.CreateBuildDetailSpec(projectName); buildSpec.MaxBuildsPerDefinition = 1; buildSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; IBuildQueryResult query = buildServer.QueryBuilds(buildSpec); if (query.Builds.Count() == 0) { return(null); } IBuildDetail detail = query.Builds[0]; return(detail.BuildNumber); }
private IBuildDetail GetBuildDetail(string buildId) { if (buildId == Context.BUILD_NONE) { return(null); } IBuildDetailSpec buildDetailSpec = Context.BuildServer.CreateBuildDetailSpec(this.teamProject); buildDetailSpec.BuildNumber = buildId; IBuildQueryResult buildQueryResult = Context.BuildServer.QueryBuilds(buildDetailSpec); IBuildDetail buildDetail = buildQueryResult.Builds[0]; bool queueBuild = false; // if (queueBuild) // { // IBuildRequest request = buildDetail.BuildDefinition.CreateBuildRequest(); // request.Priority = QueuePriority.AboveNormal; // request.CommandLineArguments = "/p:ExtParamA=\"Toto je test\""; // Context.BuildServer.QueueBuild(request); // } return(buildDetail); }
/// <summary> /// Rets the last two builds for all build definitions matching the passe din parameters /// </summary> /// <param name="teamProject">the team project to uery against</param> /// <param name="buildDefinitionPattern">optional build definition pattern</param> /// <returns>build result pairs</returns> public TfsLastTwoBuildResults[] GetLastTwoBuilds(TeamProject teamProject, string buildDefinitionPattern) { log.Debug("Finding build results for definition pattern " + buildDefinitionPattern); IBuildDetailSpec buildDetailsQuerySpec; if (buildDefinitionPattern != null) { buildDetailsQuerySpec = this.Connection.BuildServer.CreateBuildDetailSpec(teamProject.Name, buildDefinitionPattern); } else { buildDetailsQuerySpec = this.Connection.BuildServer.CreateBuildDetailSpec(teamProject.Name); } //// Failure to set this property results in ALL of the build information being retrieved resulting in 10X+ call times //// You can retrieve subsets with something like //// buildDetailsQuerySpec.InformationTypes = new string[] { "ActivityTracking", "AgentScopeActivityTracking" }; buildDetailsQuerySpec.InformationTypes = null; //// last and previous buildDetailsQuerySpec.MaxBuildsPerDefinition = 2; //// use start time descending because InProgress builds don't seem to sort correctly when using EndTimeDescending buildDetailsQuerySpec.QueryOrder = BuildQueryOrder.StartTimeDescending; IBuildQueryResult buildResults = this.Connection.BuildServer.QueryBuilds(buildDetailsQuerySpec); IDictionary <string, TfsLastTwoBuildResults> results = new SortedDictionary <string, TfsLastTwoBuildResults>(); //// create placeholder result objects, one for each build, that we will fill with results foreach (IBuildDetail oneDetail in buildResults.Builds) { if (!results.ContainsKey(oneDetail.BuildDefinition.Name)) { results.Add(oneDetail.BuildDefinition.Name, new TfsLastTwoBuildResults(oneDetail.BuildDefinition, null, null)); } } //// now fill the results. //// The builds are in reverse start time order so the last build shold always be first putting it in the last build slot foreach (IBuildDetail oneDetail in buildResults.Builds) { TfsLastTwoBuildResults corresponding = results[oneDetail.BuildDefinition.Name]; //// sorted by start time descending so latest should always come first if (corresponding.LastBuild == null) { corresponding.LastBuild = oneDetail; } else { corresponding.PreviousBuild = oneDetail; } } if (log.IsDebugEnabled) { foreach (string key in results.Keys) { TfsLastTwoBuildResults oneResult = results[key]; log.Debug(" " + oneResult.BuildDefinition.Name); log.Debug(" " + oneResult.LastBuild.BuildNumber + " " + oneResult.LastBuild.Status); if (oneResult.PreviousBuild != null) { log.Debug(" " + oneResult.PreviousBuild.BuildNumber + " " + oneResult.PreviousBuild.Status); } } } //// convert the dictionary to an array TfsLastTwoBuildResults[] resultsAsArray = new TfsLastTwoBuildResults[results.Values.Count]; results.Values.CopyTo(resultsAsArray, 0); return(resultsAsArray); }
public IList <BuildNumber> GetPromotableBuilds(int targetEnvironmentBuildNumber) { try { List <BuildNumber> promotableBuilds = new List <BuildNumber>(); IBuildDetailSpec buildSpec = Pipeline.Source.BuildServer.CreateBuildDetailSpec(BuildDefinition); buildSpec.InformationTypes = null; buildSpec.Status = BuildStatus.Succeeded; IBuildQueryResult buildDetails = Pipeline.Source.BuildServer.QueryBuilds(buildSpec); foreach (IBuildDetail buildDetail in buildDetails.Builds) { if (buildDetail.BuildFinished) { IDictionary <string, object> processParams = WorkflowHelpers.DeserializeProcessParameters(buildDetail.ProcessParameters); Build build = new Build(buildDetail); int visibleBuildNumber = build.Number; if (EnvironmentName == "Production") { string buildUriString = buildDetail.Uri.ToString(); string buildUri = buildUriString.Contains("?") ? buildUriString.Substring(0, buildUriString.IndexOf("?")) : buildUriString; string buildUriPrefix = buildUri.Substring(0, buildUri.LastIndexOf("/") + 1); Uri commitBuildUri = new Uri(string.Format("{0}{1}", buildUriPrefix, processParams["PriorBuild"] as string)); IBuildDetail commitBuildDetail = BuildDefinition.BuildServer.GetMinimalBuildDetails(commitBuildUri); IDictionary <string, object> commitProcessParams = WorkflowHelpers.DeserializeProcessParameters(commitBuildDetail.ProcessParameters); visibleBuildNumber = Int32.Parse((string)commitProcessParams["PriorBuild"]); } else if (EnvironmentName != "Commit") { visibleBuildNumber = Int32.Parse((string)processParams["PriorBuild"]); } if (targetEnvironmentBuildNumber > 0) { if (visibleBuildNumber > targetEnvironmentBuildNumber) { promotableBuilds.Add(new BuildNumber(build, visibleBuildNumber)); } } else { promotableBuilds.Add(new BuildNumber(build, visibleBuildNumber)); } } } return(promotableBuilds); } catch (Exception ex) { throw new Exception(string.Format("Unable to get builds from TFS, error message was:\n\n{0}", ex.Message)); } }
internal void PopulateTeamBuilds(bool refresh, bool resort, Action <IBuildDetailSpec> modifyAction) { ListViewCCH listView = GetTreeView(); listView.BeginUpdate(); BackupSelectedItems(); //if (refresh || this.lastSelectedTeamProjectIndex != this.parentControl.selectedTeamProjectIndex || !lastIsQueuedSelected.Equals(IsQueuedSelected)) if (refresh || this.lastAppliedFilterHashCode != UIContext.Instance.ControlTeamBuildFilter.LastAppliedFilterHashCode || !lastIsQueuedSelected.Equals(IsQueuedSelected)) { this.cachedBuilds = null; } if (this.cachedBuilds == null) { string[] checkedProjects = UIContext.Instance.ControlTeamBuildFilter.CheckedProjects; UIContext.Instance.ProgressBegin(checkedProjects.Length, 1); try { this.cachedBuilds = new Dictionary <bool, List <BuildInfo> > { { false, new List <BuildInfo>() }, { true, new List <BuildInfo>() } }; listView.Groups.Clear(); this.teamBuildQualities.Clear(); foreach (string teamProject in checkedProjects) { List <BuildInfo> buildDetails = new List <BuildInfo>(); if (IsQueuedSelected) { IQueuedBuildsView buildsView = Context.BuildServer.CreateQueuedBuildsView(teamProject); buildsView.QueryOptions = QueryOptions.All; buildsView.StatusFilter = QueueStatus.All; buildsView.Refresh(true); IQueuedBuild[] queuedBuilds = buildsView.QueuedBuilds; foreach (var queuedBuild in queuedBuilds) { buildDetails.Add(new BuildInfo(queuedBuild)); } } else { IBuildDetailSpec buildDetailSpec = Context.BuildServer.CreateBuildDetailSpec(teamProject); buildDetailSpec.MaxBuildsPerDefinition = btnLatestBuilds.Checked ? 1 : int.MaxValue; buildDetailSpec.QueryOrder = BuildQueryOrder.StartTimeDescending; buildDetailSpec.Status = BuildStatus.Failed | BuildStatus.NotStarted | BuildStatus.PartiallySucceeded | BuildStatus.Stopped | BuildStatus.Succeeded; if (modifyAction != null) { modifyAction(buildDetailSpec); } IBuildQueryResult builds = Context.BuildServer.QueryBuilds(buildDetailSpec); foreach (var buildDetail in builds.Builds) { buildDetails.Add(new BuildInfo(buildDetail)); } } if (this.cachedBuilds.ContainsKey(this.IsQueuedSelected)) { List <BuildInfo> cachedBuildItems = this.cachedBuilds[this.IsQueuedSelected]; foreach (var item in buildDetails) { cachedBuildItems.Add(item); } } else { this.cachedBuilds.Add(this.IsQueuedSelected, buildDetails); } //this.cachedBuilds.Add(IsQueuedSelected, cachedBuildItems); listView.Groups.Add(teamProject, teamProject); string[] buildQualities = Context.BuildServer.GetBuildQualities(teamProject); this.teamBuildQualities.Add(teamProject, new List <string>(buildQualities)); UIContext.Instance.ProgressDoStep(); } this.lastAppliedFilterHashCode = UIContext.Instance.ControlTeamBuildFilter.LastAppliedFilterHashCode; } finally { UIContext.Instance.ProgressEnd(); } } if (resort) { SortListData(); } listView.Visible = true; try { UIContext.Instance.ProgressBegin(this.cachedBuilds.Count, 1); listView.Items.Clear(); foreach (var cachedBuild in this.cachedBuilds[IsQueuedSelected]) { PopulateListItem(listView, cachedBuild); UIContext.Instance.ProgressDoStep(); } // this.cachedBuilds.ForEach(teamBuild => // { // ListViewItem viewItem = listView.Items.Add(teamBuild.Status.ToString()); // viewItem.UseItemStyleForSubItems = false; // viewItem.StateImageIndex = GetBuildStatusImage(teamBuild.Status); // viewItem.Tag = teamBuild; // viewItem.SubItems.Add(teamBuild.StartTime.ToString()); // viewItem.SubItems.Add(teamBuild.BuildNumber); // viewItem.SubItems.Add(teamBuild.BuildDefinition.Name); // viewItem.SubItems.Add(teamBuild.BuildAgent.Name); // viewItem.SubItems.Add(teamBuild.RequestedBy); // viewItem.SubItems.Add(teamBuild.Quality); // viewItem.SubItems.Add(teamBuild.FinishTime.ToString()); // // bool logFileExists = !string.IsNullOrEmpty(teamBuild.LogLocation) // && File.Exists(teamBuild.LogLocation); // // ListViewItem.ListViewSubItem subItem = viewItem.SubItems.Add(logFileExists ? "Has log" : "No log"); // subItem.ForeColor = logFileExists // ? Color.FromKnownColor(KnownColor.WindowText) : Color.FromKnownColor(KnownColor.ControlLight); // // viewItem.Group = listView.Groups[teamBuild.BuildDefinition.TeamProject]; // // UIContext.ProgressDoStep(); // }); } finally { listView.EndUpdate(); UIContext.Instance.ProgressEnd(); RestoreSelectedItems(); } }