How to detect if file is already checked out by someone?
Posted: Fri Aug 07, 2009 11:22 am
I need to know the file state. If file is checked out and user name who checked out it. Would you help me?
A Support Community for SourceGear Products
http://kb.sourcegear.com/VaultHelp/
Code: Select all
foreach (VaultClientCheckOutItem item in checkOuts)
{
xml.WriteStartElement("checkoutitem");
xml.WriteElementString("id", item.FileID.ToString());
foreach (VaultClientCheckOutUser user in item.CheckOutUsers)
{
xml.WriteStartElement("checkoutuser");
xml.WriteElementString("username", user.Name);
xml.WriteElementString("version", user.Version.ToString());
xml.WriteElementString("repositorypath", user.RepPath);
switch (user.LockType)
{
case VaultCheckOutType.None:
xml.WriteElementString("locktype", "none");
break;
case VaultCheckOutType.CheckOut:
xml.WriteElementString("locktype", "checkout");
break;
case VaultCheckOutType.Exclusive:
xml.WriteElementString("locktype", "exclusive");
break;
default:
xml.WriteElementString("locktype", "unknown");
break;
}
xml.WriteElementString("comment", user.Comment);
xml.WriteElementString("hostname", user.Hostname);
xml.WriteElementString("localpath", user.LocalPath);
xml.WriteElementString("folderid", user.FolderID.ToString());
xml.WriteElementString("lockedwhen", user.LockedWhen.ToString());
xml.WriteElementString("miscinfo", user.MiscInfo);
xml.WriteEndElement();
}