Quartz.Net系列(八):Trigger之CalendarIntervalScheduleBuilder详解
所有方法图

CalendarIntervalScheduleBuilder方法
在SimpleScheduleBuilder基础上实现了日、周、月、年
WithInterval:指定要生成触发器的时间单位和间隔。
WithIntervalInHours:指定要生成触发器的间隔按小时来
WithIntervalInMinutes:指定要生成触发器的间隔按分钟来
WithIntervalInSeconds:指定要生成触发器的间隔按秒来
WithIntervalInDays:指定要生成触发器的间隔按日来
WithIntervalInWeeks:指定要生成触发器的间隔按周来
WithIntervalInMonths:指定要生成触发器的间隔按月来
WithIntervalInYears:指定要生成触发器的间隔按年来
var trigger = TriggerBuilder.Create().WithCalendarIntervalSchedule(c=>c .WithInterval(1, IntervalUnit.Millisecond)
.WithIntervalInSeconds(1)
.WithIntervalInMinutes(1)
.WithIntervalInHours(1)
.WithIntervalInDays(1)
.WithIntervalInWeeks(1)
.WithIntervalInMonths(1)
.WithIntervalInYears(1)).Build();
注:按最后一个设定时间为准
最后指定给字段interval和intervalUnit,那么前面就会覆盖
在不指定间隔的时候默认是1,间隔单位是一天
public class CalendarIntervalScheduleBuilder : ScheduleBuilder<ICalendarIntervalTrigger>
{
private int interval = 1;
private IntervalUnit intervalUnit = IntervalUnit.Day; private int misfireInstruction = MisfireInstruction.SmartPolicy;
private TimeZoneInfo timeZone;
private bool preserveHourOfDayAcrossDaylightSavings;
private bool skipDayIfHourDoesNotExist;
}

/// <summary>
/// Supported interval units used by <see cref="ICalendarIntervalTrigger" />.
/// </summary>
public enum IntervalUnit
{
Millisecond,
Second,
Minute,
Hour,
Day,
Week,
Month,
Year
}
/// <summary>
/// Specify the time unit and interval for the Trigger to be produced.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="interval">the interval at which the trigger should repeat.</param>
/// <param name="unit"> the time unit (IntervalUnit) of the interval.</param>
/// <returns>the updated CalendarIntervalScheduleBuilder</returns>
/// <seealso cref="ICalendarIntervalTrigger.RepeatInterval" />
/// <seealso cref="ICalendarIntervalTrigger.RepeatIntervalUnit" />
public CalendarIntervalScheduleBuilder WithInterval(int interval, IntervalUnit unit)
{
ValidateInterval(interval);
this.interval = interval;
intervalUnit = unit;
return this;
} /// <summary>
/// Specify an interval in the IntervalUnit.SECOND that the produced
/// Trigger will repeat at.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="intervalInSeconds">the number of seconds at which the trigger should repeat.</param>
/// <returns>the updated CalendarIntervalScheduleBuilder</returns>
/// <seealso cref="ICalendarIntervalTrigger.RepeatInterval" />
/// <seealso cref="ICalendarIntervalTrigger.RepeatIntervalUnit" />
public CalendarIntervalScheduleBuilder WithIntervalInSeconds(int intervalInSeconds)
{
ValidateInterval(intervalInSeconds);
interval = intervalInSeconds;
intervalUnit = IntervalUnit.Second;
return this;
} /// <summary>
/// Specify an interval in the IntervalUnit.MINUTE that the produced
/// Trigger will repeat at.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="intervalInMinutes">the number of minutes at which the trigger should repeat.</param>
/// <returns>the updated CalendarIntervalScheduleBuilder</returns>
/// <seealso cref="ICalendarIntervalTrigger.RepeatInterval" />
/// <seealso cref="ICalendarIntervalTrigger.RepeatIntervalUnit" />
public CalendarIntervalScheduleBuilder WithIntervalInMinutes(int intervalInMinutes)
{
ValidateInterval(intervalInMinutes);
interval = intervalInMinutes;
intervalUnit = IntervalUnit.Minute;
return this;
} /// <summary>
/// Specify an interval in the IntervalUnit.HOUR that the produced
/// Trigger will repeat at.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="intervalInHours">the number of hours at which the trigger should repeat.</param>
/// <returns>the updated CalendarIntervalScheduleBuilder</returns>
/// <seealso cref="ICalendarIntervalTrigger.RepeatInterval" />
/// <seealso cref="ICalendarIntervalTrigger.RepeatIntervalUnit" />
public CalendarIntervalScheduleBuilder WithIntervalInHours(int intervalInHours)
{
ValidateInterval(intervalInHours);
interval = intervalInHours;
intervalUnit = IntervalUnit.Hour;
return this;
} /// <summary>
/// Specify an interval in the IntervalUnit.DAY that the produced
/// Trigger will repeat at.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="intervalInDays">the number of days at which the trigger should repeat.</param>
/// <returns>the updated CalendarIntervalScheduleBuilder</returns>
/// <seealso cref="ICalendarIntervalTrigger.RepeatInterval" />
/// <seealso cref="ICalendarIntervalTrigger.RepeatIntervalUnit" />
public CalendarIntervalScheduleBuilder WithIntervalInDays(int intervalInDays)
{
ValidateInterval(intervalInDays);
interval = intervalInDays;
intervalUnit = IntervalUnit.Day;
return this;
} /// <summary>
/// Specify an interval in the IntervalUnit.WEEK that the produced
/// Trigger will repeat at.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="intervalInWeeks">the number of weeks at which the trigger should repeat.</param>
/// <returns>the updated CalendarIntervalScheduleBuilder</returns>
/// <seealso cref="ICalendarIntervalTrigger.RepeatInterval" />
/// <seealso cref="ICalendarIntervalTrigger.RepeatIntervalUnit" />
public CalendarIntervalScheduleBuilder WithIntervalInWeeks(int intervalInWeeks)
{
ValidateInterval(intervalInWeeks);
interval = intervalInWeeks;
intervalUnit = IntervalUnit.Week;
return this;
} /// <summary>
/// Specify an interval in the IntervalUnit.MONTH that the produced
/// Trigger will repeat at.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="intervalInMonths">the number of months at which the trigger should repeat.</param>
/// <returns>the updated CalendarIntervalScheduleBuilder</returns>
/// <seealso cref="ICalendarIntervalTrigger.RepeatInterval" />
/// <seealso cref="ICalendarIntervalTrigger.RepeatIntervalUnit" />
public CalendarIntervalScheduleBuilder WithIntervalInMonths(int intervalInMonths)
{
ValidateInterval(intervalInMonths);
interval = intervalInMonths;
intervalUnit = IntervalUnit.Month;
return this;
} /// <summary>
/// Specify an interval in the IntervalUnit.YEAR that the produced
/// Trigger will repeat at.
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="intervalInYears">the number of years at which the trigger should repeat.</param>
/// <returns>the updated CalendarIntervalScheduleBuilder</returns>
/// <seealso cref="ICalendarIntervalTrigger.RepeatInterval" />
/// <seealso cref="ICalendarIntervalTrigger.RepeatIntervalUnit" />
public CalendarIntervalScheduleBuilder WithIntervalInYears(int intervalInYears)
{
ValidateInterval(intervalInYears);
interval = intervalInYears;
intervalUnit = IntervalUnit.Year;
return this;
}
InTimeZone:设置时区
var trigger = TriggerBuilder.Create().WithCalendarIntervalSchedule(c => c.InTimeZone(TimeZoneInfo.Local)).Build();
Quartz.Net系列(八):Trigger之CalendarIntervalScheduleBuilder详解的更多相关文章
- SpringBoot系列(十二)过滤器配置详解
SpringBoot(十二)过滤器详解 往期精彩推荐 SpringBoot系列(一)idea新建Springboot项目 SpringBoot系列(二)入门知识 springBoot系列(三)配置文件 ...
- 深入浅出Mybatis系列(四)---配置详解之typeAliases别名(mybatis源码篇)
上篇文章<深入浅出Mybatis系列(三)---配置详解之properties与environments(mybatis源码篇)> 介绍了properties与environments, ...
- Android Studio系列教程五--Gradle命令详解与导入第三方包
Android Studio系列教程五--Gradle命令详解与导入第三方包 2015 年 01 月 05 日 DevTools 本文为个人原创,欢迎转载,但请务必在明显位置注明出处!http://s ...
- 构建安全的Xml Web Service系列之wse之错误代码详解
原文:构建安全的Xml Web Service系列之wse之错误代码详解 WSE3.0现在还没有中文版的可以下载,使用英文版的过程中,难免会遇到各种各样的错误,而面对一堆毫无头绪的错误异常,常常会感到 ...
- [js高手之路] es6系列教程 - 对象功能扩展详解
第一:字面量对象的方法,支持缩写形式 //es6之前,这么写 var User = { name : 'ghostwu', showName : function(){ return this.nam ...
- ST MCU_GPIO的八种工作模式详解。
补充: N.P型的区别,就是一个为正电压启动(NMOS),一个为负电压启动(PMOS) GPIO的八种工作模式详解 浮空输入_IN_FLOATING带上拉输入_IPU带下拉输入_IPD模拟输入_AIN ...
- [转帖]Linux系列之SAR命令使用详解
Linux系列之SAR命令使用详解 sar是System Activity Reporter(系统活动情况报告)的缩写.这个工具所需要的负载很小,也是目前linux中最为全面的性能分析工具之一.此款工 ...
- Velocity魔法堂系列二:VTL语法详解
一.前言 Velocity作为历史悠久的模板引擎不单单可以替代JSP作为Java Web的服务端网页模板引擎,而且可以作为普通文本的模板引擎来增强服务端程序文本处理能力.而且Velocity被移植到不 ...
- quartz (从原理到应用)详解篇(转)
一.Quartz 基本介绍 1.1 Quartz 概述 1.2 Quartz特点 1.3 Quartz 集群配置 二.Quartz 原理及流程 2.1 quartz基本原理 2.2 quartz启动流 ...
- 实时通讯系列目录篇之SignalR详解
一. 简单说几句 最早使用SignalR的时候大约是两年前了,记得当时是一个OA中消息的实时提醒,轮询的方式有点耗资源,WebSocket写起来又比较麻烦,最终选择了SignalR,当时是什么版本已经 ...
随机推荐
- 【Azure Function App】Python Function调用Powershell脚本在Azure上执行失败的案例
问题描述 编写Python Function,并且在Function中通过 subprocess 调用powershell.exe 执行 powershell脚本. import azure.fun ...
- buffer busy waits等待事件案例-vage
转自vage 讨厌香草冰激凌的汽车与Buffer busy wiats的故事 记得好几年前看到过一个故事,通用公司曾收到一客户的邮件,邮件中客户描述了一个非常奇怪的问题.他们家有晚饭后去 ...
- RLChina2022公开课-博弈搜索算法
序列决策 序列决策问题一般用马尔可夫决策模型进行描述 搜索算法的优化
- 阿里发布AI编码助手:通义灵码,兼容 VS Code、IDEA等主流编程工具
今天是阿里云栖大会的第一天,相信场外的瓜,大家都吃过了.这里就不说了,有兴趣可以看看这里:云栖大会变成相亲现场,最新招婿鄙视链来了... . 这里主要说说阿里还发布了一款AI编码助手,对于我们开发者来 ...
- 数据结构-线性表-顺序表(c++)
SeqList.h #ifndef SEQLIST_H_ #define SEQLIST_H_ #include<iostream> const int Max=100; template ...
- [Python急救站课程]健康食谱搭配
健康食谱搭配输出 diet = ['西红柿', '花椰菜', '黄瓜', '牛排', '虾仁'] for x in range(0, 5): for y in range(0, 5): if not ...
- 一起来探索CSS中margin属性的奥秘吧!!
作者:WangMin 格言:努力做好自己喜欢的每一件事 众所周知 margin属性 是用来声明当前所设置或者指定元素所有外边距的宽度,或者设置各边上外边距的宽度.一直以来我认为它是一个很简单的属性,但 ...
- python中四种方法提升数据处理的速度
在数据科学计算.机器学习.以及深度学习领域,Python 是最受欢迎的语言.Python 在数据科学领域,有非常丰富的包可以选择,numpy.scipy.pandas.scikit-learn.mat ...
- wps表格求标准差怎么算?
在WPS表格中,要计算标准差,可以使用STDEV函数.标准差是一种衡量数据集合离散程度的统计指标.下面我将详细介绍如何使用STDEV函数来计算标准差. STDEV函数的语法为:STDEV(range) ...
- 介绍一个我开源的项目:一键部署 VictoriaMetrics 群集
作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢! cnblogs博客 zhihu Github 公众号:一本正经的瞎扯 我实在是非常喜欢这个强大的 metrics 监控组件 Vi ...