52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using HHWMS.Web.Models;
|
|
using Quartz;
|
|
using WalkingTec.Mvvm.Core;
|
|
using WalkingTec.Mvvm.Core.Support.Quartz;
|
|
|
|
namespace HHWMS.Web
|
|
{
|
|
//[QuartzRepeat(10,10, true, 30)]
|
|
[PersistJobDataAfterExecution]
|
|
[DisallowConcurrentExecution]
|
|
public class TestJob : WtmJob
|
|
{
|
|
public override Task Execute(IJobExecutionContext context)
|
|
{
|
|
try
|
|
{
|
|
var _unitwork = new UnitWork(Wtm);
|
|
|
|
Wtm.DoLog("测试", ActionLogTypesEnum.Job, "TestJob");
|
|
|
|
#region 更新时间
|
|
var job = _unitwork.FindSingle<SysJob>(x =>
|
|
x.JobName == context.JobDetail.Key.Name
|
|
);
|
|
if (job != null)
|
|
{
|
|
job.LastFireTime = TimeZoneInfo.ConvertTimeFromUtc(
|
|
context.FireTimeUtc.DateTime,
|
|
TimeZoneInfo.Local
|
|
);
|
|
// 只执行一次 没有下次执行时间
|
|
if (context.NextFireTimeUtc != null)
|
|
{
|
|
job.NextFireTime = TimeZoneInfo.ConvertTimeFromUtc(
|
|
context.NextFireTimeUtc.Value.DateTime,
|
|
TimeZoneInfo.Local
|
|
);
|
|
}
|
|
_unitwork.Update<SysJob>(job);
|
|
}
|
|
#endregion
|
|
}
|
|
catch(Exception ex) {
|
|
Wtm.DoLog("测试", ActionLogTypesEnum.Job, "TestJob", request:"error", result:ex.Message);
|
|
}
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|
|
}
|