我尝试在Quartz.net中使用ConTrigger添加添加计划开始日期时间和计划结束日期时间吗?
答案 0 :(得分: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;
}
}