Пример #1
0
        public async static Task <IEnumerable <T> > ExecuteAsync <T>(this IEnumerable <TableBatchInformation <T> > batchInformations, CloudTable table, EventHub eventHub) where T : ITableEntity
        {
            var executions = new List <TableResult>();

            foreach (var batchInformation in batchInformations)
            {
                try
                {
                    var execution = await table.ExecuteBatchAsync(batchInformation.Operation);

                    executions.AddRange(execution);
                }
                catch (StorageException e)
                {
                    var responseCodeIndex = e.Message.LastIndexOf(" ", StringComparison.InvariantCulture);
                    if (responseCodeIndex > -1)
                    {
                        int failedIndex;
                        if (Int32.TryParse(e.Message.Substring(responseCodeIndex + 1), out failedIndex))
                        {
                            throw new DrivenAzStorageException <T>(e, batchInformation.Entities[failedIndex]);
                        }
                    }
                    throw;
                }

                eventHub.RaiseOperationCompleted(new DrivenAzOperationCompletedArgs(batchInformation.OperationType, batchInformation.Entities.Cast <ITableEntity>()));
            }

            var results = executions.Select(e => (T)e.Result)
                          .ToList();

            return(results);
        }
Пример #2
0
      public static async Task<IEnumerable<T>> ExecuteBatchAsync<T>(this CloudTable table, IEnumerable<T> entities, EntitiesBatchInformationConverter<T> converter, EventHub eventHub)
         where T : class, ITableEntity
      {
         var executions = await entities
            .ToPessimisticConcurrency()
            .ToBatches()
            .ToBatchInformations(converter)
            .ExecuteAsync<T>(table, eventHub);

         var results = executions
            .Where(e => e != null)
            .ToList();

         return results;
      }
Пример #3
0
      public static async Task<IEnumerable<T>> ExecuteBatchAsync<T>(this CloudTable table, IEnumerable<EntityKey> keys, EntityKeyBatchInformationConverter<T> batchInformationConverter, EventHub eventHub)
         where T : ITableEntity
      {
         var executions = await keys            
            .ToBatches()
            .ToBatchInformations(batchInformationConverter)
            .ExecuteAsync<T>(table, eventHub);

         var results = executions
            .Where(e => e != null)
            .ToList();

         return results;
      }
Пример #4
0
 public AsyncTableAccessor(CloudStorageAccount account, EventHub eventHub)
 {
     _eventHub = eventHub;
     _eventHub.OperationCompleted += OperationCompleted;
     _client = account.CreateCloudTableClient();
 }