我一直在使用C#中Microsoft.TeamFoundation模式中的WorkItem对象,但我想知道是否有人知道我如何引用类型为“Area”或“Iteration”的对象。
它们似乎在TFS中被视为对象,但我还没有看到任何关于如何在C#中引用它们的信息。
您可以使用WIQL按区域或迭代过滤WorkItems,但是如果我想用所有区域或迭代来填充ComboBox呢?
另外,如何查看工作场所的TFS项目的数据库结构?
谢谢你们,
安迪
发布于 2012-06-23 03:40:02
看看this Blog Post吧。这里有示例代码和一个演示。
下面是一个可以完成这项工作的快速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();
}
}https://stackoverflow.com/questions/11162577
复制相似问题