11using System ;
22using Quartz ;
3- using Quartz . Impl ;
43
54namespace InEngine . Core . Scheduling
65{
@@ -19,78 +18,80 @@ public static TriggerBuilder MakeTriggerBuilder(AbstractCommand command)
1918 . WithIdentity ( $ "{ command . Name } :job:{ command . ScheduleId } ", command . SchedulerGroup ) ;
2019 }
2120
22- public void RegisterJob ( Action < DailyTimeIntervalScheduleBuilder > action )
21+ public LifecycleActions RegisterJob ( Action < DailyTimeIntervalScheduleBuilder > action )
2322 {
24- Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithDailyTimeIntervalSchedule ( action ) . Build ( ) ) ;
23+ return new LifecycleActions {
24+ JobRegistration = Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithDailyTimeIntervalSchedule ( action ) . Build ( ) )
25+ } ;
2526 }
2627
27- public void RegisterJob ( string cronExpression )
28+ public LifecycleActions RegisterJob ( string cronExpression )
2829 {
29- Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithCronSchedule ( cronExpression ) . Build ( ) ) ;
30+ return new LifecycleActions {
31+ JobRegistration = Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithCronSchedule ( cronExpression ) . Build ( ) )
32+ } ;
3033 }
3134
32- public void RegisterJob ( Action < SimpleScheduleBuilder > action )
35+ public LifecycleActions RegisterJob ( Action < SimpleScheduleBuilder > action )
3336 {
34- Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithSimpleSchedule ( action ) . Build ( ) ) ;
37+ return new LifecycleActions {
38+ JobRegistration = Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithSimpleSchedule ( action ) . Build ( ) )
39+ } ;
3540 }
3641
37- public void Cron ( string cronExpression )
42+ public LifecycleActions Cron ( string cronExpression )
3843 {
39- RegisterJob ( cronExpression ) ;
44+ return RegisterJob ( cronExpression ) ;
4045 }
4146
4247 public LifecycleActions EverySecond ( )
4348 {
44- RegisterJob ( x => x . WithIntervalInSeconds ( 1 ) . RepeatForever ( ) ) ;
45- return new LifecycleActions ( )
46- {
47- Command = Command
48- } ;
49+ return RegisterJob ( x => x . WithIntervalInSeconds ( 1 ) . RepeatForever ( ) ) ;
4950 }
5051
51- public void EveryMinute ( )
52+ public LifecycleActions EveryMinute ( )
5253 {
53- RegisterJob ( x => x . WithIntervalInMinutes ( 1 ) . RepeatForever ( ) ) ;
54+ return RegisterJob ( x => x . WithIntervalInMinutes ( 1 ) . RepeatForever ( ) ) ;
5455 }
5556
56- public void EveryFiveMinutes ( )
57+ public LifecycleActions EveryFiveMinutes ( )
5758 {
58- RegisterJob ( x => x . WithIntervalInMinutes ( 5 ) . RepeatForever ( ) ) ;
59+ return RegisterJob ( x => x . WithIntervalInMinutes ( 5 ) . RepeatForever ( ) ) ;
5960 }
6061
61- public void EveryTenMinutes ( )
62+ public LifecycleActions EveryTenMinutes ( )
6263 {
63- RegisterJob ( x => x . WithIntervalInMinutes ( 10 ) . RepeatForever ( ) ) ;
64+ return RegisterJob ( x => x . WithIntervalInMinutes ( 10 ) . RepeatForever ( ) ) ;
6465 }
6566
66- public void EveryFifteenMinutes ( )
67+ public LifecycleActions EveryFifteenMinutes ( )
6768 {
68- RegisterJob ( x => x . WithIntervalInMinutes ( 15 ) . RepeatForever ( ) ) ;
69+ return RegisterJob ( x => x . WithIntervalInMinutes ( 15 ) . RepeatForever ( ) ) ;
6970 }
7071
71- public void EveryThirtyMinutes ( )
72+ public LifecycleActions EveryThirtyMinutes ( )
7273 {
73- RegisterJob ( x => x . WithIntervalInMinutes ( 30 ) . RepeatForever ( ) ) ;
74+ return RegisterJob ( x => x . WithIntervalInMinutes ( 30 ) . RepeatForever ( ) ) ;
7475 }
7576
76- public void Hourly ( )
77+ public LifecycleActions Hourly ( )
7778 {
78- RegisterJob ( x => x . WithIntervalInHours ( 1 ) . RepeatForever ( ) ) ;
79+ return RegisterJob ( x => x . WithIntervalInHours ( 1 ) . RepeatForever ( ) ) ;
7980 }
8081
81- public void HourlyAt ( int minutesAfterTheHour )
82+ public LifecycleActions HourlyAt ( int minutesAfterTheHour )
8283 {
83- RegisterJob ( $ "0 { minutesAfterTheHour } * * * ?") ;
84+ return RegisterJob ( $ "0 { minutesAfterTheHour } * * * ?") ;
8485 }
8586
86- public void Daily ( )
87+ public LifecycleActions Daily ( )
8788 {
88- RegisterJob ( x => x . WithIntervalInHours ( 24 ) . RepeatForever ( ) ) ;
89+ return RegisterJob ( x => x . WithIntervalInHours ( 24 ) . RepeatForever ( ) ) ;
8990 }
9091
91- public void DailyAt ( int hours , int minutes , int seconds = 0 )
92+ public LifecycleActions DailyAt ( int hours , int minutes , int seconds = 0 )
9293 {
93- RegisterJob ( x => x . StartingDailyAt ( new TimeOfDay ( hours , minutes , seconds ) ) ) ;
94+ return RegisterJob ( x => x . StartingDailyAt ( new TimeOfDay ( hours , minutes , seconds ) ) ) ;
9495 }
9596 }
9697}
0 commit comments