Click or drag to resize

ILockUnlockAsync Method

IT Hit WebDAV Classes Reference
Removes lock with the specified token from this item.

Namespace:  ITHit.WebDAV.Server.Class2
Assembly:  ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 13.3.13068
Syntax
Task UnlockAsync(
	string lockToken
)

Parameters

lockToken
Type: SystemString
Lock with this token should be removed from the item.

Return Value

Type: Task
.
Exceptions
ExceptionCondition
LockedExceptionThis folder was locked. Client did not provide the lock token.
NeedPrivilegesExceptionThe user doesn't have enough privileges.
InsufficientStorageExceptionQuota limit is reached.
MultistatusExceptionErrors has occured during processing of the subtree.
DavExceptionIn other cases.
Remarks

If this lock included more than one hierarchy item, the lock is removed from all items included in the lock.

Examples

The code below is part of 'WebDAVServer.FileSystemStorage.AspNet' C# & VB samples provided with the SDK.

public async Task UnlockAsync(string lockToken)
{
    if (string.IsNullOrEmpty(lockToken))
    {
        throw new DavException("Lock can not be found.", DavStatus.BAD_REQUEST);
    }

    List<DateLockInfo> locks = await GetLocksAsync(getAllWithExpired: true);
    DateLockInfo lockInfo = locks.SingleOrDefault(x => x.LockToken == lockToken);

    await RemoveExpiredLocksAsync(lockToken);

    if (lockInfo == null || lockInfo.Expiration <= DateTime.UtcNow)
    {
        throw new DavException("The lock could not be found.", DavStatus.CONFLICT);
    }
    await context.socketService.NotifyUnLockedAsync(Path, GetWebSocketID());
}
See Also