Пример #1
0
        public async Task <Product> Subcases(string product)
        {
            logger_.LogInformation("Loading subcases for {product}...", product);
            var reportLink = dataProdiver_.GetReportLink(product);

            try
            {
                var result = await dataProdiver_.GetSubcasesAsync(product);

                var subcases = result.ToArray();

                logger_.LogInformation("Loaded {0} subcases", subcases.Length);
                return(new Product()
                {
                    Name = product,
                    Subcases = subcases.ToArray(),
                    ReportLink = reportLink
                });
            }
            catch (Exception error)
            {
                logger_.LogError(error, $"Error loading subcases for {product}");
                return(new Product()
                {
                    Name = product,
                    Error = error.Message,
                    Subcases = new Subcase[] {},
                    ReportLink = reportLink
                });
            }
        }
Пример #2
0
        public async Task UpdateAsync()
        {
            var productNames = _dataProdiver.GetProducts();

            foreach (var productName in productNames)
            {
                try
                {
                    _logger.LogInformation($"Getting subcases for {productName}...");
                    var subcases = (await _dataProdiver.GetSubcasesAsync(productName)).ToArray();

                    _logger.LogInformation($"{subcases.Count()} subcases for {productName}...");
                    var product = new Product
                    {
                        Id         = GetHash(productName),
                        Name       = productName,
                        ReportLink = _dataProdiver.GetReportLink(productName),
                        Subcases   = subcases.ToArray()
                    };
                    await RegisterProductAsync(product);

                    _logger.LogInformation($"Update complete for {productName}");
                }
                catch (Exception error)
                {
                    _logger.LogError(error, $"Error on updating subcases for {productName}");
                }
            }
        }
 public string GetReportLink(string product)
 {
     return(_dataProdiver.GetReportLink(product));
 }