自定义jobkey

zw
rszn 5 months ago
parent 604d12c236
commit 30eff70bb3

@ -3,40 +3,30 @@ using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Job;
using log4net;
using Quartz;
using Quartz.Impl.Triggers;
using Repository.System;
namespace Service.Job;
[Scope]
public class TestJob : IMyJob
public class TestJob : AbstractCronJob
{
private static readonly ILog Log = LogManager.GetLogger(typeof(TestJob));
private SysConfigRepository SysConfigRepository = AppInfo.Container.Resolve<SysConfigRepository>();
public JobKey GetJobKey()
protected override Task Handle()
{
return JobKey.Create("default", JobKey.DefaultGroup);
Log.Info("work");
return Task.CompletedTask;
}
public ITrigger GetTrigger()
protected override string Key()
{
return new CronTriggerImpl("d", "d", "0/5 * * * * ?");
return "test-job";
}
public Task Execute(IJobExecutionContext context)
{
try
{
Log.Info($"{SysConfigRepository.GetHashCode()}");
}
catch (Exception e)
protected override string Cron()
{
Log.Error(e);
}
return Task.CompletedTask;
return "0/2 * * * * ?";
}
}

Loading…
Cancel
Save