我一直在玩C#中Microsoft.TeamFoundation模式中的WorkItem对象,但想知道是否有人知道我将如何引用类型为"Area"或"迭代"类型的对象。
似乎这些在 TFS 中被视为对象,但我还没有遇到任何有关如何在 C# 中引用这些对象的信息。
可以使用 WIQL 按 [区域] 或 [迭代] 筛选工作项,但如果我想用所有区域或迭代填充组合框,该怎么办?
此外,如何查看工作区 TFS 项目的数据库结构?
谢谢大家,
安 迪
看看这篇博文。有示例代码和演示。
下面是一个快速的 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();
}
}