DCSIMG
TFS API Part 5: WorkItemStore - Get Project Details (WorkItemTypes, Queries) - Shai Raiten's Blog

Shai Raiten's Blog

It's all about code...

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

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

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# January 16, 2009 1:05 PM

Shai Raiten said:

TFS API Part 6: WorkItemStore - Get Fields From WorkItemType In TFS API Part 5: WorkItemStore - Get Project

# January 19, 2009 10:34 AM

Rapid prototype said:

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.

# February 5, 2010 11:18 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: