public async Task <TfsQueryResult> Query(TfsKnownConnection knownConn, TfsStatesViewModel model) { var sw = Stopwatch.StartNew(); var vssConnection = knownConn.ToVssConnection(); this.workItemClient = vssConnection.GetClient <WorkItemTrackingHttpClient>(); var wiql = TfsQueryBuilder.BuildQuery(model); var tfsQueryResult = await this.workItemClient.QueryByWiqlAsync(new Wiql { Query = wiql }); var workItems = tfsQueryResult.WorkItems.ToList(); this.totalCount = workItems.Count(); var queue = new ConcurrentQueue <TfsInfo>(); var asyncOptions = GetAsyncOptions(); var getRevsBlock = new ActionBlock <WorkItemReference>( async workItemRef => { var tfsInfo = await ProcessWorkItemRevisions(workItemRef); if (tfsInfo.TransitionCount > model.MinTransitions) { queue.Enqueue(tfsInfo); } }, asyncOptions); foreach (var wiRef in workItems) { getRevsBlock.Post(wiRef); } getRevsBlock.Complete(); await getRevsBlock.Completion; var list = queue .OrderBy(i => i.Iteration) .ThenBy(i => i.Id) .ToList(); sw.Stop(); var result = new TfsQueryResult { TfsItems = list, TotalWorkItems = this.processedCount, TotalRevisions = this.revisionsCount }; return(result); }
// TODO: Consider caching such as https://github.com/alastairtree/LazyCache?WT.mc_id=-blog-scottha public async Task <List <string> > GetProjectNames(TfsKnownConnection knownConn) { var vssConnection = knownConn.ToVssConnection(); var projectClient = vssConnection.GetClient <ProjectHttpClient>(); var states = ProjectState.Unchanged | ProjectState.WellFormed; var projects = await projectClient.GetProjects(states, top : 200); var projectNames = projects .OrderBy(p => p.Name) .Select(p => p.Name) .ToList(); return(projectNames); }
public async Task <List <string> > GetIterations(TfsKnownConnection knownConn, string projectName) { var vssConnection = knownConn.ToVssConnection(); var client = vssConnection.GetClient <WorkItemTrackingHttpClient>(); var rootIterationNode = await client.GetClassificationNodeAsync( projectName, TreeStructureGroup.Iterations, depth : int.MaxValue); var list = new List <IterationItem>(); GetIterations(list, rootIterationNode); var sortedIterationNames = list .OrderBy(i => i.Path) .ThenBy(i => i.StartDate) .Select(i => i.Name) .ToList(); return(sortedIterationNames); }