Click here to Skip to main content
13,096,268 members (57,138 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked
Posted 26 Nov 2012

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

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


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);

    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;

    for (int i = 0; i < changeSets.Changes.Count(); i++)
        if (changeSets.Changes[i].Item.ServerItem.Contains("aspx") || 

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);

int i = -1;
foreach (Changeset data in changeSets)
    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.


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


About the Author

Software Developer (Senior)
Indonesia Indonesia
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionMissing download Pin
Smitha Vijayan26-Nov-12 4:57
staffSmitha Vijayan26-Nov-12 4:57 
AnswerRe: Missing download Pin
efero26-Nov-12 15:04
memberefero26-Nov-12 15:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 27 Nov 2012
Article Copyright 2012 by efero
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid