TFS2010:如何将一个工作项链接到变更 [英] TFS2010: How to link a WorkItem to a ChangeSet
问题描述
我想以编程方式链接到WorkItems对比变更。
I would like to programatically link WorkItems to Changesets.
目前我已经创建从我的C#代码的工作项目,并将其保存到TFS的时刻。代码如下所示:
At the moment I am already creating work items from my c# code and saving them to the TFS. The code looks as follows:
WorkItem item = new WorkItem(project.WorkItemTypes["CustomItem"]);
item.Fields["CustomField1"].Value = someValue;
item.Fields["CustomField2"].Value = someValue;
item.Fields["CustomField3"].Value = someValue;
item.Validate();
item.Save();
的
这部分代码工作正常。现在我想给新创建的工作项关联到现有的变更。我正在使用变更:
This part of the code works fine. Now I would like to associate the newly created work item to an existing changeset. I am getting the changeset using:
VersionControlServer service = collection.GetService<VersionControlServer>();
Changeset changeset = service.GetChangeset(123123, true, true);
不过,我只能通过现有的工作项目进行迭代。我无法在新的工作项目添加到该变更。有没有人有一个想法如何做到这一点。
However, I can only iterate through the existing work items. I cannot add a new work item to this changeset. Does anyone have an idea how to achieve this?
推荐答案
我发现了如何通过线索和错误的方法来做到这一点?
I found out how to do this by trail-and-error method:
WorkItemStore store = new WorkItemStore(collection);
Changeset changeset = service.GetChangeset(123, true, true);
WorkItem item = new WorkItem(project.WorkItemTypes["CustomItem"]);
item.Links.Add(new ExternalLink(store.RegisteredLinkTypes[ArtifactLinkIds.Changeset], changeset.ArtifactUri.AbsoluteUri));
item.Fields["CustomField1"].Value = someValue;
item.Fields["CustomField2"].Value = someValue;
item.Fields["CustomField3"].Value = someValue;
item.Validate();
item.Save();
我希望这会帮助别人,将来别人! :)
I hope this will help someone else in the future! :)
基督教
这篇关于TFS2010:如何将一个工作项链接到变更的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!