2

我计划将 RAMJobStore 用于 Quartz.net。根据我的阅读,我们可以在 Xml 中配置作业,并让 Xml 插件在运行时读取作业并触发它们

但是是否有 API 可以编写新作业或以编程方式将现有更新到 Xml

4

1 回答 1

2

我不认为你能找到类似的东西,但你可以自己写。这是一个愚蠢的样本。
看看它。它可能会有所帮助:

jobschedulingdataSchedule[] jbSchedule = { new jobschedulingdataSchedule() };

jobdetailType[] jobs = {new jobdetailType() { description = "Blah" } };
triggerType[] triggers = {new triggerType() { Item = new simpleTriggerType() { description = "Blah" } } };
jbSchedule[0].job = jobs;
jbSchedule[0].trigger = triggers;

var quartzConfig = new QuartzXmlConfiguration20();
quartzConfig.version = "2.0";
quartzConfig.schedule = jbSchedule;

var quartzJobsXml = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "quartz_jobs.xml");
using (TextWriter textWriter = new StreamWriter(quartzJobsXml))
{
XmlSerializer serializer = new XmlSerializer(typeof(Quartz.Xml.JobSchedulingData20.QuartzXmlConfiguration20));
serializer.Serialize(textWriter, quartzConfig);
}
于 2012-12-05T10:48:51.720 回答