C# Quartz.NET:触发器是';未触发,未记录任何内容

C# Quartz.NET:触发器是';未触发,未记录任何内容,c#,quartz.net,quartz.net-2.0,C#,Quartz.net,Quartz.net 2.0,正如标题所说,我根本无法让Quartz.NET工作。我从NuGet获得了Quartz.NET(2.2.1)、common.logging(2.1.2)、common.logging.nlog(2.0.0)和nlog(2.1.0)的最新版本。触发器没有触发,石英绝对没有记录任何东西。我猜我把配置搞砸了 我的App.config: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSectio

正如标题所说,我根本无法让Quartz.NET工作。我从NuGet获得了Quartz.NET(2.2.1)、common.logging(2.1.2)、common.logging.nlog(2.0.0)和nlog(2.1.0)的最新版本。触发器没有触发,石英绝对没有记录任何东西。我猜我把配置搞砸了

我的App.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    ...

    <section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" />

    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>

  </configSections>

  <common>
    <logging>
      <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog">
        <arg key="configType" value="FILE" />
        <arg key="configFile" value="~/NLog.config" />
      </factoryAdapter>
    </logging>
  </common>

  <quartz>
    <add key="quartz.scheduler.instanceName" value="ServerScheduler" />

    <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
    <add key="quartz.threadPool.threadCount" value="10" />
    <add key="quartz.threadPool.threadPriority" value="2" />

    <add key="quartz.jobStore.misfireThreshold" value="60000" />
    <add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
  </quartz>

...

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
...
      <dependentAssembly>
        <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
调度程序已启动,作业和触发器已正确添加,否则日志记录将正常工作。下一次来来去去去,什么也没发生

触发器创建代码:

    ITrigger trigger = TriggerBuilder
        .Create()
        .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(jobDetails.Time.Hours, jobDetails.Time.Minutes))
        .StartNow()
        .WithIdentity(jobDetails.Name + "Trigger")
        .Build();

我已经转载了你的文章,这对我很有用:

ITrigger trigger = TriggerBuilder
    .Create()
    .WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(jobDetails.Time.Hours, jobDetails.Time.Minutes))
    .WithIdentity(jobDetails.Name + "Trigger")
    .Build();
卸下
.StartNow()
,触发器将触发


希望有帮助

根据您的信息,它应该会起作用;它应该每天运行一次

确保您已安装了通用日志记录工具]:

Install-Package Common.Logging.NLog20
并更改此部分:

  <common>
    <logging>
      <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
        <arg key="configType" value="FILE" />
        <arg key="configFile" value="~/NLog.config" />
      </factoryAdapter>
    </logging>
  </common>


QuartzNetDailyAtHourAndMinute.zip)。

如何创建触发器,能否向我们展示cron表达式?我已经用创建触发器的代码更新了问题。需要更多代码来重现问题:jobDetails声明(它来自哪里)以及如何将作业/触发器对添加到计划程序中。出于某种原因,使用DailyTimeIntervalsScheduleBuilder而不是CronScheduleBuilder使其正常工作。
  <common>
    <logging>
      <factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
        <arg key="configType" value="FILE" />
        <arg key="configFile" value="~/NLog.config" />
      </factoryAdapter>
    </logging>
  </common>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
private static void GetNext10FireTimes(ITrigger trigger)
{
    Console.WriteLine("List of next 10 schedules: ");

    var dt = trigger.GetNextFireTimeUtc();

    for (int i = 0; i < 10; i++)
    {
    if (dt == null)
        break;

    Console.WriteLine(dt.Value.ToLocalTime());

    dt = trigger.GetFireTimeAfter(dt);
    }
}