2

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 ?
}
Zoe
  • 27,060
  • 21
  • 118
  • 148

3 Answers3

2
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.

aquinas
  • 23,318
  • 5
  • 58
  • 81
0

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

Manjar
  • 3,159
  • 32
  • 44
0

You can make use of QueryPendingSets method!

Isaiah4110
  • 9,855
  • 1
  • 40
  • 56