Quartz.NET,每 x 周重复一次
我需要使用 Quartz.NET 实现以下场景:
每 n 周重复一次:
星期日和/或星期一、星期二、星期三、星期四、星期五、星期六...
所以例如我可以选择:星期一和星期四,并且每两周重复一次,这可能吗?
我发现可行的方法可能是使用 Cron 表达式,但到目前为止我还没有运气好“每 X 周重复一次”
谢谢!
i need to implement the following scenario using Quartz.NET:
Recur every n week(s) on:
Sunday and/or Monday, Tuesday, Wednesday, Thursday, Friday, Saturday...
So for example i might select: monday and thursday, and recur every 2 weeks, is this possible?
I figure it out that the way to go might be using Cron Expressions, but i haven't had luck so far with the "Recur Every X Weeks"
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正在运行 Quartz.Net 2.0 和选项吗?它尚未正式发布,但其中有一种新的触发器类型可以解决您的问题。这称为日历间隔触发器。基本上你定义它就像你在问题中描述的那样。您将间隔设置为 2,间隔单位设置为周,并且每 2 周触发一次。我在此处写了一篇描述它的文章 。您可以在此处。
Is running Quartz.Net 2.0 and option for you? It has not been officially released yet, but in it there is a new trigger type that solves your problem. It's called the calendar interval trigger. Basically you define it just as you described in your question. You set the interval to 2 and the interval unit to weeks, and it fires every 2 weeks. I've written a post describing it here. You can access the source code documentation here.
这是我使用的解决方案...
当没有复发时,我使用 cron 触发器并选择日期并使其每周运行一次
。
0 0 * * 1,2,3
当每个选定的日子都有重复时,我添加一个 SimpleTrigger,基本上开始日期是一周中的某一天,然后我通过将重复乘以 7 来计算重复,
所以我最终会每天只需一个简单的触发器。
我希望这对其他人有帮助!
This is the solution that i used...
When there is no recurence i use a cron trigger and select the days and make it run every week
E.G.
0 0 * * 1,2,3
when there is recurence for each selected day i add a SimpleTrigger, bassically the start date is the day of the week, and then i calculate the recurrence by multiplying the recurence for 7
So i will end up wit one simpletrigger for each day.
I hope this helps someone else!
这是一个复杂的触发器,您可以通过3个触发器进行管理;
第一个触发器将创建 3。
第二个触发器将删除 3。
祝你好运。
It is a complext trigger, you can manage by 3 triggers;
first trigger will create 3.
second trigger will remove 3.
Good luck.
不幸的是,Quartz.Net 2 尚未发布、未记录,并且引入了重大更改。
就像奥雷里亚诺和邦戈所说,触发器的组合可能会有所帮助,但我不太明白他们各自的解决方案。
我的解决方案是包装 CronTrigger 并跳过不需要的事件:
Unfortunately Quartz.Net 2 is unreleased, undocumented, and introduces breaking changes.
Like Aureliano and Bongo say, a combination of triggers might help but I do not quite understand their respective solutions.
My solution is to wrap a CronTrigger and skip the unwanted events :