public TagTransactionEntity(TagTransactionOperation operation, string channel, string alias, string username) { if (String.IsNullOrEmpty(alias)) { throw new ArgumentNullException(nameof(alias)); } if (String.IsNullOrEmpty(username)) { throw new ArgumentNullException(nameof(username)); } channel = String.IsNullOrEmpty(channel) ? "@" : channel; var now = DateTime.UtcNow.ToString("yyyy-MMdd-HHmm-ss"); var uniquifier = Uniquifier++; var transactionId = $"{username}|{now}-{uniquifier % 10000}"; this.PartitionKey = TagTransactionEntity.CalculatePartitionKey(channel, transactionId); this.RowKey = TagTransactionEntity.CalculateRowKey(); this.Channel = channel; this.Alias = alias; this.Username = username; this.Id = transactionId; this.Operation = operation.ToString(); this.StagedBlobUri = $"{channel}/{alias}/{transactionId}"; }
public async Task<TagTransactionEntity> GetTagTransactionAsync(string channel, string transactionId) { var partitionKey = TagTransactionEntity.CalculatePartitionKey(channel, transactionId); var rowKey = TagTransactionEntity.CalculateRowKey(); var op = TableOperation.Retrieve<TagTransactionEntity>(partitionKey, rowKey); var result = await this.Table.ExecuteAsync(op); return (TagTransactionEntity)result.Result; }
internal static string CalculatePartitionKey(string channel, string transactionId) { return(TagTransactionEntity.CalculatePartitionKey(channel, transactionId)); }