예제 #1
0
 internal WorkItemCollectionEnumerator(WIT.WorkItemCollection collection)
 {
     if (typeof(T) != typeof(WIT.WorkItem))
     {
         throw new NotImplementedException();
     }
     workItemCollectionEnumerator = collection.GetEnumerator();
 }
예제 #2
0
        private List <WorkItemNode> WalkLinks(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemCollection workItemCollection, WorkItemLinkInfo[] workItemLinks, WorkItemNode current)
        {
            var currentId = 0;

            if (current != null)
            {
                currentId = current.Item.Id;
            }

            var workItems = (from linkInfo in workItemLinks
                             where linkInfo.SourceId == currentId
                             select new WorkItemNode()
            {
                Item = workItemCollection[workItemCollection.IndexOf(linkInfo.TargetId)],
            }).ToList();

            workItems.ForEach(w => w.Children = WalkLinks(workItemCollection, workItemLinks, w));
            return(workItems);
        }
예제 #3
0
 public WorkItemEnumerator(WIT.WorkItemCollection collection)
 {
     this.collection = collection;
 }
예제 #4
0
        public QueryResult Execute(WorkItemStore workItemStore, TFSQuery tfsQuery, Duration durationFilter, bool dayPrecision)
        {
            var queryResults = new QueryResult();
            // get the query
            var queryDefinition = new QueryDefinition(Guid.NewGuid().ToString(), tfsQuery.QueryString);
            var query           = new Query(workItemStore, tfsQuery.QueryString, tfsQuery.Context, dayPrecision);

            if (queryDefinition.QueryType == QueryType.OneHop || queryDefinition.QueryType == QueryType.Tree)
            {
                var workItemLinks = query.RunLinkQuery();

                int[] ids = (from WorkItemLinkInfo info in workItemLinks
                             select info.TargetId).ToArray();

                //
                // Next we want to create a new query that will retrieve all the column values from the original query, for
                // each of the work item IDs returned by the original query.
                //
                var detailsWiql = new StringBuilder();
                detailsWiql.AppendLine("SELECT");
                bool first = true;

                foreach (FieldDefinition field in query.DisplayFieldList)
                {
                    detailsWiql.Append(" ");
                    if (!first)
                    {
                        detailsWiql.Append(",");
                    }
                    detailsWiql.AppendLine("[" + field.ReferenceName + "]");
                    first = false;
                }

                detailsWiql.AppendLine("FROM WorkItems");

                //
                // Get the work item details
                //

                int[] uniqueIds = ids.Distinct().ToArray();

                var flatQuery = new Query(workItemStore, detailsWiql.ToString(), uniqueIds);
                Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemCollection flatQueryList = flatQuery.RunQuery();

                //When query returns details, timestamps are converted to client zone. Use Client timestamp to further filter data
                queryResults.Result = FilterOutItemsNotNeeded(WalkLinks(flatQueryList, workItemLinks, null), durationFilter);
            }
            else
            {
                var workItems = query.RunQuery();
                var result    = new List <WorkItemNode>();
                foreach (Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem workItem in workItems)
                {
                    result.Add(new WorkItemNode
                    {
                        Item     = workItem,
                        Children = new List <WorkItemNode>()
                    });
                }
                queryResults.Result = result;
            }

            return(queryResults);
        }
예제 #5
0
 public Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemCollection GetListOfWorkItems(TFSQuery query)
 {
     Validate();
     Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemCollection workItems = workItemStore.Query(query.QueryString);
     return(workItems);
 }
예제 #6
0
 public static IEnumerator <T> GetEnumerator <T>(this WIT.WorkItemCollection workItemCollection)
 {
     return(new WorkItemCollectionEnumerator <T>(workItemCollection));
 }