From 7f837ed44a9523d480aec6e0aaad7a7ff32cafca Mon Sep 17 00:00:00 2001 From: mausch Date: Thu, 29 Nov 2012 18:44:41 -0300 Subject: [PATCH] Wrapper for IScheduler with simpler Quartz 1.x methods --- .../Controllers/SchedulerController.cs | 5 +- .../QuartzNetWebConsole.csproj | 1 + QuartzNetWebConsole/Utils/SchedulerWrapper.cs | 93 +++++++++++++++++++ 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 QuartzNetWebConsole/Utils/SchedulerWrapper.cs diff --git a/QuartzNetWebConsole/Controllers/SchedulerController.cs b/QuartzNetWebConsole/Controllers/SchedulerController.cs index 716545b..8fda402 100644 --- a/QuartzNetWebConsole/Controllers/SchedulerController.cs +++ b/QuartzNetWebConsole/Controllers/SchedulerController.cs @@ -7,11 +7,12 @@ using System.Web; using MiniMVC; using Quartz; +using QuartzNetWebConsole.Utils; namespace QuartzNetWebConsole.Controllers { public class SchedulerController : Controller { - private readonly IScheduler scheduler = Setup.Scheduler(); - private static readonly MethodInfo[] methods = typeof (IScheduler).GetMethods(); + private readonly SchedulerWrapper scheduler = new SchedulerWrapper(Setup.Scheduler()); + private static readonly MethodInfo[] methods = typeof(SchedulerWrapper).GetMethods(); public class MethodParameters { public readonly MethodInfo method; diff --git a/QuartzNetWebConsole/QuartzNetWebConsole.csproj b/QuartzNetWebConsole/QuartzNetWebConsole.csproj index d1f7750..bf651e3 100644 --- a/QuartzNetWebConsole/QuartzNetWebConsole.csproj +++ b/QuartzNetWebConsole/QuartzNetWebConsole.csproj @@ -73,6 +73,7 @@ + diff --git a/QuartzNetWebConsole/Utils/SchedulerWrapper.cs b/QuartzNetWebConsole/Utils/SchedulerWrapper.cs new file mode 100644 index 0000000..3e1d631 --- /dev/null +++ b/QuartzNetWebConsole/Utils/SchedulerWrapper.cs @@ -0,0 +1,93 @@ +using System; +using Quartz; +using Quartz.Impl.Matchers; + +namespace QuartzNetWebConsole.Utils { + public class SchedulerWrapper { + private readonly IScheduler scheduler; + + public SchedulerWrapper(IScheduler scheduler) { + this.scheduler = scheduler; + } + + public void Shutdown() { + scheduler.Shutdown(); + } + + public void Start() { + scheduler.Start(); + } + + public void Standby() { + scheduler.Standby(); + } + + public void PauseAll() { + scheduler.PauseAll(); + } + + public void ResumeAll() { + scheduler.ResumeAll(); + } + + public void ResumeJobGroup(string groupName) { + scheduler.ResumeJobs(GroupMatcher.GroupEquals(groupName)); + } + + public void ResumeTriggerGroup(string groupName) { + scheduler.ResumeTriggers(GroupMatcher.GroupEquals(groupName)); + } + + public void PauseJobGroup(string groupName) { + scheduler.PauseJobs(GroupMatcher.GroupEquals(groupName)); + } + + public void PauseTriggerGroup(string groupName) { + scheduler.PauseTriggers(GroupMatcher.GroupEquals(groupName)); + } + + public void RemoveGlobalJobListener(string name) { + scheduler.ListenerManager.RemoveJobListener(name); + } + + public void RemoveGlobalTriggerListener(string name) { + scheduler.ListenerManager.RemoveTriggerListener(name); + } + + public void DeleteJob(string jobName, string groupName) { + scheduler.DeleteJob(new JobKey(jobName, groupName)); + } + + public void PauseJob(string jobName, string groupName) { + scheduler.PauseJob(new JobKey(jobName, groupName)); + } + + public void ResumeJob(string jobName, string groupName) { + scheduler.ResumeJob(new JobKey(jobName, groupName)); + } + + public void TriggerJob(string jobName, string groupName) { + scheduler.TriggerJob(new JobKey(jobName, groupName)); + } + + public void TriggerJobWithVolatileTrigger(string jobName, string groupName) { + throw new NotSupportedException(); + } + + public void Interrupt(string jobName, string groupName) { + scheduler.Interrupt(new JobKey(jobName, groupName)); + } + + public void ResumeTrigger(string triggerName, string groupName) { + scheduler.ResumeTrigger(new TriggerKey(triggerName, groupName)); + } + + public void PauseTrigger(string triggerName, string groupName) { + scheduler.PauseTrigger(new TriggerKey(triggerName, groupName)); + } + + public void UnscheduleJob(string triggerName, string groupName) { + scheduler.UnscheduleJob(new TriggerKey(triggerName, groupName)); + } + } +} \ No newline at end of file