public virtual async Task Execute(IJobExecutionContext context) { Logger.Information("Creating provider instance"); Provider = await ScrapeHandlerFactory.CreateAsync(ProviderType, Logger, WebPortalHelper, ScrapeHelper); ModifyProvider(); var success = false; int i; for (i = 0; i < Constants.RetryAttempt; i++) { Logger.Information($"Scrape attempt: {i + 1}"); if (await Provider.Scrape()) { success = true; break; } await Task.Delay(Constants.RetryAfter); } if (success) { Logger.Information($"Scrape succeeded after {i + 1} attempt(s)"); } else { Logger.Error($"Scrape failed after {Constants.RetryAttempt} attempts"); } }
public ScraperService(IScrapeHandler <TimedScrapeRequest> scrapeHandler, IDbContextFactory <DatabaseContext> databaseContextFactory) { _scrapeHandler = scrapeHandler; _databaseContextFactory = databaseContextFactory; }
public TimedScrapeRequestHandler(IScrapeHandler <ScrapeRequest> scrapeRequestHandler) { _scrapeRequestHandler = scrapeRequestHandler; }