c# - 使用 TFS API 查找哪些工作项正在进行代码审查

标签 c# visual-studio-2015 tfs tfs-2015

给定工作项列表,我想找到与使用 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/

相关文章:

c# - 按偏移量/矢量移动每个 UV 顶点

c# - 是否可以使用面向方面的方法通过 Autofac 和 DynamicProxy 登录 Azure 函数

azure - 如何从 One VS 解决方案发布两个单独的 Azure 网站

c# - 是否可以共享 SQL Server 数据库以在 Asp.Net Web 窗体中存储 session 状态

c# - 将 8 位数字转换为日期时间类型

api - C#、RestSharp、类型或命名空间名称 "HttpBasicAuthenticator"找不到

android-ndk - 链接器命令失败,退出代码为 1(使用 -v 查看调用)VisualStudio

.net - MSBuild 错误 : "Could not resolve this reference. Could not locate the assembly..."

tfs - 我在源代码控制映射中犯了一个错误。我该如何纠正?

tfs - 如何确定谁删除了 TFS 工作项