Click here to Skip to main content
Click here to Skip to main content

Tagged as

How to Search Information from TFS based on Change Set and Comment

, 26 Nov 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
How to search information from TFS based on Change Set and comment.

Introduction

Before I created this project, I had problems when I checked-in many files in TFS and I had to register the file names to the tracker project. This project allows a TFS user to find what file has been checked-in to TFS by filtering on the change set and allows the user to find his history based on comments. The user can know which change sets or the history of their work.

In this UI, user can find two list boxes, one is display containing .cs, and the other contains .sql.

Using the Code

private void WorkWithTFS(string login, string password, string tfsName)
{
    NetworkCredential tfsCredential = new NetworkCredential(login, password);
    TeamFoundationServer tfs = new TeamFoundationServer(tfsName, tfsCredential);
    tfs.Authenticate();

    Type type = typeof(VersionControlServer);
    VersionControlServer versionControl = (VersionControlServer)tfs.GetService(type);
  
    Changeset changeSets = versionControl.GetChangeset(int.Parse(txtChangeset.Text));

    lblCheckin.Text = changeSets.CreationDate.ToString("dd.MM.yyyy HH:mm:ss");
    lblComment.Text = changeSets.Comment;
    lblCommit.Text = changeSets.Committer;

    lbChangeItem.Items.Clear();
    lbSQLItem.Items.Clear();
    for (int i = 0; i < changeSets.Changes.Count(); i++)
    {
        if (changeSets.Changes[i].Item.ServerItem.Contains("aspx") || 
            changeSets.Changes[i].Item.ServerItem.Contains("cs"))
        {
            lbChangeItem.Items.Add(changeSets.Changes[i].Item.ServerItem);
        }
        else
        {
            lbSQLItem.Items.Add(changeSets.Changes[i].Item.ServerItem);
        }
    }
} 

UI Find Tracker History by Comment

Using the Code

Encrip encrip = new Encrip();
string server = ConfigurationSettings.AppSettings.GetValues("Server")[0];
string login = ConfigurationSettings.AppSettings.GetValues("Login")[0];
string urlTracker = ConfigurationSettings.AppSettings.GetValues("urlTracker")[0];

string encrpString = encrip.Decrypt(ConfigurationSettings.AppSettings.GetValues("Pass")[0]);
string pass = encrpString;

TeamFoundationServer tfs = new TeamFoundationServer(server, new NetworkCredential(login, pass));
Type type = typeof(VersionControlServer);
VersionControlServer versionControl = (VersionControlServer)tfs.GetService(type);
IEnumerable changeSets = versionControl.QueryHistory(urlTracker,
    VersionSpec.Latest, 0, RecursionType.Full,
    null, null, null, int.Parse(txtDepth.Text), true, false);

lbfileCheckin.Items.Clear();
int i = -1;
foreach (Changeset data in changeSets)
{
    i++;
    if (data.Comment.Contains(txtBugID.Text))
    {
        lbfileCheckin.Items.Add(FillSpaceToValue(data.ChangesetId.ToString(), 8) + "| " +
            FillSpaceToValue(data.Owner, 20) + "| " +
            FillSpaceToValue(data.Comment, 60) + "| " + 
            data.CreationDate.ToString("dd.MM.yyyy HH:mm:ss"));
    }
}

Points of Interest

Through this program, I hope I can share my knowledge with everyone.

License

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

Share

About the Author

efero
Software Developer (Senior)
Indonesia Indonesia
No Biography provided
Follow on   Google+

Comments and Discussions

 
QuestionMissing download PinstaffSmitha Vijayan26-Nov-12 5:57 
AnswerRe: Missing download Pinmemberefero26-Nov-12 16:04 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150129.1 | Last Updated 27 Nov 2012
Article Copyright 2012 by efero
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid