gpt4 book ai didi

asp.net - 来自ASP.NET中config.xml的Quartz.NET

转载 作者:行者123 更新时间:2023-12-04 18:12:39 25 4
gpt4 key购买 nike

有人可以建议我做错了什么吗?
我试图设置 quartz ,以便在启动时将读取一个xml配置文件。在文件中,有一个激活我的HelloEmail_Job.cs类的作业(它是正确创建的,使用execute方法中的逻辑扩展了IJob)。 xml还为该作业提供了cron触发器,该触发器将每分钟触发一次(纯粹用于测试)。

但是,一切启动时都没有错误,但是该工作从未执行。我确定我配置错误。

我有一个处理我的调度程序的单例,调度程序在应用程序启动时启动(在global.asax文件中)

    NameValueCollection properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "RemoteServer";

////// set thread pool info
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "5";
properties["quartz.threadPool.threadPriority"] = "Normal";

properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
properties["quartz.jobStore.useProperties"] = "true";
properties["quartz.jobStore.dataSource"] = "default";
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";
properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";

properties["quartz.dataSource.default.connectionString"] = "Data Source=CRAIG-PC\\SQLEXPRESS;Initial Catalog=MCWdb;User ID=sa;Password=mastercrud;";
properties["quartz.dataSource.default.provider"] = "SqlServer-20";

// job initialization plugin handles our xml reading, without it defaults are used
properties["quartz.plugin.xml.type"] = "Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz";
properties["quartz.plugin.xml.fileNames"] = "~/quartz_jobs.xml";

ISchedulerFactory sf = new StdSchedulerFactory(properties);
_sched = sf.GetScheduler();

我的 quartz_jobs.xml文件如下所示:
        <?xml version="1.0" encoding="UTF-8"?>

<job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0">

<processing-directives>
<overwrite-existing-data>true</overwrite-existing-data>
</processing-directives>

<schedule>
<job>
<job-detail>
<name>MyJob</name>
<group>MyJobs</group>
<description>sends out a test email</description>
<job-type>HelloEmail_Job</job-type>
<volatile>false</volatile>
<durable>true</durable>
<recover>false</recover>
<job-data-map>
<entry>
<key>Body</key>
<value>Hello From your website!!!!!!!!</value>
</entry>
</job-data-map>
</job-detail>
<trigger>
<cron>
<name>MyJobTrigger</name>
<group>MyJobs</group>
<description>A description</description>
<job-name>MyJob</job-name>
<job-group>MyJobs</job-group>
<cron-expression>0 0/1 * 1/1 * ? *</cron-expression>
</cron>
</trigger>
</job>
</schedule>

</job-scheduling-data>

我知道,通过一个简单的触发器,该调度程序即可针对即席作业正确运行,因为当我的应用程序创建它们并对其进行动态调度时,它可以完美地工作。但是我希望逻辑可以重复(通过cron),并且可以通过xml配置。

我的直觉是,JOB_TYPE值是错误的。

最佳答案

您的工作类型需要指定为

<job-type>Fully.Qualified.Type.Name, AssemblyNameWithoutTheDllExtension</job-type>

关于asp.net - 来自ASP.NET中config.xml的Quartz.NET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10296383/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com