public static void RemoveJob(CroneJob croneJob) { if (croneJob != null) { RecurringJob.RemoveIfExists(croneJob.Id.ToString()); } }
public static void InitJob(CroneJob croneJob) { if (croneJob.RepeatEvery == "Minutely") { RecurringJob.AddOrUpdate(croneJob.Id.ToString(), () => SendRequest(croneJob.JobUrl, croneJob.RequestType, null), Cron.Minutely); } if (croneJob.RepeatEvery == "Daily") { RecurringJob.AddOrUpdate(croneJob.Id.ToString(), () => SendRequest(croneJob.JobUrl, croneJob.RequestType, null), Cron.Daily); } if (croneJob.RepeatEvery == "Hourly") { RecurringJob.AddOrUpdate(croneJob.Id.ToString(), () => SendRequest(croneJob.JobUrl, croneJob.RequestType, null), Cron.Hourly); } if (croneJob.RepeatEvery == "Monthly") { RecurringJob.AddOrUpdate(croneJob.Id.ToString(), () => SendRequest(croneJob.JobUrl, croneJob.RequestType, null), Cron.Monthly); } if (croneJob.RepeatEvery == "Yearly") { RecurringJob.AddOrUpdate(croneJob.Id.ToString(), () => SendRequest(croneJob.JobUrl, croneJob.RequestType, null), Cron.Yearly); } }