本文整理汇总了C#中CronExpression类的典型用法代码示例。如果您正苦于以下问题:C# CronExpression类的具体用法?C# CronExpression怎么用?C# CronExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CronExpression类属于命名空间,在下文中一共展示了CronExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestCronExpressionPassingMidnight
public void TestCronExpressionPassingMidnight()
{
CronExpression cronExpression = new CronExpression("0 15 23 * * ?");
DateTimeOffset cal = new DateTime(2005, 6, 1, 23, 16, 0).ToUniversalTime();
DateTimeOffset nextExpectedFireTime = new DateTime(2005, 6, 2, 23, 15, 0).ToUniversalTime();
Assert.AreEqual(nextExpectedFireTime, cronExpression.GetTimeAfter(cal).Value);
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:7,代码来源:CronExpressionTest.cs
示例2: GetTargetObject
/// <summary>
/// Get the object to serialize when generating serialized file for future
/// tests, and against which to validate deserialized object.
/// </summary>
/// <returns></returns>
protected override object GetTargetObject()
{
CronExpression cronExpression = new CronExpression("0 15 10 * * ? 2005");
cronExpression.TimeZone = testTimeZone;
return cronExpression;
}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:12,代码来源:CronExpressionTest.cs
示例3: TestCronExpressionLastDayOfMonth
public void TestCronExpressionLastDayOfMonth()
{
CronExpression cronExpression = new CronExpression("0 0 12 L * ?");
int[] arrJuneDaysThatShouldFire = new int[] { 30 };
List<int> juneDays = new List<int>(arrJuneDaysThatShouldFire);
TestCorrectWeekFireDays(cronExpression, juneDays);
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:8,代码来源:CronExpressionTest.cs
示例4: Should_be_able_to_create_an_all_inclusive_expression
public void Should_be_able_to_create_an_all_inclusive_expression()
{
var date = new DateTime(2011, 1, 1, 0, 0, 0);
var cron = new CronExpression("* * * * *", date);
for (var i = 1; i < 121; i++)
{
Assert.AreEqual(date.AddMinutes(i), cron.NextOccurrence());
}
}
开发者ID:yonglehou,项目名称:shuttle-scheduling,代码行数:10,代码来源:CronExpressionTest.cs
示例5: TestCronExpressionParsingIncorrectDayOfWeek
public void TestCronExpressionParsingIncorrectDayOfWeek()
{
// test failed before because of improper trimming
try
{
string expr = string.Format(" * * * * * {0}", DateTime.Now.Year);
CronExpression ce = new CronExpression(expr);
ce.IsSatisfiedBy(DateTime.UtcNow.AddMinutes(2));
Assert.Fail("Accepted wrong format");
}
catch (FormatException fe)
{
Assert.AreEqual("Day-of-Week values must be between 1 and 7", fe.Message);
}
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:15,代码来源:CronExpressionTest.cs
示例6: Should_be_able_to_get_week_days_across_month_boundary
public void Should_be_able_to_get_week_days_across_month_boundary()
{
var date = new DateTime(2011, 1, 23, 0, 0, 0);
var cron = new CronExpression("0 0 ? * 3,6", date);
Assert.AreEqual(new DateTime(2011, 1, 25, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 1, 28, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 1, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 4, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 8, 0, 0, 0), cron.NextOccurrence());
date = new DateTime(2011, 2, 10, 0, 0, 0);
cron = new CronExpression("0 0 ? * 3,6", date);
Assert.AreEqual(new DateTime(2011, 2, 8, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 4, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 1, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 1, 28, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 1, 25, 0, 0, 0), cron.PreviousOccurrence());
}
开发者ID:yonglehou,项目名称:shuttle-scheduling,代码行数:20,代码来源:CronExpressionTest.cs
示例7: Should_be_able_to_get_last_day_of_month_across_multiple_months
public void Should_be_able_to_get_last_day_of_month_across_multiple_months()
{
var date = new DateTime(2011, 1, 1, 0, 0, 0);
var cron = new CronExpression("0 0 L 1,2,5,6,9,12 *", date);
Assert.AreEqual(new DateTime(2011, 1, 31, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 28, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 5, 31, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 6, 30, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 9, 30, 0, 0, 0), cron.NextOccurrence());
Assert.AreEqual(new DateTime(2011, 12, 31, 0, 0, 0), cron.NextOccurrence());
date = new DateTime(2012, 1, 1, 0, 0, 0);
cron = new CronExpression("0 0 L 1,2,5,6,9,12 *", date);
Assert.AreEqual(new DateTime(2011, 12, 31, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 9, 30, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 6, 30, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 5, 31, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 2, 28, 0, 0, 0), cron.PreviousOccurrence());
Assert.AreEqual(new DateTime(2011, 1, 31, 0, 0, 0), cron.PreviousOccurrence());
}
开发者ID:yonglehou,项目名称:shuttle-scheduling,代码行数:22,代码来源:CronExpressionTest.cs
示例8: TestIsSatisfiedBy
public void TestIsSatisfiedBy()
{
CronExpression cronExpression = new CronExpression("0 15 10 * * ? 2005");
DateTime cal = new DateTime(2005, 6, 1, 10, 15, 0).ToUniversalTime();
Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
cal = cal.AddYears(1);
Assert.IsFalse(cronExpression.IsSatisfiedBy(cal));
cal = new DateTime(2005, 6, 1, 10, 16, 0).ToUniversalTime();
Assert.IsFalse(cronExpression.IsSatisfiedBy(cal));
cal = new DateTime(2005, 6, 1, 10, 14, 0).ToUniversalTime();
Assert.IsFalse(cronExpression.IsSatisfiedBy(cal));
cronExpression = new CronExpression("0 15 10 ? * MON-FRI");
// weekends
cal = new DateTime(2007, 6, 9, 10, 15, 0).ToUniversalTime();
Assert.IsFalse(cronExpression.IsSatisfiedBy(cal));
Assert.IsFalse(cronExpression.IsSatisfiedBy(cal.AddDays(1)));
}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:23,代码来源:CronExpressionTest.cs
示例9: TestMonthShift
public void TestMonthShift()
{
// QRTZNET-28
CronExpression cronExpression = new CronExpression("* * 1 * * ?");
DateTimeOffset cal = new DateTime(2005, 7, 31, 22, 59, 57).ToUniversalTime();
DateTimeOffset nextExpectedFireTime = new DateTime(2005, 8, 1, 1, 0, 0).ToUniversalTime();
Assert.AreEqual(nextExpectedFireTime, cronExpression.GetTimeAfter(cal).Value);
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:8,代码来源:CronExpressionTest.cs
示例10: TestHourShift
public void TestHourShift()
{
// cronexpression that fires every 5 seconds
CronExpression cronExpression = new CronExpression("0/5 * * * * ?");
DateTimeOffset cal = new DateTimeOffset(2005, 6, 1, 1, 59, 55, TimeSpan.Zero);
DateTimeOffset nextExpectedFireTime = new DateTimeOffset(2005, 6, 1, 2, 0, 0, TimeSpan.Zero);
Assert.AreEqual(nextExpectedFireTime, cronExpression.GetTimeAfter(cal).Value);
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:8,代码来源:CronExpressionTest.cs
示例11: TestLastDayOffset
public void TestLastDayOffset()
{
CronExpression cronExpression = new CronExpression("0 15 10 L-2 * ? 2010");
DateTime cal = new DateTime(2010, 10, 29, 10, 15, 0).ToUniversalTime(); // last day - 2
Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
cal = new DateTime(2010, 10, 28, 10, 15, 0).ToUniversalTime();
Assert.IsFalse(cronExpression.IsSatisfiedBy(cal));
cronExpression = new CronExpression("0 15 10 L-5W * ? 2010");
cal = new DateTime(2010, 10, 26, 10, 15, 0).ToUniversalTime(); // last day - 5
Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
cronExpression = new CronExpression("0 15 10 L-1 * ? 2010");
cal = new DateTime(2010, 10, 30, 10, 15, 0).ToUniversalTime(); // last day - 1
Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
cronExpression = new CronExpression("0 15 10 L-1W * ? 2010");
cal = new DateTime(2010, 10, 29, 10, 15, 0).ToUniversalTime(); // nearest weekday to last day - 1 (29th is a friday in 2010)
Assert.IsTrue(cronExpression.IsSatisfiedBy(cal));
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:25,代码来源:CronExpressionTest.cs
示例12: TestFormatExceptionWildCardDayOfMonthAndSpecifiedDayOfWeek
public void TestFormatExceptionWildCardDayOfMonthAndSpecifiedDayOfWeek()
{
CronExpression cronExpression = new CronExpression("0 0 * * * 4");
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:4,代码来源:CronExpressionTest.cs
示例13: TestGetTimeAfter_QRTZNET149
public void TestGetTimeAfter_QRTZNET149()
{
CronExpression expression = new CronExpression("0 0 0 29 * ?");
DateTimeOffset? after = expression.GetNextValidTimeAfter(new DateTime(2009, 1, 30, 0, 0, 0).ToUniversalTime());
Assert.IsTrue(after.HasValue);
Assert.AreEqual(new DateTime(2009, 3, 29, 0, 0, 0).ToUniversalTime(), after.Value.DateTime);
after = expression.GetNextValidTimeAfter(new DateTime(2009, 12, 30).ToUniversalTime());
Assert.IsTrue(after.HasValue);
Assert.AreEqual(new DateTime(2010, 1, 29, 0, 0, 0).ToUniversalTime(), after.Value.DateTime);
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:11,代码来源:CronExpressionTest.cs
示例14: CronCalendar
/// <summary>
/// Initializes a new instance of the <see cref="CronCalendar"/> class.
/// </summary>
/// <param name="expression">a string representation of the desired cron expression</param>
public CronCalendar(string expression)
{
cronExpression = new CronExpression(expression);
}
开发者ID:vaskosound,项目名称:FantasyLeagueStats,代码行数:8,代码来源:CronCalendar.cs
示例15: SetCronExpressionString
/// <summary>
/// Sets the cron expression for the calendar to a new value.
/// </summary>
/// <param name="expression">The expression.</param>
public void SetCronExpressionString(string expression)
{
CronExpression newExp = new CronExpression(expression);
cronExpression = newExp;
}
开发者ID:vaskosound,项目名称:FantasyLeagueStats,代码行数:9,代码来源:CronCalendar.cs
示例16: TestNthWeekDayPassingMonth
public void TestNthWeekDayPassingMonth()
{
CronExpression ce = new CronExpression("0 30 10-13 ? * FRI#3");
DateTime start = new DateTime(2008, 12, 19, 0, 0, 0);
for (int i = 0; i < 200; ++i)
{
bool shouldFire = (start.Hour >= 10 && start.Hour <= 13 && start.Minute == 30 && (start.DayOfWeek == DayOfWeek.Wednesday || start.DayOfWeek == DayOfWeek.Friday));
shouldFire = shouldFire && start.Day > 15 && start.Day < 28;
bool satisfied = ce.IsSatisfiedBy(start.ToUniversalTime());
Assert.AreEqual(shouldFire, satisfied);
// cycle with half hour precision
start = start.AddHours(0.5);
}
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:16,代码来源:CronExpressionTest.cs
示例17: TestYearChange
public void TestYearChange()
{
// QRTZNET-85
CronExpression cronExpression = new CronExpression("0 12 4 ? * 3");
cronExpression.GetNextValidTimeAfter(new DateTime(2007, 12, 28));
}
开发者ID:apobekiaris,项目名称:quartznet,代码行数:6,代码来源:CronExpressionTest.cs
示例18: TestDaylightSavingsDoesNotMatchAnHourBefore2
public void TestDaylightSavingsDoesNotMatchAnHourBefore2()
{
//another case
TimeZoneInfo est = TimeZoneUtil.FindTimeZoneById("Eastern Standard Time");
CronExpression expression = new CronExpression("0 0 0 ? * THU");
expression.TimeZone = est;
DateTimeOffset startTime = new DateTimeOffset(2012, 11, 4, 0, 0, 0, TimeSpan.Zero);
var actualTime = expression.GetTimeAfter(startTime);
DateTimeOffset expected = new DateTimeOffset(2012, 11, 8, 0, 0, 0, TimeSpan.FromHours(-5));
Assert.AreEqual(expected, actualTime);
}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:13,代码来源:CronExpressionTest.cs
示例19: TestDaylightSaving_QRTZNETZ186
public void TestDaylightSaving_QRTZNETZ186()
{
CronExpression expression = new CronExpression("0 15 * * * ?");
if (!TimeZoneInfo.Local.SupportsDaylightSavingTime)
{
return;
}
var daylightChange = TimeZone.CurrentTimeZone.GetDaylightChanges(2012);
DateTimeOffset before = daylightChange.Start.ToUniversalTime().AddMinutes(-5); // keep outside the potentially undefined interval
DateTimeOffset? after = expression.GetNextValidTimeAfter(before);
Assert.IsTrue(after.HasValue);
DateTimeOffset expected = daylightChange.Start.Add(daylightChange.Delta).AddMinutes(15).ToUniversalTime();
Assert.AreEqual(expected, after.Value);
}
开发者ID:CharlieBP,项目名称:quartznet,代码行数:14,代码来源:CronExpressionTest.cs
示例20: CronTrigger
public CronTrigger(CronExpression expression, TimeSpan fireOffset)
: base(fireOffset)
{
_expression = expression;
}
开发者ID:rgonek,项目名称:crongadgetry,代码行数:5,代码来源:CronTrigger.cs
注:本文中的CronExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论