Esempio n. 1
0
        public ActionResult WorkItems(Guid teamProjectCollectionId, string selectedTeamBuildUris)
        {
            if (string.IsNullOrEmpty(selectedTeamBuildUris))
            {
                throw new ArgumentNullException("selectedTeamBuildUris");
            }

            this.ViewData[ViewDataKey.TeamProjectCollectionId] = teamProjectCollectionId;
            string[]  selectedTeamBuildUrisList = selectedTeamBuildUris.Split(',');
            ArrayList arrayList = new ArrayList(selectedTeamBuildUrisList.Length);

            foreach (string selectedTeamBuildUri in selectedTeamBuildUrisList)
            {
                arrayList.Add(new Uri(selectedTeamBuildUri));
            }

            Uri[] uris = (Uri[])arrayList.ToArray(typeof(Uri));
            WorkItemDtoCollection workItemsFromTeamBuilds = GetTfsConfigurationServer().GetWorkItemsFromTeamBuilds(teamProjectCollectionId, uris);

            return(this.View(workItemsFromTeamBuilds));
        }
Esempio n. 2
0
        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;
        }