简体   繁体   中英

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 ?
}
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.

在Visual Studio 2012中,您可以在“输出”窗口中获得更衣室名称。

您可以使用QueryPendingSets方法!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM