Quartz.Net—Calendar
动态的排除一些触发器的时间。
DailyCalendar-天日历
定义:
This implementation of the Calendar excludes (or includes - see below) a specified time range each day.
排除 天 内的一个时间段。或者叫做 在天上做减法操作。
private async void button8_Click_1(object sender, EventArgs e)
{
ISchedulerFactory sf = new StdSchedulerFactory();
var schdeler = await sf.GetScheduler();
await schedu.Start();
IJobDetail job = JobBuilder.Create<MyJob5>().WithDescription("JOB5").StoreDurably(true).Build(); //某一天的时间段上做减法操作。
DailyCalendar dailyCa = new DailyCalendar(DateBuilder.DateOf(, , ).DateTime, DateBuilder.DateOf(, , ).DateTime);
await schdeler.AddCalendar("ceshica", dailyCa,true,true); //ModifiedByCalendar 减去时间段
ITrigger trigger = TriggerBuilder.Create().WithCronSchedule("* * * * * ?").ModifiedByCalendar("ceshica").Build(); await schedu.ScheduleJob(job, trigger);
}
WeeklyCalendar-周日历
定义:
This implementation of the Calendar excludes a set of days of the week. You may use it to exclude weekends for example. But you may define any day of the week. By default it excludes Saturday and Sunday.
该日历的实现不包括一组星期的天数。你可以用它来排除周末。但是你可以定义一周中的任何一天。默认情况下,它不包括周六和周日。
private async void button9_Click(object sender, EventArgs e)
{
ISchedulerFactory sf = new StdSchedulerFactory();
var schdeler = await sf.GetScheduler();
await schedu.Start();
IJobDetail job = JobBuilder.Create<MyJob5>().WithDescription("JOB5").StoreDurably(true).Build(); //一周内 某些天数做减法。 默认周六周日是排除的。
WeeklyCalendar weekCa = new WeeklyCalendar(); weekCa.SetDayExcluded(DayOfWeek.Friday, true); await schdeler.AddCalendar("ceshica", weekCa, true, true); //ModifiedByCalendar 减去周内的 几天
ITrigger trigger = TriggerBuilder.Create().WithCronSchedule("* * * * * ?").ModifiedByCalendar("ceshica").Build(); await schedu.ScheduleJob(job, trigger);
}
HolidayCalendar-假期日历
定义:
This implementation of the Calendar stores a list of holidays (full days that are excluded from scheduling).
该日历的实现存储了一个假日列表(被排除在调度之外的完整天数)。
适合用在某一天 假期等,或者当年的某一天不能执行。
private async void button10_Click(object sender, EventArgs e)
{
ISchedulerFactory sf = new StdSchedulerFactory();
var schdeler = await sf.GetScheduler();
await schedu.Start();
IJobDetail job = JobBuilder.Create<MyJob5>().WithDescription("JOB5").StoreDurably(true).Build(); //制定某一天不能执行。 这个更加倾向于 holiday 假期。一般工作通过工作日历表中找出所有的假期,然后放入holidaycalendar。
HolidayCalendar holidayCa = new HolidayCalendar();
holidayCa.AddExcludedDate(DateTime.Now);//排除今天。
//holidayCa.RemoveExcludedDate(DateTime.Now);//后期可以动态处理
await schdeler.AddCalendar("ceshica", holidayCa, true, true); //ModifiedByCalendar 减去周内的 几天
ITrigger trigger = TriggerBuilder.Create().WithCronSchedule("* * * * * ?").ModifiedByCalendar("ceshica").Build(); await schedu.ScheduleJob(job, trigger);
}
MonthlyCalendar-月日历
定义:
This implementation of the Calendar excludes a set of days of the month. You may use it to exclude every 1. of each month for example. But you may define any day of a month.
这个日历的实现不包括一个月的天数。你可以用它来排除每个月一号。但是你也可以定义一个月的任何一天。
private async void button11_Click(object sender, EventArgs e)
{
ISchedulerFactory sf = new StdSchedulerFactory();
var schdeler = await sf.GetScheduler();
await schedu.Start();
IJobDetail job = JobBuilder.Create<MyJob5>().WithDescription("JOB5").StoreDurably(true).Build(); MonthlyCalendar monthlyCa = new MonthlyCalendar();
//月份中的某一天不能被执行。
monthlyCa.SetDayExcluded(, true); await schdeler.AddCalendar("ceshica", monthlyCa, true, true); //ModifiedByCalendar 减去周内的 几天
ITrigger trigger = TriggerBuilder.Create().WithCronSchedule("* * * * * ?").ModifiedByCalendar("ceshica").Build(); await schedu.ScheduleJob(job, trigger); }
AnnualCalendar-年日历
定义:
This implementation of the Calendar excludes a set of days of the year. You may use it to exclude bank holidays which are on the same date every year.
该日历的实现不包括一组年份。你可以用它来排除每年同一日期的银行假日。 适合每年的每一天不能执行 比如说国庆节 不干活。
private async void button12_Click(object sender, EventArgs e)
{
ISchedulerFactory sf = new StdSchedulerFactory();
var schdeler = await sf.GetScheduler();
await schedu.Start();
IJobDetail job = JobBuilder.Create<MyJob5>().WithDescription("JOB5").StoreDurably(true).Build() AnnualCalendar annualCa = new AnnualCalendar();
//每年这几天不执行
annualCa.SetDayExcluded(new DateTime(, , ), true);
annualCa.SetDayExcluded(new DateTime(, , ), true);
annualCa.SetDayExcluded(new DateTime(, , ), true);
annualCa.SetDayExcluded(new DateTime(, ,), true);
annualCa.SetDayExcluded(new DateTime(, , ), true);
annualCa.SetDayExcluded(new DateTime(, , ), true);
annualCa.SetDayExcluded(new DateTime(, , ), true); annualCa.SetDayExcluded(new DateTime(, , ), true); await schdeler.AddCalendar("ceshica", annualCa, true, true); //ModifiedByCalendar
ITrigger trigger = TriggerBuilder.Create().WithCronSchedule("* * * * * ?").ModifiedByCalendar("ceshica").Build(); await schedu.ScheduleJob(job, trigger);
}
CronCalendar-Cron日历
定义:
This implementation of the Calendar excludes the set of times expressed by a given CronExpression.
该日历的实现不包括给定的CronExpression所表示的时间集合。 也就是排除cron时间。
private async void button13_Click(object sender, EventArgs e)
{
ISchedulerFactory sf = new StdSchedulerFactory();
var schdeler = await sf.GetScheduler();
await schedu.Start();
IJobDetail job = JobBuilder.Create<MyJob5>().WithDescription("JOB5").StoreDurably(true).Build(); CronCalendar cronCa = new CronCalendar("1,5,10,15,20,25,30,35,40,45,50,55 * * * * ?"); await schdeler.AddCalendar("ceshica", cronCa, true, true); //ModifiedByCalendar
ITrigger trigger = TriggerBuilder.Create().WithCronSchedule("* * * * * ?").ModifiedByCalendar("ceshica").Build(); await schedu.ScheduleJob(job, trigger);
}
Quartz.Net—Calendar的更多相关文章
- Quartz Scheduler Calendar日历的使用
Quartz Calendar 日历的使用 quartz引擎为我们提供了日历的功能,让我们可以自己定义一个时间段,可以控制触发器在这个时间段内触发或者不触发,比如可以设置节假日,工作时间早8晚5等等. ...
- Quartz任务调度基本使用
转自:http://www.cnblogs.com/bingoidea/archive/2009/08/05/1539656.html 上一篇:定时器的实现.Java定时器Timer和Quartz介绍 ...
- Quartz 入门详解
Quartz是OpenSymphony开源组织在Job scheduling领域又一个开源项目,它可以与J2EE与J2SE应用程序相结合也可以单独使用.Quartz可以用来创建简单或为运行十个,百个, ...
- 使用Quartz.NET进行任务调度管理
1.Quartz.NET 介绍 Quartz.NET是一个开源的作业调度框架,是OpenSymphony 的 Quartz API的.NET移植,它用C#写成,可用于winform和asp.net应用 ...
- Quartz.NET开源作业调度框架系列(三):IJobExecutionContext 参数传递
前面写了关于Quartz.NET开源作业调度框架的入门和Cron Trigger , 这次继续这个系列, 这次想讨论一下Quartz.NET中的Job如何通过执行上下文(Execution Conte ...
- Quartz集群
为什么选择Quartz: 1)资历够老,创立于1998年,比struts1还早,但是一直在更新(27 April 2012: Quartz 2.1.5 Released),文档齐全. 2)完全由Jav ...
- Quartz任务调度快速入门(转)
转自http://www.blogjava.net/baoyaer/articles/155645.html 概述 了解Quartz体系结构 Quartz对任务调度的领域问题进行了高度的抽象,提出了调 ...
- Quartz将Job保存在数据库中所需表的说明
http://blog.iqbon.com/doc/364.html (将Quartz持久化到数据库的做法) QRTZ_CALENDARS 以 Blob 类型存储 Quartz 的 Calen ...
- 用Quartz进行作业调度(转)
概述 各种企业应用几乎都会碰到任务调度的需求,就拿论坛来说:每隔半个小时生成精华文章的RSS文件,每天凌晨统计论坛用户的积分排名,每隔30分钟执行锁定用户解锁任务. 对于一个典型的MIS系统来说,在每 ...
随机推荐
- SVN优于CVS之处
1.原子提交.一次提交不管是单个还是多个文件,都是作为一个整体提交的.在这当中发生的意外例如传输中断,不会引起数据库的不完整和数据损坏. 2.重命名.复制.删除文件等动作都保存在版本历史记录当中. 3 ...
- 【知识点】Java机密
Java添加PDF图章.动态图章 主要实现以下功能: 添加图片图章.即通过加载现有的图章(以图片形式),添加到PDF指定页面位置 添加动态图章.即加载PDF文档,并在动态的添加印章内容,包括印章字样. ...
- FCN笔记
FCN.py tensorflow命令行参数 FLAGS = tf.flags.FLAGS tf.flags.DEFINE_integer("batch_size", " ...
- 生成uuid 和 检验
//注意replaceAll前面的是正则表达式 String uuid = UUID.randomUUID().toString().replaceAll("-","&q ...
- Java 面向对象(十五)
Lambda表达式 1. 函数式编程思想概述 在数学中,函数就是有输入量.输出量的一套计算方案,也就是"拿什么东西做什么事情".相对而言,面向对象过分强调"必须通过对象的 ...
- Gated CNN 阅读笔记
之前看过TCN,稍微了解了一下语言模型,这篇论文也是对语言模型建模,但是由于对语言模型了解不深,一些常用数据处理方法,训练损失的计算包括残差都没有系统的看过,只是参考网上代码对论文做了粗浅的复现.开学 ...
- PostgreSQL远程连接,发生致命错误:没有用于主机“…”,用户“…”,数据库“…”,SSL关闭的pg_hba.conf记录
PostgreSQL远程连接方法 有时候在远程连接时,会报Error connecting to the server:致命错误:没有用于主机“…”,用户“…”,数据库“…”,SSL关闭的pg_hba ...
- Java上传视频(mencoder)
页面: 上传文件时的关键词:enctype="multipart/form-data" <%@ page language="java" import=& ...
- ubuntu18.04 qemu环境搭建【学习笔记】
一.准备工具 1.1 安装相关工具 sudo apt-get install qemu libncurses5-dev gcc-arm-linux-gnueabi build-essential 1. ...
- np.vstack()和np.hstack()
本文链接:https://blog.csdn.net/m0_37393514/article/details/79538748在这里我们介绍两个拼接数组的方法: np.vstack():在竖直方向上堆 ...