TFS API: Two, TFS code query work items

Source: Internet
Author: User

TFS API: Two, TFS code query work items

First, we need to recognize the two classes of TFS's fetching service objects.

They were tfsconfigurationserver and tfsteamprojectcollection, and their differences were that they could get different TFS API service classes. Their difference is as follows:

Service

Tfsconfigurationserver

( server level )

Tfsteamprojectcollection

( collection level )

Iteamfoundationregistry

Iidentitymanagementservice

Iteamfoundationjobservice

Ipropertyservice

Ieventservice

Isecurityservice

Ilocationservice

Tswaclienthyperlinkservice

Iteamprojectcollectionservice

Iadministrationservice

Icatalogservice

Versioncontrolserver

WorkItemStore

Ibuildserver

Itestmanagementservice

Ilinking

ICommonStructureService3

Iserverstatusservice

Iprocesstemplates

Basically we can operate all functional points on TFS through the above two classes. Let's take a look at how to use tfsteamprojectcollection to get all the items under a particular team collection and print out the project name.

First we need to import the namespace

Using Microsoft.TeamFoundation.Client;

Using Microsoft.TeamFoundation.Framework.Client;

Using Microsoft.TeamFoundation.Framework.Common;

Using Microsoft.TeamFoundation.WorkItemTracking.Client;

Using Microsoft.TeamFoundation.VersionControl.Client;

Next link TFS

Uri Tfsuri = new Uri ("Http://10.0.9.142:8080/tfs/web");

Tfsteamprojectcollection Server = new Tfsteamprojectcollection (Tfsuri);

WorkItemStore workstore = server. Getservice<workitemstore> ();

I need a special explanation here.

Http://10.0.9.142:8080/tfs/web This address must be written right, sometimes this address can actually open TFS in the browser, but not the address of the link TFS, otherwise you will be prompted such errors

TF31002: Unable to connect to this Team Foundation server:http://10.0.9.142:8080/tfs/web.

Team Foundation Server Url:http://10.0.9.142:8080/tfs/web.

How to get the correct address we need, please look at the picture.

After you link to TFS, you can query a lot of data.

Remove the project name under the Team collection URI and, if the team collection is empty, take the project under the default collection

Uri Tfsuri = new Uri ("Http://10.0.9.142:8080/tfs/web");

Tfsteamprojectcollection Server = new Tfsteamprojectcollection (Tfsuri);

WorkItemStore workstore = server. Getservice<workitemstore> ();

foreach (Project project in Workstore. Projects)

{

Console.WriteLine ("TFS Collection under Project name is:" + Project.) Name);

}

Console.WriteLine ("---------------------------------------------------------------");

The following example gets all team collections for our entire TFS server and all team names under the team collection

TFS API: Two, TFS code query work items

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.