Click here to Skip to main content
15,897,718 members
Articles / DevOps / TFS

Getting HTML Fields Data into your TFS Warehouse

Rate me:
Please Sign up or sign in to vote.
3.75/5 (5 votes)
30 May 2013CPOL3 min read 32.3K   96   3  
A small trick on how to get HTML data into your warehouse.
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TFSFunctions.cs" company="">
//   
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
namespace HtmlFieldsInReports
{
    #region

    using System;

    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.Framework.Server;
    using Microsoft.TeamFoundation.WorkItemTracking.Client;

    #endregion

    public static class TFSFunctions
    {
        #region Public Methods and Operators

        public static WorkItemCollection ExecuteQuery(WorkItemStore store, string query, string teamProjectName, string processStepWorkItemType)
        {
            query = query.ToLower().Replace("@project", teamProjectName);
            query = query.ToLower().Replace("@processstepworkitemtype", processStepWorkItemType);
            return store.Query(query);
        }

        public static Uri GetTFSUri(TeamFoundationRequestContext requestContext)
        {
            return new Uri(requestContext.GetService<TeamFoundationLocationService>().GetServerAccessMapping(requestContext).AccessPoint.Replace("localhost", Environment.MachineName) + "/" + requestContext.ServiceHost.Name);
        }

        public static TfsTeamProjectCollection GetTeamProjectCollection(string requestContextVirtualDirectory, string workItemChangedEventDisplayUrl)
        {
            string tpcUrl = GetTeamProjectCollectionUrl(requestContextVirtualDirectory, workItemChangedEventDisplayUrl);
            var collection = new TfsTeamProjectCollection(new Uri(tpcUrl));

            collection.EnsureAuthenticated();
            return collection;
        }

        public static string GetTeamProjectCollectionUrl(string requestContextVirtualDirectory, string workItemChangedEventDisplayUrl)
        {
            string[] strArray = workItemChangedEventDisplayUrl.Split('/');
            return string.Format("{0}//{1}{2}", strArray[0], strArray[2], requestContextVirtualDirectory);
        }

        public static WorkItemStore GetWorkItemStore(TfsTeamProjectCollection collection)
        {
            return (WorkItemStore)collection.GetService(typeof(WorkItemStore));
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Architect SSW
South Africa South Africa

Comments and Discussions