动态的排除一些触发器的时间。

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的更多相关文章

  1. Quartz Scheduler Calendar日历的使用

    Quartz Calendar 日历的使用 quartz引擎为我们提供了日历的功能,让我们可以自己定义一个时间段,可以控制触发器在这个时间段内触发或者不触发,比如可以设置节假日,工作时间早8晚5等等. ...

  2. Quartz任务调度基本使用

    转自:http://www.cnblogs.com/bingoidea/archive/2009/08/05/1539656.html 上一篇:定时器的实现.Java定时器Timer和Quartz介绍 ...

  3. Quartz 入门详解

    Quartz是OpenSymphony开源组织在Job scheduling领域又一个开源项目,它可以与J2EE与J2SE应用程序相结合也可以单独使用.Quartz可以用来创建简单或为运行十个,百个, ...

  4. 使用Quartz.NET进行任务调度管理

    1.Quartz.NET 介绍 Quartz.NET是一个开源的作业调度框架,是OpenSymphony 的 Quartz API的.NET移植,它用C#写成,可用于winform和asp.net应用 ...

  5. Quartz.NET开源作业调度框架系列(三):IJobExecutionContext 参数传递

    前面写了关于Quartz.NET开源作业调度框架的入门和Cron Trigger , 这次继续这个系列, 这次想讨论一下Quartz.NET中的Job如何通过执行上下文(Execution Conte ...

  6. Quartz集群

    为什么选择Quartz: 1)资历够老,创立于1998年,比struts1还早,但是一直在更新(27 April 2012: Quartz 2.1.5 Released),文档齐全. 2)完全由Jav ...

  7. Quartz任务调度快速入门(转)

    转自http://www.blogjava.net/baoyaer/articles/155645.html 概述 了解Quartz体系结构 Quartz对任务调度的领域问题进行了高度的抽象,提出了调 ...

  8. Quartz将Job保存在数据库中所需表的说明

    http://blog.iqbon.com/doc/364.html   (将Quartz持久化到数据库的做法)   QRTZ_CALENDARS 以 Blob 类型存储 Quartz 的 Calen ...

  9. 用Quartz进行作业调度(转)

    概述 各种企业应用几乎都会碰到任务调度的需求,就拿论坛来说:每隔半个小时生成精华文章的RSS文件,每天凌晨统计论坛用户的积分排名,每隔30分钟执行锁定用户解锁任务. 对于一个典型的MIS系统来说,在每 ...

随机推荐

  1. [WC2010]重建计划(长链剖分版)

    传送门 Description Solution 时隔多年,补上了这题的长链剖分写法 感觉比点分治要好写的多 我们假设\(pos\)是当前点的\(dfn\),它距离所在链的底端的边的数量是\(len\ ...

  2. Codeforces Round #576 (div.1 + div.2)

    Div2 A 长度为\(n(n≤10^5)\)的数组,每个元素不同,求有多少个位置\(d\)满足\(d - x \le j < d \And d < j \le d + y a_d< ...

  3. 生成uuid 和 检验

    //注意replaceAll前面的是正则表达式 String uuid = UUID.randomUUID().toString().replaceAll("-","&q ...

  4. C 套接字

    套接字函数 1 创建套接字──socket() 应用程序在使用套接字前,首先必须拥有一个套接字,系统调用socket()向应用程序提供创建套接字的手段,   其调用格式如下:SOCKET PASCAL ...

  5. MyBatis:MyBatis操作MySQL存储过程

    一 . 数据库中创建存储过程,并查看创建结果 1.创建存储过程 DROP procedure IF EXISTS net_procedure_request; DELIMITER $$ )) BEGI ...

  6. linux: 右键添加打开终端

    安装一个包,即可在右键里面添加一个“打开终端”的菜单. sudo apt-get install nautilus-open-terminal 注销用户重启,然后再进入就可以右键->在终端打开选 ...

  7. 识别哈希算法类型hash-identifier

    识别哈希算法类型hash-identifier hash-identifier是一款哈希算法识别工具.通过该工具,用户可以识别哈希值所使用的哈希算法.确定算法后,就可以采用对应的工具进行xx.执行该命 ...

  8. export,import ,export default

    a.js export var name="李四"; 或者: a.js var name1="李四"; var name2="张三"; ex ...

  9. linux非root用户安装4.0.14版本redis

    先到官网https://redis.io/download下安装包,现在最新是5.0.5版本,可惜点击下载后被windows禁了,那就下4版本的,往下看Other versions的Old(4.0), ...

  10. Sed之大小写转换

    使用sed进行大小写转换 大写转小写 echo "ABCD"|sed 's#[A-Z]#\l&#g' 小写转大写 echo "abcd"|sed 's# ...