Пример #1
0
        public Task AddWithDateKeyBatchAsync(IReadOnlyCollection <MarginTradingAccountHistoryEntity> src)
        {
            var entities = src.Select(s => new MarginTradingAccountHistoryEntity
            {
                PartitionKey          = s.PartitionKey,
                Amount                = s.Amount,
                Balance               = s.Balance,
                ClientId              = s.ClientId,
                Comment               = s.Comment,
                Date                  = s.Date,
                Id                    = s.RowKey,
                Type                  = s.Type,
                WithdrawTransferLimit = s.WithdrawTransferLimit,
            }).ToList();

            return(_tableStorage.InsertBatchAndGenerateRowKeyAsync(entities,
                                                                   (e, retry, itemNum) =>
                                                                   e.Date.ToString(RowKeyDateTimeFormat.Iso.ToDateTimeMask()) +
                                                                   (retry * entities.Count + itemNum).ToDateTimeSuffix(RowKeyDateTimeFormat.Iso)));
        }
Пример #2
0
        protected override async Task Consume(IEnumerable <TLogEntity> entries)
        {
            try
            {
                var partitionGroups = entries.GroupBy(e => e.PartitionKey);
                var tasks           = partitionGroups
                                      .Select(group => _tableStorage.InsertBatchAndGenerateRowKeyAsync(
                                                  group.ToArray(),
                                                  (entity, retryNum, batchItemNum) => _rowKeyGenerator.Generate(entity, retryNum, batchItemNum)));

                await Task.WhenAll(tasks);
            }
            catch (Exception ex)
            {
                await _lastResortLog.WriteErrorAsync(
                    "Persist log entries to the Table Storage",
                    $"Manager type: {GetType().Name}. Log entity type: {typeof(TLogEntity).Name}",
                    ex);
            }
        }
 private Task PersistEntriesGroup(IGrouping <string, LogEntity> group)
 {
     return(_storage.InsertBatchAndGenerateRowKeyAsync(
                group.ToArray(),
                (entity, retryNum, batchItemNum) => LogEntity.GenerateRowKey(entity.DateTime, batchItemNum, retryNum)));
 }