private LockItem AddLockItemToDynamo(string partitionKey, string recordVersionNumber, PutItemRequest putItemRequest) { long lastUpdatedTime = LockClientUtils.TimeStamp(); PutItemResponse response = _client.PutItemAsync(putItemRequest).Result; if (response.HttpStatusCode == HttpStatusCode.OK) { //todo: do something with this } LockItem lockItem = new LockItem(partitionKey, _ownerName, recordVersionNumber, DateTime.Now, null); _locks.TryAdd(lockItem.UniqueIdentifier, lockItem); return(lockItem); }
public LockItem AddAndWatchNewOrReleasedLock(string partitionKey, string recordVersionNumber, Dictionary <string, AttributeValue> item) { Dictionary <string, string> expressionAttributeNames = new Dictionary <string, string> { { PkPathExpressionVariable, _partitionKeyName }, { IsReleasedPathExpressionVariable, IsReleased } }; Dictionary <string, AttributeValue> expressionAttributeValues = new Dictionary <string, AttributeValue> { { IsReleasedValueExpressionVariable, IsReleasedAttributeValue } }; PutItemRequest putItemRequest = new PutItemRequest(_tableName, item) { ConditionExpression = AcquireLockThatDoesntExistOrIsReleasedCondition, ExpressionAttributeNames = expressionAttributeNames, ExpressionAttributeValues = expressionAttributeValues }; long lastUpdatedTime = LockClientUtils.TimeStamp(); PutItemResponse response = _client.PutItemAsync(putItemRequest).Result; if (response.HttpStatusCode != HttpStatusCode.OK) { //todo: do something with this } LockItem lockItem = new LockItem(partitionKey, _ownerName, recordVersionNumber, DateTime.Now, null); _locks.TryAdd(lockItem.UniqueIdentifier, lockItem); return(lockItem); }