none
Connect to tfspreview.com from code

    Question

  • Hi

    First of all: What a nice piece of work you have done so far with TFS. I'm impressed!

    Would it be possible to connect to the "WorkItem database" via a custom .Net application. We're currently pulling information from our internal TFS into our ERP-system and would like to be able to do the same with tfspreview. Is that possible and do you have any documentation on how to access the web service?

    Thanks!

    //Casper

    Thursday, October 20, 2011 1:17 PM

Answers

  • Hi Casper and Trevor,

    I have been doing this for a while. If i understand your question correctly you want to consume the work item data through .net code so that you can make use of it in your custom application. 

    The TfsService allows you to use the TFS API against it. I'll show this to you with an example,

    1. You need to download the TFS SDK, the TFS 2010 SDK works with TFS Azure. My tfs preview collection is https://avanade.tfspreview.com the TFS URI is "https://avanade.tfspreview.com/defaultcollection" you can see this blog post on where to find the uri (step 5)  http://geekswithblogs.net/TarunArora/archive/2011/06/18/tfs-2010-sdk-connecting-to-tfs-2010-programmaticallyndashpart-1.aspx (this also has a link to the download for tfs sdk)

    2. Connect to TFS programmatically and use the work item store service. 

     

    var tfs =
                    TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
                        new Uri("https://avanade.tfspreview.com/defaultcollection"));
                var service = tfs.GetService<WorkItemStore>();
    

    3. The work item store service class makes all work item operations available to you. See this link for more details,  http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.workitemtracking.client.workitemstore(v=VS.100).aspx

     

    now if you wanted to query a work item by id, you could do something like below,

     

    public WorkItem GetWorkItemDetails(int id)
            {
                var tfs =
                    TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
                        new Uri("https://tfs2010:8080/defaultcollection"));
                var service = tfs.GetService<WorkItemStore>();
    
                return service.GetWorkItem(id);
            }
    

     


    4. You could take steps forward and build wiq both flat and tree, links in code and execute them. I have several blog posts on using the TFS API, all of these have been build against the TFS Azure. http://geekswithblogs.net/TarunArora/category/12804.aspx

    If you have any follow up questions, please don't hesitate to add to the thread.

    HTH
    Cheers, Tarun 


    Please remember to mark the replies as answers if they help.

    Tarun Arora

     

    Blog: http://geekswithblogs.net/TarunArora  Subscribe in a reader


    Thursday, October 20, 2011 6:52 PM

All replies