Yaniv Madav
Yaniv Madav

Reputation: 45

TFS: Get the user's name of locked file

While trying to checkout a file \ folder in a Workspace, I get 0 as a result if the action was failed. Usually it fails because someone else already checked it out with lock.

Welp, I would like to know who is this user (to bump his ass). How do I do that?

My code:

var workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(folder);
var server = new TfsTeamProjectCollection(workspaceInfo.ServerUri);
var workspace = workspaceInfo.GetWorkspace(server);
int result = workspace.PendEdit(new[] { jsonFile }, RecursionType.Full, null, LockLevel.CheckOut);
if (result == 0)
{
    // How to get the user's name ?
}

Upvotes: 2

Views: 865

Answers (3)

aquinas
aquinas

Reputation: 23796

TfsTeamProjectCollection coll = YOURTEAMPROJECTCOLLECTION;

PendingSet[] pending = coll
        .GetService<VersionControlServer>()
        .QueryPendingSets(new[] { jsonFile  }, RecursionType.None, null, null);

'pending' will contain any pending changesets, who has it checked out, etc.

Upvotes: 2

Isaiah4110
Isaiah4110

Reputation: 10090

You can make use of QueryPendingSets method!

Upvotes: 0

Manjar
Manjar

Reputation: 3268

In Visual Studio 2012 you get the name of the locker person in the Output window

Upvotes: 0

Related Questions