2

我一直在使用 C# 中 Microsoft.TeamFoundation 模式中的 WorkItem 对象,但想知道是否有人知道我将如何引用“区域”类型的对象,或者就此而言,“迭代”。

似乎这些在 TFS 中被视为对象,但我没有遇到任何关于如何在 C# 中引用这些的信息。

您可以使用 WIQL 按 [Area] 或 [Iteration] 过滤 WorkItem,但是如果我想用所有 Areas 或 Iterations 填充 ComboBox 怎么办?

另外,如何查看我工作场所的 TFS 项目的数据库结构?

多谢你们,

安迪

4

1 回答 1

1

看看这篇博文。有示例代码和演示。

这是一个可以完成这项工作的快速LINQPad查询(下载VS2010 / VS2012):

void Main()
{
    const String CollectionAddress = "http://tfsserver:8080/tfs/MyCollection";
    const String ProjectName = "MyProject";

    using (var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
        new Uri(CollectionAddress)))
    {
        tfs.EnsureAuthenticated();
        var server = tfs.GetService<ICommonStructureService>();

        var projectInfo = server.GetProjectFromName(ProjectName);
        var nodes = server.ListStructures(projectInfo.Uri).Dump();

        // You should be able to re-factor this with "Iteration"
        // for getting those too.
        var nodesXml = server.GetNodesXml(
            nodes
                .Where(node => node.Name == "Area")
                .Select(node => node.Uri).ToArray(),
            true);

        var areaPathAndId =
            XElement.Parse(nodesXml.OuterXml)
            .Descendants("Node")
            .Select(xe => new 
            { 
                Path = xe.Attribute("Path").Value, 
                ID = xe.Attribute("NodeID").Value, 
            })
            .Dump();        
    }
}
于 2012-06-22T19:40:02.007 回答