public static bool Set(string schedulerName, string jobsConfigPath, bool isRun, ILogger logger, IJobListener globalJobListener, JobToBeExecuted globalBeforeExecuted, JobWasExecuted globalAfterExecuted) { schedulerName = schedulerName.Trim().ToLower(); jobsConfigPath = jobsConfigPath.Trim().ToLower(); if (Schedulers.ContainsKey(schedulerName)) { if (jobsConfigPath == Schedulers[schedulerName].JobsConfigPath) { throw new Exception("所设置的调度器已经存在,不做任何操作"); } Schedulers[schedulerName].Stop(); lock (sync) { Schedulers.Remove(schedulerName); } } lock (sync) { Schedulers.Add(schedulerName, new QuartzScheduler(schedulerName, jobsConfigPath, logger, globalJobListener, globalBeforeExecuted, globalAfterExecuted)); if (isRun) { Schedulers[schedulerName].Start(); } } return(true); }
public static bool SetAndRun(string schedulerName, string jobsConfigPath, ILogger logger, IJobListener globalJobListener, JobToBeExecuted globalBeforeExecuted, JobWasExecuted globalAfterExecuted) { return(Set(schedulerName, jobsConfigPath, true, logger, globalJobListener, globalBeforeExecuted, globalAfterExecuted)); }
public QuartzScheduler(string name, string jobsConfigPath, ILogger logger, IJobListener globalJobListener, JobToBeExecuted globalBeforeExecuted, JobWasExecuted globalAfterExecuted) { JobsConfigPath = jobsConfigPath; JobCfgFileWatch(); if (logger == null) { Log = LogCentral.Current; } else { Log = logger; } if (name == null) { Name = jobsConfigPath; } else { Name = name; } GlobalJobListener = globalJobListener; GlobalBeforeExecuted = globalBeforeExecuted; GlobalAfterExecuted = globalAfterExecuted; IsStop = true; }
public QuartzJobsListener(string name, JobToBeExecuted beforeExecuted, JobWasExecuted afterExecuted) { if (Clover.Core.Common.StringHelper.IsEmpty(name)) { Name = "QuartzJobsListener"; } else { Name = name; } _beforeExecuted = beforeExecuted; _afterExecuted = afterExecuted; }
public void Start(JobToBeExecuted globalBeforeExecuted, JobWasExecuted globalAfterExecuted) { GlobalBeforeExecuted = globalBeforeExecuted; GlobalAfterExecuted = globalAfterExecuted; try { sched.Start(); _isStop = false; LogCentral.Current.Info("Quartz Task Start Success"); } catch (Exception ex) { LogCentral.Current.Error("Quartz Task Start Error", ex); if (sched.IsShutdown) { Start(GlobalBeforeExecuted, GlobalAfterExecuted); } } }
public static bool Add(string schedulerName, string jobsConfigPath, bool isRun, ILogger logger, IJobListener globalJobListener, JobToBeExecuted globalBeforeExecuted, JobWasExecuted globalAfterExecuted) { schedulerName = schedulerName.Trim().ToLower(); jobsConfigPath = jobsConfigPath.Trim().ToLower(); if (Schedulers.ContainsKey(schedulerName)) { throw new Exception(string.Concat("已存在相同名称的调度器,参数:schedulerName='", schedulerName, "'")); } lock (sync) { Schedulers.Add(schedulerName, new QuartzScheduler(schedulerName, jobsConfigPath, logger, globalJobListener, globalBeforeExecuted, globalAfterExecuted)); if (isRun) { Schedulers[schedulerName].Start(); } } return(true); }
public QuartzJobsListener(JobToBeExecuted beforeExecuted, JobWasExecuted afterExecuted) : this(null, beforeExecuted, afterExecuted) { }
public static void FireJobWasExecutedEvent(object sender, EventArgs args) { JobWasExecuted?.Invoke(sender, args); }