通过C#代码从TFS服务器读取文档。 [英] Reading a document from TFS server through C# code.

查看:280
本文介绍了通过C#代码从TFS服务器读取文档。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从TFS服务器读取我的测试用例,以便我的框架连接到TFS。此外,我想版本控制该文件。

请提供正确的方法。

任何帮助都非常感谢。



-

谢谢。

I want to read my test cases from TFS server so that my framework would be connected to TFS. Also i want to version control of that documents.
Please provide me the right approach.
Any help is highly appreciated.

--
Thanks.

推荐答案

你可以得到工作项目 [ ^ ]然后查看Attachments属性,该属性将为您提供与WorkItem关联的附件列表。您需要参考 Microsoft.TeamFoundation.Client [ ^ ]和 Microsoft.TeamFoundation.WorkItemTracking.Client [ ^ ]。下面是代码示例以获取工作项目。



You can get a version of a Work Item[^] and then look at the Attachments property that will get you a list of attachments associated with your WorkItem. You will require a reference to Microsoft.TeamFoundation.Client[^] and Microsoft.TeamFoundation.WorkItemTracking.Client[^]. A Code sample is below to get the Work Items.

using (Microsoft.TeamFoundation.Client.TeamFoundationServer tfs = Microsoft.TeamFoundation.Client.TeamFoundationServerFactory.GetServer(uri))
{
    Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore wit = (Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore)tfs.GetService(typeof(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore));

    Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemCollection result = wit.Query("SELECT * FROM WorkItems");
    foreach (Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem wi in result)
    {
        foreach (Microsoft.TeamFoundation.WorkItemTracking.Client.Attachment attachment in wi.Attachments)
        {
            //do something
        }
    }
}


这篇关于通过C#代码从TFS服务器读取文档。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆