refactor: replace QuartzHostedService with QuartzServer and remove unnecessary using
- Replaced `AddQuartzHostedService` with `AddQuartzServer` for better Quartz integration. - Removed `Microsoft.Extensions.Options` using as it was unused. - Updated Quartz job naming to remove GUID and simplify identity. - Minor code cleanup in using statements and regions.
This commit is contained in:
parent
4d6b01030c
commit
3c456562cc
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
@ -8,6 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Quartz.AspNetCore" Version="3.15.1" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.10" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.10" />
|
||||||
|
|||||||
@ -5,8 +5,8 @@ using EnvelopeGenerator.Finalizer.Models;
|
|||||||
using EnvelopeGenerator.Infrastructure;
|
using EnvelopeGenerator.Infrastructure;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Quartz;
|
using Quartz;
|
||||||
|
using Quartz.AspNetCore;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
// Load Serilog from appsettings.json
|
// Load Serilog from appsettings.json
|
||||||
@ -43,10 +43,10 @@ try
|
|||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Worker
|
#region AQuartz
|
||||||
builder.Services.AddQuartz(q =>
|
builder.Services.AddQuartz(q =>
|
||||||
{
|
{
|
||||||
var name = $"{typeof(Worker).FullName}-{Guid.NewGuid():N}";
|
var name = $"{typeof(Worker).FullName}";
|
||||||
var jobKey = new JobKey(name);
|
var jobKey = new JobKey(name);
|
||||||
q.AddJob<Worker>(opts => opts.WithIdentity(jobKey));
|
q.AddJob<Worker>(opts => opts.WithIdentity(jobKey));
|
||||||
|
|
||||||
@ -63,9 +63,9 @@ try
|
|||||||
.WithCronSchedule(expression));
|
.WithCronSchedule(expression));
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.Services.AddQuartzHostedService(opt =>
|
builder.Services.AddQuartzServer(options =>
|
||||||
{
|
{
|
||||||
opt.WaitForJobsToComplete = true;
|
options.WaitForJobsToComplete = true;
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -22,8 +22,8 @@
|
|||||||
"https": {
|
"https": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": false,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "quartz",
|
||||||
"applicationUrl": "https://localhost:7141;http://localhost:5010",
|
"applicationUrl": "https://localhost:7141;http://localhost:5010",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user