我正在尝试使用 ConTrigger 添加计划开始日期时间和计划结束日期时间,这在 Quartz.net 中是否可行?
问问题
165 次
1 回答
0
是的,CronTrigger 支持这一点。CronTriggerImpl 有一个构造函数,允许你这样做:
/// <summary>
/// Create a <see cref="CronTriggerImpl" /> with fire time dictated by the
/// <param name="cronExpression" /> resolved with respect to the specified
/// <param name="timeZone" /> occurring from the <see cref="startTimeUtc" /> until
/// the given <paran name="endTimeUtc" />.
/// </summary>
/// <param name="name">The name of the <see cref="ITrigger" /></param>
/// <param name="group">The group of the <see cref="ITrigger" /></param>
/// <param name="jobName">name of the <see cref="IJobDetail" /> executed on firetime</param>
/// <param name="jobGroup">Group of the <see cref="IJobDetail" /> executed on firetime</param>
/// <param name="startTimeUtc">A <see cref="DateTimeOffset" /> set to the earliest time for the <see cref="ITrigger" /> to start firing.</param>
/// <param name="endTime">A <see cref="DateTimeOffset" /> set to the time for the <see cref="ITrigger" /> to quit repeat firing.</param>
public CronTriggerImpl(string name, string group, string jobName,
string jobGroup, DateTimeOffset startTimeUtc,
DateTimeOffset? endTime,
string cronExpression,
TimeZoneInfo timeZone) : base(name, group, jobName, jobGroup)
{
CronExpressionString = cronExpression;
if (startTimeUtc == DateTimeOffset.MinValue)
{
startTimeUtc = SystemTime.UtcNow();
}
StartTimeUtc = startTimeUtc;
if (endTime.HasValue)
{
EndTimeUtc = endTime;
}
if (timeZone == null)
{
timeZone = TimeZoneInfo.Local;
}
else
{
TimeZone = timeZone;
}
}
于 2014-06-26T18:12:48.473 回答