Skip to content

Commit

Permalink
Wrapper for IScheduler with simpler Quartz 1.x methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mausch committed Nov 29, 2012
1 parent b4830aa commit 7f837ed
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
5 changes: 3 additions & 2 deletions QuartzNetWebConsole/Controllers/SchedulerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions QuartzNetWebConsole/QuartzNetWebConsole.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<Compile Include="Controllers\StaticController.cs" />
<Compile Include="Controllers\TriggerGroupController.cs" />
<Compile Include="Utils\LimitedList.cs" />
<Compile Include="Utils\SchedulerWrapper.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\styles.css" />
Expand Down
93 changes: 93 additions & 0 deletions QuartzNetWebConsole/Utils/SchedulerWrapper.cs
Original file line number Diff line number Diff line change
@@ -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<JobKey>.GroupEquals(groupName));
}

public void ResumeTriggerGroup(string groupName) {
scheduler.ResumeTriggers(GroupMatcher<TriggerKey>.GroupEquals(groupName));
}

public void PauseJobGroup(string groupName) {
scheduler.PauseJobs(GroupMatcher<JobKey>.GroupEquals(groupName));
}

public void PauseTriggerGroup(string groupName) {
scheduler.PauseTriggers(GroupMatcher<TriggerKey>.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));
}
}
}

0 comments on commit 7f837ed

Please sign in to comment.