Click here to Skip to main content
Licence CPOL
First Posted 12 Nov 2008
Views 11,788
Bookmarked 7 times

TFS Masala - How to get TFS pending check-in statistics through a .NET web service

By | 12 Nov 2008 | Article
How to get TFS pending check-in statistics through a .NET web service.

Introduction

This article outlines how to query a TFS object model from a .NET web service method.

Background

I have been developing a team dashboard in Silverlight which queries different sources and provides useful information to specific domain users. I would like to share my experience of dealing with the TFS object model for getting the checked out file information from the system, from a web service's perspective.

Using the code

Prerequisites

  1. Make sure your web service project has references to:
    1. Microsoft.TeamFoundation.Client.dll
    2. Microsoft.TeamFoundation.VersionControl.Client.dll
  2. Make sure the destination box on which you are deploying the web service has the TFS client installed on it.

How to use the TFS Object Model

You would need to instantiate a TeamFoundationServer object from the Microsoft.TeamFoundation.Client namespace. You need to have a TFS user with read-only (ideally) rights on all the projects for the next step. Remember, the web service won't use the currently logged on Windows credentials to log on to the TFS server. We would need to impersonate as this TFS user with read-only access rights. Now, where to store the login credentials is a discussion for another day. I have got it hard-coded in the method for simplicity:

System.Net.NetworkCredential nc = 
  new System.Net.NetworkCredential("tfs login name",
  "tfs login password");

TeamFoundationServer tfs = new TeamFoundationServer("TFS server name", nc);

Now, we need to get the VersionControlServer service from the TeamFoundation server instance:

VersionControlServer vcs = 
   (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

Now, query the VersionControlServer instance to get a PendingSet collection:

PendingSet[] sets = vcs.GetPendingSets(
                    new String[] { 
                        "$/Project1", 
                        "$/Project2",
                        "$/Project3", 
                        "$/Project4" }
                        RecursionType.Full);

assuming we want the details for the four projects - Project1, Project2, Project3, PIroject4.

I have left out the details of how you would transform this data before returning it to the caller over the wire.

Points of interest

None so far.

History

First release, so awaiting feedback.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

rawwool (Rahul Kumar)

Team Leader
Sage UK Limited
United Kingdom United Kingdom

Member

Follow on Twitter Follow on Twitter


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralVery good Pinmemberjuliotrujilloleon5:20 27 Nov '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 12 Nov 2008
Article Copyright 2008 by rawwool (Rahul Kumar)
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid