using OASystem.API.OAMethodLib.Quartz.Business;
using Quartz;
using QuzrtzJob.Factory;

namespace OASystem.API.OAMethodLib.Quartz.Jobs
{
    /// <summary>
    /// 任务指派
    /// 定时器
    /// </summary>
    public class TaskJob:IJob
    {
        private readonly ILogger<TaskJob> _logger;

        public TaskJob(ILogger<TaskJob> logger)
        {
            _logger = logger;
        }

        public Task Execute(IJobExecutionContext context)
        {
            _logger.LogInformation("调用任务状态变更Function " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            try
            {
                //在此处编写任务业务代码
                TaskAssignment.PostTaskUpdateStatus();
            }
            catch (Exception ex)
            {

                _logger.LogInformation($"调用任务状态变更Function ErrorMsg:{ex.Message} " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            }
           

            return Task.CompletedTask;
        }
    }
}
