How to open WorkItem (VS-Team Explorer) from the side of visual studio?

I want to open a work item from an external visual studio using C # code. Is it possible?

I tried with this:

IWorkItemDocument widoc = null; try { string tfsName = "http://rd-tfs-no2:8080/tfs/siproducts"; var projectCollectionUri = new Uri(tfsName); var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri, new UICredentialsProvider()); projectCollection.EnsureAuthenticated(); DocumentService docService = (DocumentService)Package.GetGlobalService(typeof(DocumentService)); widoc = docService.GetWorkItem(projectCollection, id,this); docService.ShowWorkItem(widoc); } finally { widoc.Release(this); } 

But don't help while I get a null value for docService.

Any good suggestion?

+3
source share
3 answers

Package only works when you are working on a Visual Studio plug-in. If you are looking for a way to display a work item, you can either do this by matching the fields with your winform / WPF application, or by crawling in Internet Explorer and passing the work item ID to the URL for the website viewer.

+1
source

You can try to look at the WorkItemStore object in the TFS API.

  TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(Constants.TEAMFOUNDSERVER); WorkItemStore workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore)); string wiqlQuery = "SELECT [System.Id] FROM WorkItems"; WorkItemCollection wic = workItemStore.Query(wiqlQuery); foreach (WorkItem wi in wic) { //do work here } 
0
source

To get the document service, try the following:

 var dte2 = Marshal.GetActiveObject("VisualStudio.DTE.10.0") as DTE2; var witDocumentService = (DocumentService)dte2.DTE.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService"); 
0
source

All Articles