public async Task <Core.JobScheduling.IJob> Schedule <T>(Expression <Action <T> > methodCall, TimeSpan delay) { try { var Action = methodCall.Compile(); var job = Job_Action <T> .Create(Guid.NewGuid().ToString(), Action); ISimpleTrigger trigger = (ISimpleTrigger)TriggerBuilder.Create() .StartAt(DateTime.UtcNow.Add(delay)) .Build(); await scheduler.ScheduleJob(job, trigger); return(new Job(job, this)); } catch (Exception ex) { throw ex; } }
public async Task <Core.JobScheduling.IJob> RecurringJob <T>(string jobID, Expression <Action <T> > Expression, string cronSchedule) { try { var Action = Expression.Compile(); var job = Job_Action <T> .Create(jobID, Action); var trigger = TriggerBuilder.Create() .WithCronSchedule(cronSchedule, o => o.InTimeZone(TimeZoneInfo.Utc)) .ForJob(job) .Build(); await scheduler.ScheduleJob(job, trigger); return(new Job(job, this)); } catch (Exception ex) { throw; } }
public async Task <Core.JobScheduling.IJob> RecurringJob_EveryNSeconds <T>(string JobID, Expression <Action <T> > methodCall, int Seconds) { try { var Action = methodCall.Compile(); var job = Job_Action <T> .Create(Guid.NewGuid().ToString(), Action); ISimpleTrigger trigger = (ISimpleTrigger)TriggerBuilder.Create() .WithIdentity(JobID) .WithSimpleSchedule(o => o .WithIntervalInSeconds(Seconds) .RepeatForever()) .Build(); await scheduler.ScheduleJob(job, trigger); return(new Job(job, this)); } catch (Exception ex) { throw ex; } }