Skip to content

Commit

Permalink
Merged PR 8093: Fix JobSchedulingSqlServerSeederStartupTask ctor to b…
Browse files Browse the repository at this point in the history
…etter use the default quartz configuration

Fix JobSchedulingSqlServerSeederStartupTask ctor to better use the default quartz configuration
  • Loading branch information
vip32 committed Sep 26, 2024
1 parent b0cb012 commit 8433b8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion examples/DinnerFiesta/Presentation.Web.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModuleScopeJobSchedulingBehavior>()
//.WithBehavior<ChaosExceptionJobSchedulingBehavior>()
.WithBehavior<RetryJobSchedulingBehavior>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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!
}
}

0 comments on commit 8433b8c

Please sign in to comment.