From 8433b8cf4ffea7d6b9ae7d1f34be2808c906de1f Mon Sep 17 00:00:00 2001 From: Vincent van Proosdij Date: Thu, 26 Sep 2024 19:33:47 +0000 Subject: [PATCH] Merged PR 8093: Fix JobSchedulingSqlServerSeederStartupTask ctor to better use the default quartz configuration Fix JobSchedulingSqlServerSeederStartupTask ctor to better use the default quartz configuration --- .../DinnerFiesta/Presentation.Web.Server/Program.cs | 3 ++- .../JobSchedulingSqlServerSeederStartupTask.cs | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/DinnerFiesta/Presentation.Web.Server/Program.cs b/examples/DinnerFiesta/Presentation.Web.Server/Program.cs index ed6199d5..21ac5c81 100644 --- a/examples/DinnerFiesta/Presentation.Web.Server/Program.cs +++ b/examples/DinnerFiesta/Presentation.Web.Server/Program.cs @@ -78,7 +78,8 @@ .WithBehavior(typeof(RetryQueryBehavior<,>)) .WithBehavior(typeof(TimeoutQueryBehavior<,>)); -builder.Services.AddJobScheduling(o => o.StartupDelay("00:00:15"), builder.Configuration) +builder.Services.AddJobScheduling(o => o + .StartupDelay("00:00:15"), builder.Configuration) .WithBehavior() //.WithBehavior() .WithBehavior() diff --git a/src/Infrastructure.EntityFramework.SqlServer/StartupTasks/JobSchedulingSqlServerSeederStartupTask.cs b/src/Infrastructure.EntityFramework.SqlServer/StartupTasks/JobSchedulingSqlServerSeederStartupTask.cs index 493b3a3d..10b493d1 100644 --- a/src/Infrastructure.EntityFramework.SqlServer/StartupTasks/JobSchedulingSqlServerSeederStartupTask.cs +++ b/src/Infrastructure.EntityFramework.SqlServer/StartupTasks/JobSchedulingSqlServerSeederStartupTask.cs @@ -19,8 +19,8 @@ public class JobSchedulingSqlServerSeederStartupTask : IStartupTask, IRetryStart public JobSchedulingSqlServerSeederStartupTask(ILoggerFactory loggerFactory, IConfiguration configuration) : this(loggerFactory, - configuration["JobScheduling:Quartz:quartz.dataSource.default.connectionString"], - configuration["JobScheduling:Quartz:quartz.jobStore.tablePrefix"]) { } + configuration.GetSection("JobScheduling:Quartz", false)["quartz.dataSource.default.connectionString"], + configuration.GetSection("JobScheduling:Quartz", false)["quartz.jobStore.tablePrefix"]) { } public JobSchedulingSqlServerSeederStartupTask( ILoggerFactory loggerFactory, @@ -45,11 +45,13 @@ public async Task ExecuteAsync(CancellationToken cancellationToken) var database = connectionStringBuilder.InitialCatalog; await using var connection = new SqlConnection(connectionStringBuilder.ConnectionString); - connection.Open(); + await connection.OpenAsync(cancellationToken).ConfigureAwait(false); var sql = SqlStatements.CreateQuartzTables(database, this.tablePrefix); - //this.logger.LogDebug(sql); + this.logger.LogDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); // TODO: remove later! + this.logger.LogDebug(sql); // TODO: remove later! await using var command = new SqlCommand(sql, connection); await command.ExecuteNonQueryAsync(cancellationToken); + this.logger.LogDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); // TODO: remove later! } } \ No newline at end of file