diff --git a/src/Server/Features/FreeAgents/EndBidding.cs b/src/Server/Features/FreeAgents/EndBidding.cs index d0846d6..6d1a9a6 100644 --- a/src/Server/Features/FreeAgents/EndBidding.cs +++ b/src/Server/Features/FreeAgents/EndBidding.cs @@ -26,7 +26,7 @@ public async Task Invoke() if (!players.Any()) return; - _logger.LogInformation($"Ending bidding for {players.Count} players."); + _logger.LogInformation("Ending bidding for {playerCount} players.", players.Count); foreach (var player in players) { diff --git a/src/Server/Features/OfferMatching/ExpireOfferMatching.cs b/src/Server/Features/OfferMatching/ExpireOfferMatching.cs index d5d088e..0826374 100644 --- a/src/Server/Features/OfferMatching/ExpireOfferMatching.cs +++ b/src/Server/Features/OfferMatching/ExpireOfferMatching.cs @@ -8,7 +8,7 @@ namespace DynamoLeagueBlazor.Server.Features.OfferMatching; public class ExpireOfferMatchingService : IInvocable { private readonly ApplicationDbContext _dbContext; - private ILogger _logger; + private readonly ILogger _logger; public ExpireOfferMatchingService(ApplicationDbContext dbContext, ILogger logger) { @@ -27,7 +27,7 @@ public async Task Invoke() if (!players.Any()) return; - _logger.LogInformation($"Expiring offer matching for {players.Count} players."); + _logger.LogInformation("Expiring offer matching for {playersCount} players.", players.Count); foreach (var player in players) { @@ -35,7 +35,7 @@ public async Task Invoke() { _dbContext.Remove(player); - _logger.LogInformation($"Deleted {player.Name} from the league."); + _logger.LogInformation("Deleted {playerName} from the league.", player.Name); } else { diff --git a/src/Server/Program.cs b/src/Server/Program.cs index 3b21ddd..39fd192 100644 --- a/src/Server/Program.cs +++ b/src/Server/Program.cs @@ -115,6 +115,24 @@ app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); + + app.Services.UseScheduler(scheduler => + { + var centralStandardTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"); + + scheduler.Schedule() + .DailyAtHour(22) + .Zoned(centralStandardTimeZone) + .RunOnceAtStart(); + + scheduler.Schedule() + .Daily() + .Zoned(centralStandardTimeZone) + .RunOnceAtStart(); + }).OnError((ex) => + { + Log.Logger.Error(ex, "An exception occured when trying to run a scheduled job."); + }); } app.UseHttpsRedirection(); @@ -135,21 +153,6 @@ app.MapControllers().RequireAuthorization(); app.MapFallbackToFile("index.html"); - app.Services.UseScheduler(scheduler => - { - var centralStandardTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"); - scheduler.Schedule() - .DailyAtHour(22) - .Zoned(centralStandardTimeZone); - - scheduler.Schedule() - .Daily() - .Zoned(centralStandardTimeZone); - }).OnError((ex) => - { - Log.Logger.Error(ex, "An exception occured when trying to run a scheduled job."); - }); - await using (var scope = app.Services.CreateAsyncScope()) { var applicationDbContext = scope.ServiceProvider.GetRequiredService();