Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

Programmatically open Pending Changes window and add Work Item

$
0
0

I develop extension for Visual Studio (2012).

I need to programmatically open Pending Changes, change text in Comment input and add Work Items to Pending Changes.

I use the following code:

var tfsExt = (TeamFoundationServerExt) dte.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt");
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsExt.ActiveProjectContext.DomainUri));

var teamExplorer = (ITeamExplorer) GetService(typeof (ITeamExplorer));
var pendingChangesPage = (TeamExplorerPageBase) teamExplorer.NavigateToPage(new Guid(TeamExplorerPageIds.PendingChanges), null);

var workItemStore = tfs.GetService<WorkItemStore>();
var workItem = workItemStore.GetWorkItem(24065); // workItem is not null!

var model = (IPendingCheckin) pendingChangesPage.Model;
model.PendingChanges.Comment = "Hello, World!"; // Comment saved
model.WorkItems.CheckedWorkItems = new[]
{
	new WorkItemCheckinInfo(workItem, WorkItemCheckinAction.Associate),
}; // CheckedWorkItems not saved =(

Comment are displayed in Pending Changes windos, but Work Item are not displayed =(

How to add Work Item to Pending Changes window programmatically?

Thanks.


Viewing all articles
Browse latest Browse all 4410

Trending Articles