private async Task <(bool isComplete, IEnumerable <PublishedProvider> items)> ProducePublishedProviders(CancellationToken cancellationToken,
                                                                                                                dynamic context)
        {
            try
            {
                ICosmosDbFeedIterator <PublishedProvider> feed = ((ISqlImportContext)context).Documents;

                if (!feed.HasMoreResults)
                {
                    return(true, ArraySegment <PublishedProvider> .Empty);
                }

                IEnumerable <PublishedProvider> documents = await feed.ReadNext(cancellationToken);

                while (documents.IsNullOrEmpty() && feed.HasMoreResults)
                {
                    documents = await feed.ReadNext(cancellationToken);
                }

                if (documents.IsNullOrEmpty() && !feed.HasMoreResults)
                {
                    return(true, ArraySegment <PublishedProvider> .Empty);
                }

                return(false, documents.ToArray());
            }
            catch
            {
                return(true, ArraySegment <PublishedProvider> .Empty);
            }
        }
        private async Task <(bool Complete, IEnumerable <MergeSpecificationRequest> items)> ProduceSpecificationInformation(CancellationToken cancellationToken,
                                                                                                                            dynamic context)
        {
            ICosmosDbFeedIterator <ProviderResult> feed = ((MergeContext)context).Feed;

            while (feed.HasMoreResults)
            {
                ProviderResult[] providerResults = (await feed.ReadNext(cancellationToken)).ToArray();

                Console.WriteLine($"Processing next {providerResults.Length} provider results");

                MergeSpecificationRequest[] requests = providerResults.Select(_ =>
                {
                    SpecificationSummary specificationSummary = GetSpecificationSummary(_.SpecificationId);

                    Console.WriteLine($"Creating merge specification request for provider {_.Provider.Id} and specification {_.SpecificationId}");

                    return(new MergeSpecificationRequest(new SpecificationInformation
                    {
                        Id = specificationSummary.Id,
                        Name = specificationSummary.Name,
                        FundingPeriodId = specificationSummary.FundingPeriod.Id,
                        LastEditDate = specificationSummary.LastEditedDate
                    },
                                                         _.Provider.Id));
                }).ToArray();

                return(false, requests);
            }

            return(true, ArraySegment <MergeSpecificationRequest> .Empty);
        }
Пример #3
0
        private async Task <(bool isComplete, IEnumerable <ProviderWithResultsForSpecifications> items)> ProduceProviderWithResultsForSpecifications(CancellationToken token,
                                                                                                                                                     dynamic context)
        {
            ICosmosDbFeedIterator <ProviderWithResultsForSpecifications> feedIterator = ((MergeSpecificationInformationContext)context).FeedIterator;

            while (feedIterator.HasMoreResults)
            {
                ProviderWithResultsForSpecifications[] page = (await feedIterator.ReadNext(token)).ToArray();

                LogInformation($"Producing next page of ProviderWithResultsForSpecifications with {page.Length} items");

                return(false, page);
            }

            return(true, ArraySegment <ProviderWithResultsForSpecifications> .Empty);
        }
Пример #4
0
        public async Task GetPublishedProvidersFromVersion()
        {
            ICosmosDbFeedIterator <PublishedProvider> feed = _repository.GetPublishedProvidersFromVersion("DSG",
                                                                                                          "FY-2021",
                                                                                                          2M);

            feed.HasMoreResults
            .Should()
            .BeTrue();

            IEnumerable <PublishedProvider> documents = await feed.ReadNext();

            documents
            .Should()
            .NotBeEmpty();
        }
Пример #5
0
        public async Task GetPublishedProviders()
        {
            ICosmosDbFeedIterator <PublishedProvider> feed = _repository.GetPublishedProviders("DSG",
                                                                                               "FY-2021-7db621f6-ff28-4910-a3b2-5440c2cd80b0",
                                                                                               1588682808);

            feed.HasMoreResults
            .Should()
            .BeTrue();

            IEnumerable <PublishedProvider> documents = await feed.ReadNext();

            documents
            .Should()
            .NotBeEmpty();
        }
Пример #6
0
        public async Task GetPublishedFundingVersions()
        {
            ICosmosDbFeedIterator <PublishedFundingVersion> feed = _repository.GetPublishedFundingVersions("DSG",
                                                                                                           "FY-2021",
                                                                                                           1588684299);

            feed.HasMoreResults
            .Should()
            .BeTrue();

            IEnumerable <PublishedFundingVersion> documents = await feed.ReadNext();

            documents
            .Should()
            .NotBeEmpty();
        }
Пример #7
0
        public async Task GetPublishedFunding()
        {
            ICosmosDbFeedIterator <PublishedFunding> feed = _repository.GetPublishedFunding("DSG",
                                                                                            "FY-2021",
                                                                                            1588685609);

            while (feed.HasMoreResults)
            {
                IEnumerable <PublishedFunding> documents = await feed.ReadNext();

                documents
                .Should()
                .NotBeNull()
                .And
                .NotBeEmpty();
            }
        }