ILockAsyncRefreshLockAsync Method
IT Hit WebDAV Classes Reference
Updates lock timeout information on this item.
Namespace:
ITHit.WebDAV.Server.Class2
Assembly:
ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 11.3.10719
Syntax Task<RefreshLockResult> RefreshLockAsync(
string token,
Nullable<TimeSpan> requestedTimeOut
)
Task<RefreshLockResult> RefreshLockAsync(
string token,
Nullable<TimeSpan> requestedTimeOut
)
Function RefreshLockAsync (
token As String,
requestedTimeOut As Nullable(Of TimeSpan)
) As Task(Of RefreshLockResult)
Function RefreshLockAsync (
token As String,
requestedTimeOut As Nullable(Of TimeSpan)
) As Task(Of RefreshLockResult)
Task<RefreshLockResult^>^ RefreshLockAsync(
String^ token,
Nullable<TimeSpan> requestedTimeOut
)
Task<RefreshLockResult^>^ RefreshLockAsync(
String^ token,
Nullable<TimeSpan> requestedTimeOut
)
abstract RefreshLockAsync :
token : string *
requestedTimeOut : Nullable<TimeSpan> -> Task<RefreshLockResult>
abstract RefreshLockAsync :
token : string *
requestedTimeOut : Nullable<TimeSpan> -> Task<RefreshLockResult>
Parameters
- token
- Type: SystemString
Lock token. - requestedTimeOut
- Type: SystemNullableTimeSpan
Lock timeout which was requested by client. MaxValue
means infinity lock that never expires. Note that your server can ignore this parameter and set
timeout that is different from the one requested by client.
Return Value
Type:
TaskRefreshLockResult
Instance of
RefreshLockResult that contains information about the lock including timeout that was actually set.
Exceptions Remarks This method is called when WebDAV client wants to modify (usually prolong) timeout for the previously
set lock. In this method implementation you can update the lock timeout. Note that you can ignore the requested
timout and set timeout that is different from the one requested by client.
Examples The code below is part of 'WebDAVServer.FileSystemStorage.AspNet' C# & VB samples provided with the SDK.
public async Task<RefreshLockResult> RefreshLockAsync(string token, TimeSpan? requestedTimeOut)
{
if (string.IsNullOrEmpty(token))
{
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 == token);
if (lockInfo == null || lockInfo.Expiration <= DateTime.UtcNow)
{
throw new DavException("Lock can not be found.", DavStatus.CONFLICT);
}
else
{
lockInfo.TimeOut = TimeSpan.FromMinutes(5);
if (requestedTimeOut.HasValue && requestedTimeOut < TimeSpan.MaxValue)
{
lockInfo.TimeOut = requestedTimeOut.Value;
}
lockInfo.Expiration = DateTime.UtcNow + lockInfo.TimeOut;
await SaveLockAsync(lockInfo);
}
await context.socketService.NotifyLockedAsync(Path);
return new RefreshLockResult(lockInfo.Level, lockInfo.IsDeep, lockInfo.TimeOut, lockInfo.ClientOwner);
}
Public Async Function RefreshLockAsync(token As String, requestedTimeOut As TimeSpan?) As Task(Of RefreshLockResult) Implements ILockAsync.RefreshLockAsync
If String.IsNullOrEmpty(token) Then
Throw New DavException("Lock can not be found.", DavStatus.BAD_REQUEST)
End If
Dim locks As List(Of DateLockInfo) = Await GetLocksAsync(getAllWithExpired:=True)
Dim lockInfo As DateLockInfo = locks.SingleOrDefault(Function(x) x.LockToken = token)
If lockInfo Is Nothing OrElse lockInfo.Expiration <= DateTime.UtcNow Then
Throw New DavException("Lock can not be found.", DavStatus.CONFLICT)
Else
lockInfo.TimeOut = TimeSpan.FromMinutes(5)
If requestedTimeOut.HasValue AndAlso requestedTimeOut < TimeSpan.MaxValue Then
lockInfo.TimeOut = requestedTimeOut.Value
End If
lockInfo.Expiration = DateTime.UtcNow + lockInfo.TimeOut
Await SaveLockAsync(lockInfo)
End If
Await context.socketService.NotifyLockedAsync(Path)
Return New RefreshLockResult(lockInfo.Level, lockInfo.IsDeep, lockInfo.TimeOut, lockInfo.ClientOwner)
End Function
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also