How can I retrieve a list of workitems from TFS in C#?

前端 未结 1 457
一整个雨季
一整个雨季 2021-02-02 15:59

I\'m trying to write a project reporting tool in WPF / C#. I want to access all the project names on our TFS (Team Foundation Server), and then display statistics for each work

相关标签:
1条回答
  • 2021-02-02 16:43

    You need to use WIQL queries to get actual work items you are interested in, e.g. to get all work items for a particular project:

    using Microsoft.TeamFoundation.WorkItemTracking.Client;
    
    Query query = new Query(
         workItemStore, 
         "select * from issue where System.TeamProject = @project",
         new Dictionary<string, string>() { { "project", project.Name } }
    );
    
    var workItemCollection = query.RunQuery();
    foreach(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem workItem in workItemCollection) 
    {
       /*Get work item properties you are interested in*/
       foreach(Microsoft.TeamFoundation.WorkItemTracking.Client.Field field in workItem.Fields)
       {
          /*Get field value*/
          info += String.Format("Field name: {0} Value: {1}\n", field.Name, field.Value);
       }
    }
    
    0 讨论(0)
提交回复
热议问题