如何使用 C# 从 TFS api 获取 TFS 讨论评论

How to get the TFS discussion comments from TFS api using c#

正在处理 TFS 工作项以获取评论、最新添加评论日期和首次添加评论日期以存储在数据库中。谁能帮我实现这个目标。

    foreach (Revision r in RqInfo.Revisions)
    {
        foreach (Field f in r.Fields)
        {
            Console.WriteLine(f.Name, f.Value);
        }
    }

已尝试上面的代码部分,它给出了所有更改日期,包括附加的 link。我只需要来自历史的评论。请帮助我。

已使用此 Microsoft.TeamFoundation.Discussion.Client 命名空间,但无法找到特定工作项的注释。

您应该只检查 System.History 字段。这是在这里考虑的:Fetching the comment history for a work item in TFS

这是一个例子:

 static void Main(string[] args)
 {
    string historyField = "System.History";
    string changedDateField = "System.ChangedDate";
    string changedByField = "System.ChangedBy";

    WorkItemStore store = new WorkItemStore("<your_server_url>/tfs/DefaultCollection");

    WorkItem wi = store.GetWorkItem(your_id);

    foreach (Revision rev in wi.Revisions)
    {

        if (rev.Fields[historyField].Value.ToString() != "")
        {
            Console.WriteLine("{0}: {1} says: \n{2}",
                rev.Fields[changedDateField].Value,
                rev.Fields[changedByField].Value,
                rev.Fields[historyField].Value);
        }
    }
}