public async Task <Catalogue> RunAsync(
            [ActivityTrigger] SaleFinderCatalogueDownloadInformation downloadInformation,
            ILogger log
            )
        {
            #region null checks
            if (downloadInformation is null)
            {
                throw new ArgumentNullException(nameof(downloadInformation));
            }

            if (log is null)
            {
                throw new ArgumentNullException(nameof(log));
            }
            #endregion

            var catalogue = await saleFinderService.GetCatalogueAsync(downloadInformation.SaleId).ConfigureAwait(false);

            log.LogInformation(S.Plural(catalogue.Pages.Count, "Successfully downloaded and parsed catalogue with 1 page", "Successfully downloaded and parsed catalogue with {0} pages", catalogue.Pages.Count));

            var items = catalogue.Pages
                        .SelectMany(page => page.Items)
                        .Where(item => item.ItemId.HasValue)
                        .Select(item => new CatalogueItem
            {
                Id   = item.ItemId !.Value.ToString(CultureInfo.InvariantCulture),
                Name = item.ItemName,
                Sku  = item.Sku,
                Uri  = item.ItemUrl != null ? new Uri(downloadInformation.BaseUri, item.ItemUrl) : null,
            })
Пример #2
0
        public static async Task QueueStart(
            [QueueTrigger(SaleFinderQueueNames.SaleFinderCataloguesToScan)] SaleFinderCatalogueDownloadInformation downloadInformation,
            [DurableClient] IDurableClient starter,
            ILogger log
            )
        {
            #region null checks
            if (downloadInformation is null)
            {
                throw new ArgumentNullException(nameof(downloadInformation));
            }

            if (starter is null)
            {
                throw new ArgumentNullException(nameof(starter));
            }

            if (log is null)
            {
                throw new ArgumentNullException(nameof(log));
            }
            #endregion

            string instanceId = await starter.StartNewAsync(SaleFinderFunctionNames.ScanSaleFinderCatalogue, downloadInformation).ConfigureAwait(false);

            log.LogInformation($"Started {SaleFinderFunctionNames.ScanSaleFinderCatalogue} orchestration with ID = '{instanceId}'.");
        }