/// <summary> /// Attempts to update the state object in the table. /// </summary> /// <param name="entity"></param> /// <param name="cancellationToken"></param> /// <returns></returns> async Task SetStateObjectAsync(StateObjectEntity entity, CancellationToken cancellationToken) { if (entity is null) { throw new ArgumentNullException(nameof(entity)); } var set = TableOperation.InsertOrReplace(entity); await table.ExecuteAsync(set, cancellationToken); }
public async Task SetTimeoutAsync(string id, TimeSpan?timeout, CancellationToken cancellationToken) { if (table == null) { throw new InvalidOperationException(); } var value = await GetStateObjectAsync(id, cancellationToken); if (value == null) { value = new StateObjectEntity(partitioner.GetPartitionKey(id), partitioner.GetRowKey(id), id); } value.Timeout = timeout?.Ticks; await SetStateObjectAsync(value, cancellationToken); }
public async Task SetFlagAsync(string id, uint?extraFlags, CancellationToken cancellationToken) { if (table == null) { throw new InvalidOperationException(); } var value = await GetStateObjectAsync(id, cancellationToken); if (value == null) { value = new StateObjectEntity(partitioner.GetPartitionKey(id), partitioner.GetRowKey(id), id); } value.ExtraFlags = (int?)extraFlags; await SetStateObjectAsync(value, cancellationToken); }
public async Task SetLockAsync(string id, uint cookie, DateTime time, CancellationToken cancellationToken) { if (table == null) { throw new InvalidOperationException(); } var value = await GetStateObjectAsync(id, cancellationToken); if (value == null) { value = new StateObjectEntity(partitioner.GetPartitionKey(id), partitioner.GetRowKey(id), id); } value.LockCookie = (int)cookie; value.LockTime = time; await SetStateObjectAsync(value, cancellationToken); }
public async Task SetDataAsync(string id, byte[] data, uint?extraFlags, TimeSpan?timeout, CancellationToken cancellationToken) { if (table == null) { throw new InvalidOperationException(); } var value = await GetStateObjectAsync(id, cancellationToken); if (value == null) { value = new StateObjectEntity(partitioner.GetPartitionKey(id), partitioner.GetRowKey(id), id); } value.Data = data; value.ExtraFlags = (int?)extraFlags; value.Timeout = timeout?.Ticks; value.Altered = DateTime.UtcNow; await SetStateObjectAsync(value, cancellationToken); }