TFS API Part 5: WorkItemStore – Get Project Details (WorkItemTypes, Queries)

16/01/2009

one comment

TFS API Part 5: WorkItemStore – Get Project Details (WorkItemTypes, Queries)

In TFS API Part 3: Get Project List Using ICommonStructureService we I use ICommonStructureService to get Team Projects.

In this post I’ll show how to use WorkItemStore to perform the same action, and take lots more information about the project.

First add reference for Microsoft.TeamFoundation, Microsoft.TeamFoundation.Client, Microsoft.TeamFoundation.Common.dll,Microsoft.TeamFoundation.WorkItemTracking.Client.dll
located in – C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\

Download Demo Project

using Microsoft.TeamFoundation.Proxy;

using Microsoft.TeamFoundation.Client;

using Microsoft.TeamFoundation.Server;

using Microsoft.TeamFoundation.WorkItemTracking.Client;

Connect to TFS (TFS API Part 1: Domain Picker)

Add :

WorkItemStore store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));

 

Now very easily you can pull Project item.

 

foreach (Project project in store.Projects)

{

  ProjectItem item = new ProjectItem(project.Name,project.WorkItemTypes,project.Uri.ToString(),project.StoredQueries);

  combo_projects.Items.Add(item);

}

 

public class ProjectItem

    {

        public string Name { get; set; }

        public List<string> WorkItemTypes { get; set; }

        public string Uri { get; set; }

        public List<string> Queries { get; set; }

 

        public ProjectItem(string name ,WorkItemTypeCollection wittype, string uri, StoredQueryCollection queries)

        {

            this.Name = name;

            this.Uri = uri;

 

            this.WorkItemTypes = new List<string>();

            foreach (WorkItemType wit in wittype)

                this.WorkItemTypes.Add(wit.Name);

 

            //Queries can be persisted on the Team Foundation

            //Server using the StoredQueryCollection class.

            this.Queries = new List<string>();

            foreach (StoredQuery q in queries)

                this.Queries.Add(q.Name);

        }

 

        public override string ToString()

        {

            return this.Name;

        }

    }

 

image image

Download Demo Project

Add comment
facebook linkedin twitter email

Leave a Reply

one comment

  1. Rapid prototype05/02/2010 ב 11:18

    This articles helps me more.Thanks for your sharing,I will pay more attentions to your blog.Looking forward to your better and better articles.See you next time.