本文整理匯總了C#中Quartz.Impl.Triggers.DailyTimeIntervalTriggerImpl類的典型用法代碼示例。如果您正苦於以下問題:C# DailyTimeIntervalTriggerImpl類的具體用法?C# DailyTimeIntervalTriggerImpl怎麽用?C# DailyTimeIntervalTriggerImpl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DailyTimeIntervalTriggerImpl類屬於Quartz.Impl.Triggers命名空間,在下文中一共展示了DailyTimeIntervalTriggerImpl類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DayOfWeekPropertyShouldNotAffectOtherTriggers
public void DayOfWeekPropertyShouldNotAffectOtherTriggers()
{
//make 2 trigger exactly the same
DailyTimeIntervalTriggerImpl trigger1 = new DailyTimeIntervalTriggerImpl()
{
RepeatInterval = 1,
RepeatIntervalUnit = IntervalUnit.Hour
};
DailyTimeIntervalTriggerImpl trigger2 = new DailyTimeIntervalTriggerImpl()
{
RepeatInterval = 1,
RepeatIntervalUnit = IntervalUnit.Hour
};
//make an adjustment to only one trigger.
//I only want mondays now
trigger1.DaysOfWeek.Clear();
trigger1.DaysOfWeek.Add(DayOfWeek.Monday);
//check trigger 2 DOW
//this fails because the reference collection only contains MONDAY b/c it was cleared.
Assert.IsTrue(trigger2.DaysOfWeek.Contains(DayOfWeek.Monday));
Assert.IsTrue(trigger2.DaysOfWeek.Contains(DayOfWeek.Tuesday));
Assert.IsTrue(trigger2.DaysOfWeek.Contains(DayOfWeek.Wednesday));
Assert.IsTrue(trigger2.DaysOfWeek.Contains(DayOfWeek.Thursday));
Assert.IsTrue(trigger2.DaysOfWeek.Contains(DayOfWeek.Friday));
Assert.IsTrue(trigger2.DaysOfWeek.Contains(DayOfWeek.Saturday));
Assert.IsTrue(trigger2.DaysOfWeek.Contains(DayOfWeek.Sunday));
}
示例2: TestQuartzCalendarExclusion
public void TestQuartzCalendarExclusion()
{
DateTimeOffset startTime = DateBuilder.DateOf(0, 0, 0, 1, 1, 2011);
var trigger = new DailyTimeIntervalTriggerImpl
{
StartTimeUtc = startTime.ToUniversalTime(),
StartTimeOfDay = new TimeOfDay(8, 0),
RepeatIntervalUnit = IntervalUnit.Minute,
RepeatInterval = 60
};
CronCalendar cronCal = new CronCalendar("* * 9-12 * * ?"); // exclude 9-12
IList<DateTimeOffset> fireTimes = TriggerUtils.ComputeFireTimes(trigger, cronCal, 48);
Assert.AreEqual(48, fireTimes.Count);
Assert.AreEqual(DateBuilder.DateOf(8, 0, 0, 1, 1, 2011), fireTimes[0]);
Assert.AreEqual(DateBuilder.DateOf(13, 0, 0, 1, 1, 2011), fireTimes[1]);
Assert.AreEqual(DateBuilder.DateOf(23, 0, 0, 4, 1, 2011), fireTimes[47]);
}
示例3: TestEndTimeAfterEndTimeOfDay
public void TestEndTimeAfterEndTimeOfDay()
{
DateTimeOffset startTime = DateBuilder.DateOf(0, 0, 0, 1, 1, 2011);
DateTimeOffset endTime = DateBuilder.DateOf(18, 0, 0, 2, 1, 2011);
TimeOfDay endTimeOfDay = new TimeOfDay(17, 0, 0);
DailyTimeIntervalTriggerImpl trigger = new DailyTimeIntervalTriggerImpl();
trigger.StartTimeUtc = startTime;
trigger.EndTimeUtc = endTime;
trigger.EndTimeOfDayUtc = endTimeOfDay;
trigger.RepeatIntervalUnit = IntervalUnit.Minute;
trigger.RepeatInterval = 60;
IList<DateTimeOffset> fireTimes = TriggerUtils.ComputeFireTimes(trigger, null, 48);
Assert.AreEqual(36, fireTimes.Count);
Assert.AreEqual(DateBuilder.DateOf(0, 0, 0, 1, 1, 2011), fireTimes[0]);
Assert.AreEqual(DateBuilder.DateOf(17, 0, 0, 1, 1, 2011), fireTimes[17]);
Assert.AreEqual(DateBuilder.DateOf(17, 0, 0, 2, 1, 2011), fireTimes[35]);
}
示例4: TestNormalExample
public void TestNormalExample()
{
DateTimeOffset startTime = DateBuilder.DateOf(0, 0, 0, 1, 1, 2011);
TimeOfDay startTimeOfDay = new TimeOfDay(8, 0, 0);
TimeOfDay endTimeOfDay = new TimeOfDay(11, 0, 0);
var trigger = new DailyTimeIntervalTriggerImpl
{
StartTimeUtc = startTime.ToUniversalTime(),
StartTimeOfDay = startTimeOfDay,
EndTimeOfDay = endTimeOfDay,
RepeatIntervalUnit = IntervalUnit.Minute,
RepeatInterval = 72 // this interval will give three firings per day (8:00, 9:12, and 10:24)
};
IList<DateTimeOffset> fireTimes = TriggerUtils.ComputeFireTimes(trigger, null, 48);
Assert.AreEqual(48, fireTimes.Count);
Assert.AreEqual(DateBuilder.DateOf(8, 0, 0, 1, 1, 2011), fireTimes[0]);
Assert.AreEqual(DateBuilder.DateOf(10, 24, 0, 16, 1, 2011), fireTimes[47]);
}
示例5: TestAllDaysOfTheWeek
public void TestAllDaysOfTheWeek()
{
Collection.ISet<DayOfWeek> daysOfWeek = DailyTimeIntervalScheduleBuilder.AllDaysOfTheWeek;
DateTimeOffset startTime = DateBuilder.DateOf(0, 0, 0, 1, 1, 2011); // SAT
TimeOfDay startTimeOfDay = new TimeOfDay(8, 0, 0);
TimeOfDay endTimeOfDay = new TimeOfDay(17, 0, 0);
DailyTimeIntervalTriggerImpl trigger = new DailyTimeIntervalTriggerImpl();
trigger.StartTimeUtc = startTime;
trigger.StartTimeOfDayUtc = startTimeOfDay;
trigger.EndTimeOfDayUtc = endTimeOfDay;
trigger.DaysOfWeek = daysOfWeek;
trigger.RepeatIntervalUnit = IntervalUnit.Minute;
trigger.RepeatInterval = 60;
IList<DateTimeOffset> fireTimes = TriggerUtils.ComputeFireTimes(trigger, null, 48);
Assert.AreEqual(48, fireTimes.Count);
Assert.AreEqual(DateBuilder.DateOf(8, 0, 0, 1, 1, 2011), fireTimes[0]);
Assert.AreEqual(DateBuilder.DateOf(17, 0, 0, 1, 1, 2011), fireTimes[9]); // The 10th hours is the end of day.
Assert.AreEqual(DateBuilder.DateOf(15, 0, 0, 5, 1, 2011), fireTimes[47]);
}
示例6: TestSatAndSun
public void TestSatAndSun()
{
Collection.ISet<DayOfWeek> daysOfWeek = DailyTimeIntervalScheduleBuilder.SaturdayAndSunday;
DateTimeOffset startTime = DateBuilder.DateOf(0, 0, 0, 1, 1, 2011); // SAT(7)
TimeOfDay startTimeOfDay = new TimeOfDay(8, 0, 0);
TimeOfDay endTimeOfDay = new TimeOfDay(17, 0, 0);
DailyTimeIntervalTriggerImpl trigger = new DailyTimeIntervalTriggerImpl();
trigger.StartTimeUtc = startTime;
trigger.StartTimeOfDayUtc = startTimeOfDay;
trigger.EndTimeOfDayUtc = endTimeOfDay;
trigger.DaysOfWeek = daysOfWeek;
trigger.RepeatIntervalUnit = IntervalUnit.Minute;
trigger.RepeatInterval = 60;
IList<DateTimeOffset> fireTimes = TriggerUtils.ComputeFireTimes(trigger, null, 48);
Assert.AreEqual(48, fireTimes.Count);
Assert.AreEqual(DateBuilder.DateOf(8, 0, 0, 1, 1, 2011), fireTimes[0]);
Assert.AreEqual(DayOfWeek.Saturday, fireTimes[0].DayOfWeek);
Assert.AreEqual(DateBuilder.DateOf(8, 0, 0, 2, 1, 2011), fireTimes[10]);
Assert.AreEqual(DayOfWeek.Sunday, fireTimes[10].DayOfWeek);
Assert.AreEqual(DateBuilder.DateOf(15, 0, 0, 15, 1, 2011), fireTimes[47]);
Assert.AreEqual(DayOfWeek.Saturday, fireTimes[47].DayOfWeek);
}
示例7: TestValidateTimeOfDayOrder
public void TestValidateTimeOfDayOrder()
{
var trigger = new DailyTimeIntervalTriggerImpl
{
StartTimeOfDay = new TimeOfDay(12, 0, 0),
EndTimeOfDay = new TimeOfDay(8, 0, 0)
};
try
{
trigger.Validate();
Assert.Fail("Trigger should be invalidate when time of day is not in order.");
}
catch (SchedulerException)
{
// expected.
}
}
示例8: TestGetFireTimeWhenStartTimeAndTimeOfDayIsSame
public void TestGetFireTimeWhenStartTimeAndTimeOfDayIsSame()
{
// A test case for QTZ-369
DateTime startTime = new DateTime(2012, 1, 1);
TimeOfDay startTimeOfDay = new TimeOfDay(8, 0, 0);
TimeOfDay endTimeOfDay = new TimeOfDay(13, 0, 0);
var trigger = new DailyTimeIntervalTriggerImpl();
trigger.StartTimeUtc = startTime;
trigger.StartTimeOfDay = startTimeOfDay;
trigger.EndTimeOfDay = endTimeOfDay;
trigger.RepeatIntervalUnit = IntervalUnit.Hour;
trigger.RepeatInterval = 1;
Assert.AreEqual(dateOf(8, 0, 0, 1, 1, 2012), trigger.GetFireTimeAfter(new DateTime(2012, 1, 1)));
}
示例9: TestGetFireTime
public void TestGetFireTime()
{
DateTime startTime = new DateTime(2011, 1, 1);
TimeOfDay startTimeOfDay = new TimeOfDay(8, 0, 0);
TimeOfDay endTimeOfDay = new TimeOfDay(13, 0, 0);
var trigger = new DailyTimeIntervalTriggerImpl();
trigger.StartTimeUtc = startTime;
trigger.StartTimeOfDay = startTimeOfDay;
trigger.EndTimeOfDay = endTimeOfDay;
trigger.RepeatIntervalUnit = IntervalUnit.Hour;
trigger.RepeatInterval = 1;
Assert.AreEqual(dateOf(8, 0, 0, 1, 1, 2011), trigger.GetFireTimeAfter(dateOf(0, 0, 0, 1, 1, 2011)));
Assert.AreEqual(dateOf(8, 0, 0, 1, 1, 2011), trigger.GetFireTimeAfter(dateOf(7, 0, 0, 1, 1, 2011)));
Assert.AreEqual(dateOf(8, 0, 0, 1, 1, 2011), trigger.GetFireTimeAfter(dateOf(7, 59, 59, 1, 1, 2011)));
Assert.AreEqual(dateOf(9, 0, 0, 1, 1, 2011), trigger.GetFireTimeAfter(dateOf(8, 0, 0, 1, 1, 2011)));
Assert.AreEqual(dateOf(10, 0, 0, 1, 1, 2011), trigger.GetFireTimeAfter(dateOf(9, 0, 0, 1, 1, 2011)));
Assert.AreEqual(dateOf(13, 0, 0, 1, 1, 2011), trigger.GetFireTimeAfter(dateOf(12, 59, 59, 1, 1, 2011)));
Assert.AreEqual(dateOf(8, 0, 0, 2, 1, 2011), trigger.GetFireTimeAfter(dateOf(13, 0, 0, 1, 1, 2011)));
}
示例10: TestRepeatCount0
public void TestRepeatCount0()
{
DateTimeOffset startTime = DateBuilder.DateOf(0, 0, 0, 1, 1, 2011);
TimeOfDay startTimeOfDay = new TimeOfDay(8, 0, 0);
TimeOfDay endTimeOfDay = new TimeOfDay(11, 0, 0);
var trigger = new DailyTimeIntervalTriggerImpl
{
StartTimeUtc = startTime.ToUniversalTime(),
StartTimeOfDay = startTimeOfDay,
EndTimeOfDay = endTimeOfDay,
RepeatIntervalUnit = IntervalUnit.Minute,
RepeatInterval = 72,
RepeatCount = 0
};
IList<DateTimeOffset> fireTimes = TriggerUtils.ComputeFireTimes(trigger, null, 48);
Assert.AreEqual(1, fireTimes.Count);
Assert.AreEqual(DateBuilder.DateOf(8, 0, 0, 1, 1, 2011), fireTimes[0]);
}
示例11: TestSecondInterval
public void TestSecondInterval()
{
DateTimeOffset startTime = DateBuilder.DateOf(0, 0, 0, 1, 1, 2011);
TimeOfDay startTimeOfDay = new TimeOfDay(8, 0, 2);
TimeOfDay endTimeOfDay = new TimeOfDay(13, 30, 0);
var trigger = new DailyTimeIntervalTriggerImpl
{
StartTimeUtc = startTime.ToUniversalTime(),
StartTimeOfDay = startTimeOfDay,
EndTimeOfDay = endTimeOfDay,
RepeatIntervalUnit = IntervalUnit.Second,
RepeatInterval = 72
};
IList<DateTimeOffset> fireTimes = TriggerUtils.ComputeFireTimes(trigger, null, 48);
Assert.AreEqual(48, fireTimes.Count);
Assert.AreEqual((DateBuilder.DateOf(8, 0, 2, 1, 1, 2011)), fireTimes[0]);
Assert.AreEqual((DateBuilder.DateOf(8, 56, 26, 1, 1, 2011)), fireTimes[47]);
}
示例12: TestValidateInterval
public void TestValidateInterval()
{
var trigger = new DailyTimeIntervalTriggerImpl
{
Name = "test",
Group = "test",
JobKey = JobKey.Create("test"),
RepeatIntervalUnit = IntervalUnit.Hour,
RepeatInterval = 25
};
Assert.Throws<SchedulerException>(trigger.Validate, "repeatInterval can not exceed 24 hours. Given 25 hours.");
trigger.RepeatIntervalUnit = IntervalUnit.Minute;
trigger.RepeatInterval = 60*25;
Assert.Throws<SchedulerException>(trigger.Validate, "repeatInterval can not exceed 24 hours (86400 seconds). Given 90000");
trigger.RepeatIntervalUnit = IntervalUnit.Second;
trigger.RepeatInterval = 60*60*25;
Assert.Throws<SchedulerException>(trigger.Validate, "repeatInterval can not exceed 24 hours (86400 seconds). Given 90000");
Assert.Throws<ArgumentException>(delegate { trigger.RepeatIntervalUnit = IntervalUnit.Day; }, "Invalid repeat IntervalUnit (must be Second, Minute or Hour)");
trigger.RepeatIntervalUnit = IntervalUnit.Second;
trigger.RepeatInterval = 0;
Assert.Throws<SchedulerException>(trigger.Validate, "Repeat Interval cannot be zero.");
}
示例13: Test
//.........這裏部分代碼省略.........
job = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));
// ask scheduler to re-Execute this job if it was in progress when
// the scheduler went down...
job.RequestsRecovery = (true);
trigger = new SimpleTriggerImpl("trig_" + count, schedId, 20, TimeSpan.FromSeconds(4));
trigger.StartTimeUtc = (DateTime.Now.AddMilliseconds(1000L));
scheduler.ScheduleJob(job, trigger);
count++;
job = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));
// ask scheduler to re-Execute this job if it was in progress when
// the scheduler went down...
job.RequestsRecovery = (true);
trigger = new SimpleTriggerImpl("trig_" + count, schedId, 20, TimeSpan.FromMilliseconds(4500));
scheduler.ScheduleJob(job, trigger);
count++;
job = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));
// ask scheduler to re-Execute this job if it was in progress when
// the scheduler went down...
job.RequestsRecovery = (true);
IOperableTrigger ct = new CronTriggerImpl("cron_trig_" + count, schedId, "0/10 * * * * ?");
ct.JobDataMap.Add("key", "value");
ct.StartTimeUtc = DateTime.Now.AddMilliseconds(1000);
scheduler.ScheduleJob(job, ct);
count++;
job = new JobDetailImpl("job_" + count, schedId, typeof(SimpleRecoveryJob));
// ask scheduler to re-Execute this job if it was in progress when
// the scheduler went down...
job.RequestsRecovery = (true);
DailyTimeIntervalTriggerImpl nt = new DailyTimeIntervalTriggerImpl("nth_trig_" + count, schedId, new TimeOfDay(1, 1, 1), new TimeOfDay(23, 30, 0), IntervalUnit.Hour, 1);
nt.StartTimeUtc = DateTime.Now.Date.AddMilliseconds(1000);
scheduler.ScheduleJob(job, nt);
DailyTimeIntervalTriggerImpl nt2 = new DailyTimeIntervalTriggerImpl();
nt2.Key = new TriggerKey("nth_trig2_" + count, schedId);
nt2.StartTimeUtc = DateTime.Now.Date.AddMilliseconds(1000);
nt2.JobKey = job.Key;
scheduler.ScheduleJob(nt2);
// GitHub issue #92
scheduler.GetTrigger(nt2.Key);
// GitHub issue #98
nt2.StartTimeOfDay = new TimeOfDay(1, 2, 3);
nt2.EndTimeOfDay = new TimeOfDay(2, 3, 4);
scheduler.UnscheduleJob(nt2.Key);
scheduler.ScheduleJob(nt2);
var triggerFromDb = (IDailyTimeIntervalTrigger) scheduler.GetTrigger(nt2.Key);
Assert.That(triggerFromDb.StartTimeOfDay.Hour, Is.EqualTo(1));
Assert.That(triggerFromDb.StartTimeOfDay.Minute, Is.EqualTo(2));
Assert.That(triggerFromDb.StartTimeOfDay.Second, Is.EqualTo(3));
Assert.That(triggerFromDb.EndTimeOfDay.Hour, Is.EqualTo(2));
Assert.That(triggerFromDb.EndTimeOfDay.Minute, Is.EqualTo(3));
Assert.That(triggerFromDb.EndTimeOfDay.Second, Is.EqualTo(4));
job.RequestsRecovery = (true);
CalendarIntervalTriggerImpl intervalTrigger = new CalendarIntervalTriggerImpl(
"calint_trig_" + count,
示例14: Test
//http://www.cnblogs.com/Magicsky/archive/2012/02/07/2341637.html
//http://blog.csdn.net/wanggang421338916/article/details/7412642
public void Test()
{
//創建一個工作調度器工場
ISchedulerFactory factory = new StdSchedulerFactory();
//獲取一個任務調度器
IScheduler scheduler = factory.GetScheduler();
scheduler.Start();
//創建一個工作
IJobDetail job = JobBuilder.Create<QuartzJobTest>().WithIdentity("SampleJob", "JobGroup1").Build();
//創建觸發器
//1.服務開始時執行
ITrigger trigger = TriggerBuilder.Create().StartNow().Build();
//2.
//該任務執行時間為每隔10秒中,如果要每隔5分鍾可以這樣0 0/5 * * * * ?
//這樣的格式表示每隔5分鍾整執行
ITrigger trigger5 = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.WithSchedule(CronScheduleBuilder.CronSchedule(new CronExpression("0/1 * * * * ?")))
.Build();
//2.在指定時間間隔內輪詢執行
//簡單的調度作業,比如每隔一小時執行一次哪麽簡單調度器
ITrigger trigger2= new SimpleTriggerImpl();
//用的簡單觸發器,每隔5秒執行一次
ITrigger trigger7 = TriggerBuilder.Create()
.WithSimpleSchedule(t => t.RepeatForever().WithIntervalInSeconds(5))
.WithIdentity("t1")
.Build();
//3.日輪詢執行
ITrigger trigger3 = new DailyTimeIntervalTriggerImpl("DailyTimeIntervalTrigger", DateTimeOffset.UtcNow, null, new TimeOfDay(1, 0, 0), new TimeOfDay(22, 01, 00), IntervalUnit.Minute, 1);
//4.複雜的時間設定
//
ITrigger trigger4 = new CronTriggerImpl("CronTrigger", "TriggerGroup1", "0 0 12 * * ?");
ITrigger trigger6 = TriggerBuilder.Create()
.WithIdentity("trigger6", "group1")
.WithCronSchedule("0/5 * 18 * * ? ")//每天每天下午的 6點到6點59分每隔5s就觸發
.Build();
//任務與觸發器添加到調度器
scheduler.ScheduleJob(job, trigger);
}
示例15: TestStartTimeWithoutStartTimeOfDay
public void TestStartTimeWithoutStartTimeOfDay()
{
DateTimeOffset startTime = DateBuilder.DateOf(0, 0, 0, 1, 1, 2011);
DailyTimeIntervalTriggerImpl trigger = new DailyTimeIntervalTriggerImpl();
trigger.StartTimeUtc = startTime;
trigger.RepeatIntervalUnit = IntervalUnit.Minute;
trigger.RepeatInterval = 60;
IList<DateTimeOffset> fireTimes = TriggerUtils.ComputeFireTimes(trigger, null, 48);
Assert.AreEqual(48, fireTimes.Count);
Assert.AreEqual(DateBuilder.DateOf(0, 0, 0, 1, 1, 2011), fireTimes[0]);
Assert.AreEqual(DateBuilder.DateOf(23, 0, 0, 2, 1, 2011), fireTimes[47]);
}