Пример #1
0
 private async Task <TResponse> PerformDbAction <TRequest, TResponse>(TRequest request, Func <IAmazonDynamoDB, TRequest, Task <TResponse> > dbAction)
 {
     try
     {
         using (var client = dynamoDbClientFactory.GetClient(AwsRegion.EUWest1))
         {
             return(await dbAction(client, request));
         }
     }
     catch (Exception ex)
     {
         logWriter.LogError(ex, $"Error in {nameof(PerformDbAction)}\n{ex.ToString()}\nRequest:\n{JsonConvert.SerializeObject(request)}");
         throw;
     }
 }
        public IReadOnlyCollection <XElement> GetAllElements()
        {
            try
            {
                logger.LogInformation($"GetAllElements()");

                using (var dbClient = dynamoDbClientFactory.GetClient(AwsRegion.EUWest1))
                {
                    var response = dbClient.ScanAsync(tableName, allAttributes).SafeGetResult();

                    return(response.Items
                           .Select(item => TryParseKeyXml(item["Xml"].S))
                           .ToList()
                           .AsReadOnly());
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Error in {nameof(DynamoDbDataProtectionXmlRepository)}.{nameof(GetAllElements)}: {ex.ToString()}");
                throw;
            }
        }