给定工作项列表,我想找到与使用 C# 中的 TFS 2015 API 进行代码审查相对应的实例。
虽然我可以从描述文本中看出 WorkItem 是否是代码审查,但我宁愿避免解析该字符串并依赖于更强大的东西(例如: WorkItem.Type )...
你会怎么做(Type 值对我来说似乎很神秘)?
最佳答案
您可以使用下面的方法来获取工作项的类型。但您需要提供工作项 ID。
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
Uri collectionUri = (args.Length < 1) ?
new Uri("http://servername:8080/tfs/MyCollection") : new Uri(args[0]);
// Connect to the server and the store.
TfsTeamProjectCollection teamProjectCollection =
new TfsTeamProjectCollection(collectionUri);
WorkItemStore workItemStore = teamProjectCollection.GetService<WorkItemStore>();
string queryString = "Select [State], [Title],[Description] From WorkItems Where [Work Item Type] = 'Code Review Request' or [Work Item Type] = 'Code Review Response'";
// Create and run the query.
Query query = new Query(workItemStore, queryString);
WorkItemCollection witCollection = query.RunQuery();
foreach (WorkItem workItem in witCollection)
{
workItem.Open();
Console.WriteLine(workItem.Fields["Title"].Value.ToString());
}
关于c# - 使用 TFS API 查找哪些工作项正在进行代码审查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44074949/