public static IEnumerable <WorkItemDto> GetWorkItemsFromTeamBuilds(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, IEnumerable <WorkItemSummaryDto> workItems) { if (tfsConfigurationServer == null) { throw new ArgumentNullException("tfsConfigurationServer"); } if (workItems == null) { throw new ArgumentNullException("workItems"); } TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId); WorkItemStore workItemStore = tfsTeamProjectCollection.GetService <WorkItemStore>(); WorkItemDtoCollection workItemDtoCollection = new WorkItemDtoCollection(); foreach (WorkItemSummaryDto workItemSummaryDto in workItems) { WorkItem workItem = workItemStore.GetWorkItem(workItemSummaryDto.Id); WorkItemDto workItemDto = WorkItemDto.CreateFromWorkItem(workItem, workItemSummaryDto.AssociatedBuildNumber); workItemDtoCollection.Add(workItemDto); } return(workItemDtoCollection); }
public static WorkItemDtoCollection GetWorkItemsFromTeamBuilds(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, Uri[] teamBuildUris) { if (tfsConfigurationServer == null) { throw new ArgumentNullException("tfsConfigurationServer"); } TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId); IBuildServer buildServer = tfsTeamProjectCollection.GetService <IBuildServer>(); WorkItemStore workItemStore = tfsTeamProjectCollection.GetService <WorkItemStore>(); IBuildDetail[] buildDetails = buildServer.QueryBuildsByUri(teamBuildUris, new[] { InformationTypes.AssociatedWorkItem }, QueryOptions.Definitions); Dictionary <int, WorkItemDto> workItems = new Dictionary <int, WorkItemDto>(); foreach (IBuildDetail buildDetail in buildDetails) { List <IWorkItemSummary> workItemSummaries = InformationNodeConverters.GetAssociatedWorkItems(buildDetail); foreach (IWorkItemSummary workItemSummary in workItemSummaries) { if (!workItems.ContainsKey(workItemSummary.WorkItemId)) { WorkItem workItem = workItemStore.GetWorkItem(workItemSummary.WorkItemId); WorkItemDto workItemDto = WorkItemDto.CreateFromWorkItem(workItem, buildDetail.BuildNumber); workItems.Add(workItem.Id, workItemDto); } } } WorkItemDtoCollection workItemDtoCollection = new WorkItemDtoCollection(); foreach (KeyValuePair <int, WorkItemDto> keyValuePair in workItems) { workItemDtoCollection.Add(keyValuePair.Value); } return(workItemDtoCollection); }
public static IEnumerable<WorkItemDto> GetWorkItemsFromTeamBuilds(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, IEnumerable<WorkItemSummaryDto> workItems) { if (tfsConfigurationServer == null) { throw new ArgumentNullException("tfsConfigurationServer"); } if (workItems == null) { throw new ArgumentNullException("workItems"); } TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId); WorkItemStore workItemStore = tfsTeamProjectCollection.GetService<WorkItemStore>(); WorkItemDtoCollection workItemDtoCollection = new WorkItemDtoCollection(); foreach (WorkItemSummaryDto workItemSummaryDto in workItems) { WorkItem workItem = workItemStore.GetWorkItem(workItemSummaryDto.Id); WorkItemDto workItemDto = WorkItemDto.CreateFromWorkItem(workItem, workItemSummaryDto.AssociatedBuildNumber); workItemDtoCollection.Add(workItemDto); } return workItemDtoCollection; }
public static WorkItemDtoCollection GetWorkItemsFromTeamBuilds(this TfsConfigurationServer tfsConfigurationServer, Guid teamProjectCollectionId, Uri[] teamBuildUris) { if (tfsConfigurationServer == null) { throw new ArgumentNullException("tfsConfigurationServer"); } TfsTeamProjectCollection tfsTeamProjectCollection = tfsConfigurationServer.GetTeamProjectCollection(teamProjectCollectionId); IBuildServer buildServer = tfsTeamProjectCollection.GetService<IBuildServer>(); WorkItemStore workItemStore = tfsTeamProjectCollection.GetService<WorkItemStore>(); IBuildDetail[] buildDetails = buildServer.QueryBuildsByUri(teamBuildUris, new[] { InformationTypes.AssociatedWorkItem }, QueryOptions.Definitions); Dictionary<int, WorkItemDto> workItems = new Dictionary<int, WorkItemDto>(); foreach (IBuildDetail buildDetail in buildDetails) { List<IWorkItemSummary> workItemSummaries = InformationNodeConverters.GetAssociatedWorkItems(buildDetail); foreach (IWorkItemSummary workItemSummary in workItemSummaries) { if (!workItems.ContainsKey(workItemSummary.WorkItemId)) { WorkItem workItem = workItemStore.GetWorkItem(workItemSummary.WorkItemId); WorkItemDto workItemDto = WorkItemDto.CreateFromWorkItem(workItem, buildDetail.BuildNumber); workItems.Add(workItem.Id, workItemDto); } } } WorkItemDtoCollection workItemDtoCollection = new WorkItemDtoCollection(); foreach (KeyValuePair<int, WorkItemDto> keyValuePair in workItems) { workItemDtoCollection.Add(keyValuePair.Value); } return workItemDtoCollection; }