protected override async Task ExecuteAsync(CancellationToken stoppingToken) { using (var db = new ComeAndTicketContext("come_and_ticket_user", "comeandticket")) { while (!stoppingToken.IsCancellationRequested) { try { _logger.Info("Worker running at: {time}", DateTimeOffset.Now); _logger.Info("Updating Drafthouse data from web"); await ComeAndTicketContext.UpdateDatabaseFromWebAsync(db); _logger.Info("Writing to database"); await db.SaveChangesAsync(); } catch (Exception ex) { _logger.Error(ex, "Exception while updating drafthouse data from web"); } await Task.Delay(TimeSpan.FromMinutes(20)); } } }
private static async Task <int> RunAndReturnExitCodeAsync(ComeAndTicketContext db) { _logger.Info("Updating Drafthouse data from web"); await ComeAndTicketContext.UpdateDatabaseFromWebAsync(db); //await // db.ShowTimes // .Include(s => s.Movie) // .Include(s => s.Theater) // .ThenInclude(t => t.Market) // .LoadAsync(); await PushMoviesAsync(db); return(0); }