refactor(Program): simplify Quartz job registration and add EnvelopeTaskApiJob
- Replaced manual FinishEnvelopeJob Quartz setup with ScheduleJobDefault extension - Added scheduling for EnvelopeTaskApiJob - Updated using directives to include EnvelopeGenerator.Finalizer namespace - Improved maintainability by removing redundant Quartz configuration logic
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using CommandDotNet.Execution;
|
||||
using EnvelopeGenerator.Application.ThirdPartyModules.Queries;
|
||||
using EnvelopeGenerator.DependencyInjection;
|
||||
using EnvelopeGenerator.Finalizer;
|
||||
using EnvelopeGenerator.Finalizer.Job;
|
||||
using EnvelopeGenerator.Finalizer.Models;
|
||||
using EnvelopeGenerator.Infrastructure;
|
||||
@@ -49,21 +50,8 @@ try
|
||||
#region Quartz
|
||||
builder.Services.AddQuartz(q =>
|
||||
{
|
||||
var name = $"{typeof(FinishEnvelopeJob).FullName}";
|
||||
var jobKey = new JobKey(name);
|
||||
q.AddJob<FinishEnvelopeJob>(opts => opts.WithIdentity(jobKey));
|
||||
|
||||
var expression = config[nameof(FinishEnvelopeJob) + ":CronExpression"];
|
||||
if (string.IsNullOrWhiteSpace(expression))
|
||||
throw new InvalidOperationException(
|
||||
"Cron expression for the Worker job is not configured. " +
|
||||
"Please provide a valid cron schedule in the configuration under " +
|
||||
$"'{nameof(FinishEnvelopeJob)}:CronExpression'.");
|
||||
|
||||
q.AddTrigger(opts => opts
|
||||
.ForJob(jobKey)
|
||||
.WithIdentity(name + "-trigger")
|
||||
.WithCronSchedule(expression));
|
||||
q.ScheduleJobDefault<FinishEnvelopeJob>(config);
|
||||
q.ScheduleJobDefault<EnvelopeTaskApiJob>(config);
|
||||
});
|
||||
|
||||
builder.Services.AddQuartzServer(options =>
|
||||
|
||||
Reference in New Issue
Block a user