Пример #1
0
        /// <inheritdoc />
        public async Task <FeedResponse <T> > ExecuteNextAsync(CancellationToken token = default)
        {
            if (!_hasLoggedQuery)
            {
                _logger.LogQueryExecution(
                    _queryContext.SqlQuerySpec,
                    _queryContext.FeedOptions?.PartitionKey?.ToString(),
                    _continuationToken,
                    _queryContext.FeedOptions?.MaxItemCount,
                    _queryContext.FeedOptions?.MaxConcurrency);
                _hasLoggedQuery = true;
            }

            try
            {
                FeedResponse <T> response = await _feedIterator.ReadNextAsync(token);

                _continuationToken = response.ContinuationToken;

                return(response);
            }
            catch (CosmosException ex)
            {
                // The SDK wraps exceptions we throw in handlers with a CosmosException.
                Exception fhirException = ex.InnerException as FhirException ?? ex.InnerException as MicrosoftHealthException;

                if (fhirException == null)
                {
                    _processor.ProcessErrorResponse(ex.StatusCode, ex.Headers, ex.Message);
                }

                throw;
            }
        }
Пример #2
0
        /// <inheritdoc />
        public async Task <FeedResponse <T> > ExecuteNextAsync(CancellationToken token = default)
        {
            Guid queryId = Guid.NewGuid();

            if (!_hasLoggedQuery)
            {
                _logger.LogQueryExecution(
                    queryId,
                    _queryContext.SqlQuerySpec,
                    _queryContext.FeedOptions?.PartitionKey?.ToString(),
                    _continuationToken,
                    _queryContext.FeedOptions?.MaxItemCount);
                _hasLoggedQuery = true;
            }

            try
            {
                FeedResponse <T> response = await _feedIterator.ReadNextAsync(token);

                _continuationToken = response.ContinuationToken;

                _logger.LogQueryExecutionResult(
                    queryId,
                    response.ActivityId,
                    response.RequestCharge,
                    response.ContinuationToken,
                    response.ETag,
                    response.Count);

                return(response);
            }
            catch (CosmosException ex)
            {
                // The SDK wraps exceptions we throw in handlers with a CosmosException.
                Exception fhirException = ex.InnerException as FhirException ?? ex.InnerException as MicrosoftHealthException;

                _logger.LogQueryExecutionResult(
                    queryId,
                    ex.ActivityId,
                    ex.RequestCharge,
                    null,
                    null,
                    0,
                    fhirException ?? ex);

                throw;
            }
        }
Пример #3
0
        /// <inheritdoc />
        public async Task <FeedResponse <T> > ExecuteNextAsync(CancellationToken token = default)
        {
            Guid queryId = Guid.NewGuid();

            _logger.LogQueryExecution(
                queryId,
                _queryContext.SqlQuerySpec,
                _queryContext.FeedOptions?.PartitionKey?.ToString(),
                _continuationToken,
                _queryContext.FeedOptions?.MaxItemCount);

            try
            {
                FeedResponse <T> response = await _feedIterator.ReadNextAsync(token);

                _continuationToken = response.ContinuationToken;

                _logger.LogQueryExecutionResult(
                    queryId,
                    response.ActivityId,
                    response.RequestCharge,
                    response.ContinuationToken,
                    response.ETag,
                    response.Count);

                return(response);
            }
            catch (CosmosException ex)
            {
                _logger.LogQueryExecutionResult(
                    queryId,
                    ex.ActivityId,
                    ex.RequestCharge,
                    null,
                    null,
                    0,
                    ex);

                throw;
            }
        }