在 C# 中清除quartz.net ramjobstore而不重新启动应用程序的正确方法是什么

发布于 2024-11-10 23:02:52 字数 138 浏览 3 评论 0原文

如果有办法做到这一点,我也可以通过查看清除之前和之后的 ramstore 来确认。我们如何以编程方式查看 ramstore 的内容?就我而言,我正在从文件中读取所有作业和触发器信息。在某些自定义事件中,我需要停止调度程序并重新开始,而无需重新启动应用程序。 谢谢

If there is a way to do this , can I also confirm by viewing the ramstore before and after clear. How can we view the contents of the ramstore programmatically ? In my case I am reading all job and trigger info from file. On some custom event I need to stop the scheduler and start all over again without re-starting the app.
thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

樱娆 2024-11-17 23:02:52

Quartz.NET 框架中的 RamJobStore 提供了多种方法来查看其内容,最简单的是“GetJobGroupNames()”和“GetJobNames()”函数:

public virtual string[] GetJobGroupNames( 
  SchedulingContext ctxt
)

public virtual string[] GetJobNames( 
  SchedulingContext ctxt,
  string groupName
)

您可以这样使用它:

foreach(string group in ramstore.GetJobGroupNames(...))
  foreach(string job in ramstore.GetJobNames(..., group))
    MessageBox.Show(String.Format("{0} (Group: {1})", job, group));

当然,这不是 你想要什么,因为它只会显示一个消息框,显示你在 RamJobStore 中的所有作业,但它确实允许你查看整个商店的内容。此外,您现在可以使用两种方法来删除所有作业。您可以使用函数“RemoveJob()”或“Shutdown()”。

foreach(string group in ramstore.GetJobGroupNames(...))
  foreach(string job in ramstore.GetJobNames(..., group))
    ramstore.RemoveJob(..., job, group);

这只会删除对象上的所有作业,但在大型商店中可能会很耗时。因此,还有一个“Shutdown()”函数,它只是从内存中删除整个存储(之后您可以创建一个新存储)。

我将...放入某些函数中,这是您最初用来存储作业的SchedulingContext

The RamJobStore from the Quartz.NET frameworks provides several methods to view it's contents, the easiest is the 'GetJobGroupNames()' and 'GetJobNames()' functions:

public virtual string[] GetJobGroupNames( 
  SchedulingContext ctxt
)

public virtual string[] GetJobNames( 
  SchedulingContext ctxt,
  string groupName
)

You can use it like this:

foreach(string group in ramstore.GetJobGroupNames(...))
  foreach(string job in ramstore.GetJobNames(..., group))
    MessageBox.Show(String.Format("{0} (Group: {1})", job, group));

Of course this is not what you want, since it will just show a message box for all the jobs you have in your RamJobStore, but it does allow you to view the contents of the entire store. Furthermore you can now use two methods to remove all the jobs. You can either use the function 'RemoveJob()' or 'Shutdown()'.

foreach(string group in ramstore.GetJobGroupNames(...))
  foreach(string job in ramstore.GetJobNames(..., group))
    ramstore.RemoveJob(..., job, group);

This will just remove all the jobs on the object, but might be time consuming on large store(s). Therefore there is also a 'Shutdown()' function, which just removes the entire store from memory (after which you can create a new one).

I put ... in some of the function(s), which is your SchedulingContext you've used to store the jobs in the first place.

蹲在坟头点根烟 2024-11-17 23:02:52

文档仅供参考:

Never use a JobStore instance directly in your code. 
For some reason many people attempt to do this.
The JobStore is for behind-the-scenes use of Quartz itself. 
You have to tell Quartz (through configuration) which JobStore 
to use, but then you should only work with the Scheduler interface
in your code.

在这里找到: http:// /www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/job-stores.html

根据我对quartz的有限经验,我认为你可以只获取调度程序的内容,然后关闭下调度程序并开始一个新的调度程序?

fyi from the documentation:

Never use a JobStore instance directly in your code. 
For some reason many people attempt to do this.
The JobStore is for behind-the-scenes use of Quartz itself. 
You have to tell Quartz (through configuration) which JobStore 
to use, but then you should only work with the Scheduler interface
in your code.

Found Here: http://www.quartz-scheduler.net/documentation/quartz-2.x/tutorial/job-stores.html

In my limited experience with quartz, i would think you could just grab the contents of the scheduler and then shut down the scheduler and start a new one?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文