forked from mausch/QuartzNetWebConsole
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (41 loc) · 1.82 KB
/
Copy pathProgram.cs
File metadata and controls
50 lines (41 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using Microsoft.Owin.Hosting;
using Owin;
using Quartz;
using Quartz.Impl;
namespace SampleApp.Owin {
class Program {
static void Start(IAppBuilder app) {
// First, initialize Quartz.NET as usual. In this sample app I'll configure Quartz.NET by code.
var schedulerFactory = new StdSchedulerFactory();
var scheduler = schedulerFactory.GetScheduler();
scheduler.Start();
// I'll add some global listeners
//scheduler.ListenerManager.AddJobListener(new GlobalJobListener());
//scheduler.ListenerManager.AddTriggerListener(new GlobalTriggerListener());
// A sample trigger and job
var trigger = TriggerBuilder.Create()
.WithIdentity("myTrigger")
.WithSchedule(DailyTimeIntervalScheduleBuilder.Create()
.WithIntervalInSeconds(6))
.StartNow()
.Build();
var job = new JobDetailImpl("myJob", null, typeof(HelloJob));
scheduler.ScheduleJob(job, trigger);
// A cron trigger and job
var cron = TriggerBuilder.Create()
.WithIdentity("myCronTrigger")
.ForJob(job.Key)
.WithCronSchedule("0/10 * * * * ?") // every 10 seconds
.Build();
scheduler.ScheduleJob(cron);
// A dummy calendar
//scheduler.AddCalendar("myCalendar", new DummyCalendar { Description = "dummy calendar" }, false, false);
app.Use(QuartzNetWebConsole.Setup.Owin("/quartz/", () => scheduler));
}
private static void Main(string[] args) {
using (WebApp.Start("http://localhost:12345", Start))
Console.ReadLine();
}
}
}