更新时间:2023-01-14 23:24:13
工作项查询只能显示WorkItemLinkType
链接.要获取其他类型的链接(即源代码管理中的文件),您需要浏览WorkItem
对象本身中的链接列表.这是一段代码,它将为您提供链接到工作项的文件的工件:
Work item queries can only show WorkItemLinkType
links. To get links of other types (i.e. files in source control), you need to go through the list of links in the WorkItem
object itself. Here's a snippet of code that will get you the artifact of the file linked to the work item:
TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
new Uri("http://<server>:8080/tfs/<collection>"));
WorkItemStore wiStore = tpc.GetService<WorkItemStore>();
VersionControlServer vc = tpc.GetService<VersionControlServer>();
WorkItem task = wiStore.GetWorkItem(<work item with a linked file>);
var externalLinks = task.Links.OfType<ExternalLink>();
foreach (var link in externalLinks)
{
XmlDocument artifact = vc.ArtifactProvider.GetArtifactDocument(new Uri(link.LinkedArtifactUri));
}
XML文档包含使用GetItem()
方法从VersionControlServer
获取正确文件版本所需的所有必要信息.
The XML document contains all necessary information needed to grab the correct file version from the VersionControlServer
using the GetItem()
method.