using Microsoft.Extensions.Logging;

/// <summary>
/// 这里要注意下，命名空间和程序集是一样的，不然反射不到(任务类要去JobSetup添加注入)
/// </summary>
namespace Tiobon.Core.Tasks;

public class Job_AutoClearLog_Quartz : JobBase, IJob
{
    private readonly ILogger<Job_URL_Quartz> _logger;
    private readonly ICommonServices _commonServices;

    public Job_AutoClearLog_Quartz(ILogger<Job_URL_Quartz> logger, ITasksQzServices tasksQzServices, ITasksLogServices tasksLogServices, ICommonServices commonServices)
        : base(tasksQzServices, tasksLogServices)
    {
        _tasksQzServices = tasksQzServices;
        _logger = logger;
        _commonServices = commonServices;
    }
    public async Task Execute(IJobExecutionContext context)
    {
        // 可以直接获取 JobDetail 的值
        var jobKey = context.JobDetail.Key;
        var jobId = jobKey.Name;
        var executeLog = await ExecuteJob(context, async () => await Run(context, jobId.ObjToInt()));

    }
    public async Task Run(IJobExecutionContext context, int jobid)
    {
        if (jobid > 0)
            await _commonServices.AutoClearLog();
    }
}
