Yuebon.Extensions/Middlewares/QuartzJobMiddleware.cs

(完整代码) 998B

using Microsoft.AspNetCore.Builder;
using Yuebon.Commons.Log;
using Yuebon.Quartz.Jobs;
using Yuebon.Security.IServices;

namespace Yuebon.Extensions.Middlewares;

/// <summary>
/// Quartz 启动服务
/// </summary>
public static class QuartzJobMiddleware
{
    public static async void UseQuartzJobMiddleware(this IApplicationBuilder app, ITaskManagerService tasksQzServices, ISchedulerCenter schedulerCenter)
    {
        if (app == null) throw new ArgumentNullException(nameof(app));

        try
        {
            if (Appsettings.app("Middleware", "QuartzNetJob", "Enabled").ObjToBool())
            {
                CancellationToken cancellationToken = CancellationToken.None;
              await new QuartzService(schedulerCenter, tasksQzServices).StartAsync(cancellationToken);

            }
        }
        catch (Exception e)
        {
            Log4NetHelper.Error($"An error was reported when starting the job service.\n{e.Message}");
            throw;
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。