TFS二次开发07——锁定(Lock)和解锁(UnLock)

一:锁定(Lock)

string tpcURL = "http://192.168.83.62:8080/";
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(tpcURL));
VersionControlServer version = tpc.GetService(typeof(VersionControlServer)) as VersionControlServer;
version.NonFatalError += version_NonFatalError;
Workspace[] wss = version.QueryWorkspaces(null, Environment.UserName, Environment.MachineName);
Workspace ws = wss[];
string serverDir = "$/MySolution/Customer/MAINLINE/ScrmApp/SinaWeiTravel/SCRM.HPHY.Models";
ItemSet its = version.GetItems(serverDir, RecursionType.OneLevel);
foreach (var item in its.Items)
{
ws.SetLock(item.ServerItem, LockLevel.CheckOut);
}

二:解锁(UnLock)

相应的解锁,苦苦查找形如  “ws.UnLock(item.ServerItem)”这样的方法。可惜没有,原来解锁要使用LockLevel.None 枚举值

ws.SetLock(item.ServerItem, LockLevel. None);

//LockLevel 锁定级别:
//LockLevel.None 解锁
//LockLevel.Checkin 签入锁定
//LockLevel.CheckOut 签出锁定
//LockLevel.Unchanged
上一篇:XCTest各种断言


下一篇:ANDROID_MARS学习笔记_S02_012_ANIMATION_利用AnimationListener在动画结束时删除或添加组件