使用Quartz XML Schedule没有工作任务

时间:2013-10-07 19:34:48

标签: c# quartz-scheduler

我刚开始使用Quartz .NET。首先,我开发了一些代码并在代码中安排了作业和触发器,这些代码运行得很好:

            var job = JobBuilder.Create<MetaFileEngine>()
                .WithIdentity("MetaFileJob", "ThunderheadOutput")
                .Build();
            job.JobDataMap.Put("Repository", repository);
            var trigger = (ICronTrigger)TriggerBuilder.Create()
                             .WithIdentity("trigger1", "group1")
                             .WithCronSchedule("0,15 * 06-22 * * ?")
                             .Build(); 

但为了更灵活,我想使用XML作业调度。但当我跑的时候什么也没发生。我甚至没有看到创建的工作,但也没有错误。

这是代码:

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

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

            // 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"] = AppConfigHelper.Get("QaurtzXMLSchedule", string.Empty);


            ISchedulerFactory sf = new StdSchedulerFactory(properties);

和我的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>
      <name>MetaFileJob</name>
      <group>ThunderheadOutput</group>
      <description>process Metafiles generated by TH to tell where the letter was archived</description>
      <job-type>JE.Task.LMS.MetaFileEngine, JE.Task.LMS</job-type>
      <durable>false</durable>
      <recover>false</recover>
      <job-data-map>
        <entry>
          <key>key0</key>
          <value>value0</value>
        </entry>
        <entry>
          <key>key1</key>
          <value>value1</value>
        </entry>
        <entry>
          <key>key2</key>
          <value>value2</value>
        </entry>
      </job-data-map>
    </job>
    <trigger>
      <cron>
        <name>MetaFileTrigger</name>
        <group>ThunderheadOutput</group>
        <description>MetaFileTrigger Schedule</description>
        <job-name>MetaFileJob</job-name>
        <job-group>ThunderheadOutput</job-group>        
        <misfire-instruction>SmartPolicy</misfire-instruction>
        <cron-expression>0,15 * 06-22 * * ?</cron-expression>
      </cron>
    </trigger>
  </schedule>
</job-scheduling-data>

非常感谢任何见解。

1 个答案:

答案 0 :(得分:0)

问题最终是它没有将dll加载到exe bin文件夹中,因为我的代码实际上都没有从dll中调用任何内容。一旦我手动将其移动到exe bin文件夹,它就开始工作了。