An option is to use the TFS API like the following snippet.
var projectCollection = new TfsTeamProjectCollection(
new Uri("http://localhost:8080/tfs"),
new UICredentialsProvider());
projectCollection.EnsureAuthenticated();
var workItemStore = projectCollection.GetService<WorkItemStore>();
var versionControlServer = projectCollection.GetService<VersionControlServer>();
var artifactProvider = versionControlServer.ArtifactProvider;
var project = workItemStore.Projects["Test01.MSFAgile.v5"];
var teamQueryFolder = project.QueryHierarchy["Team Queries"] as QueryFolder;
var query = teamQueryFolder["My Tasks"];
var queryDefinition = workItemStore.GetQueryDefinition(query.Id);
var variables = new Dictionary<string, string>
{
{"project", query.Project.Name}
};
var workItemCollection = workItemStore.Query(
queryDefinition.QueryText,
variables);
foreach (WorkItem workItem in workItemCollection)
{
Console.WriteLine("WI: {0}, Title: {1}", workItem.Id, workItem.Title);
foreach (var changeset in
workItem.Links
.OfType<ExternalLink>()
.Select(link => artifactProvider
.GetChangeset(new Uri(link.LinkedArtifactUri))))
{
Console.WriteLine(
"CS: {0}, Comment: {1}",
changeset.ChangesetId,
changeset.Comment);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…