Gets the array of lock tokens submitted by client.
StringCollection object containing collection of lock tokens submitted by client.
ClientLockTokens property provides access to the array of lock tokens submitted by client. You must generate the lock tokens during the call to your Lock and CreateLockNull methods implementation. During this call you associate generated token with an item in the repository and return it to the Engine. Engine than sends the new token to the WebDAV client. When WebDAV client is modifying any server item it sends back to server the list of lock tokens. In your WebDAV server Class 2 implementation before modifying any locked items you must check if WebDAV client provided necessary lock token.
public abstract class HierarchyItem : IHierarchyItem, ILock
{
...
internal bool ClientHasToken
{
get
{
LockInfo[] itemLocks = ActiveLocks;
if(itemLocks.Length == 0)
return true;
WDRequest request = new WDRequest();
StringCollection clientLockTokens = request.ClientLockTokens;
for(int i=0; i<clientLockTokens.Count; i++)
for(int j=0; j<itemLocks.Length; j++)
if(clientLockTokens[i] == itemLocks[j].Token)
return true;
return false;
}
}
...
}
public class Folder : HierarchyItem, IFolder, IFolderLock
{
...
public WebDAVResponse CreateFolder(string name)
{
if(!ClientHasToken)
return new LockedResponse();
SqlConnection conn = new SqlConnection(connStr);
SqlTransaction trans = null;
conn.Open();
try
{
trans = conn.BeginTransaction();
CreateChild(trans, name, ItemType.Folder);
trans.Commit();
}
catch(Exception ex)
{
if(trans != null) trans.Rollback();
throw;
}
finally
{
conn.Close();
}
return new CreatedResponse();
}
...
}
Request Class | ITHit.WebDAV.Server Namespace