quartz.net 抽象基类
此链接建议创建一个抽象基类,该基类可以读取 Quartz.net 的作业数据映射信息,并且每个作业都将从该基类派生。
http://quartznet.sourceforge.net/faq.html#howtochainjobs
有人可以提供吗我是这个基类的示例,因为我不确定如何检索基类中的作业详细信息,然后调用派生类上的 Execute 方法?
普拉蒂克
This link suggests to create an abstract base class that can read the job data map information for Quartz.net and each of the jobs will derive from this base class.
http://quartznet.sourceforge.net/faq.html#howtochainjobs
Can someone provide me a sample of this base class because I am not sure how to retrieve the job details in the base class and then call the Execute method on the derived class?
Pratik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建抽象基类只是 Quartz.NET 文档提出的建议,并不是实现作业链的要求。基本上他们建议如果你想链接工作:“AJob”-> “B工作”-> “CJob”,您将按照以下方式执行操作:
创建抽象类“ChainBaseJob”。
使您的作业类(AJob 和 BJob 都是其类型)从 ChainBaseJob 继承。
ChainBaseJob 将包含某种方法,例如:
...它将返回作业的名称(即 Quartz 作业名称)。有多种方法可以使用它,但我想文档建议您的 TriggerListener 检查(在作业完成方法期间)是否已完成的作业(假设“AJob”)继承自 ChainBaseJob。如果是,它将转换它并调用 GetNextJobInChain,并使用该方法返回的名称来调用调度程序以在 AJob 完成时执行它。如果一切都正确实现,则 TriggerListener 将知道在 AJob 完成后执行 BJob。
祝你好运。
Creating an abstract base class is just a suggestion made by the Quartz.NET documentation, and is not a requirement for implementing job chaining. Basically they are suggesting that if you want to chain jobs: "AJob" -> "BJob" -> "CJob", you would do something along the lines of this:
Create abstract class "ChainBaseJob".
Make your job class (which both AJob and BJob are types of) inherit from ChainBaseJob.
ChainBaseJob would contain some sort of method like:
...which would return the name of the job (meaning the Quartz job name). There's a variety of ways to do use this, but I guess the documentation is suggesting that your TriggerListener checks to see (during the job completed method) if a completed job (let's say "AJob") inherits from ChainBaseJob. If it does, it will cast it and call GetNextJobInChain, and use the name returned by the method to call the scheduler to execute it upon completion of AJob. If everything is implemented correctly, the TriggerListener will know to execute BJob, after AJob completes.
Good luck.