无法通过quartz.net安排任务 [英] Unable to schedule tasks by quartz.net

查看:118
本文介绍了无法通过quartz.net安排任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是安排输出任务的主要步骤

Here is the main procedure for scheduling an output task

Public Sub ScheduleOutput()

    Dim sf As ISchedulerFactory = New StdSchedulerFactory()

    Dim scheduler As IScheduler = sf.GetScheduler()
    scheduler.Start()

    Dim job As IJobDetail = JobBuilder.Create(Of OutputJob)().
                WithIdentity("output", "output").Build()

    Dim trigger As ITrigger = TriggerBuilder.Create().
                WithIdentity("trigger", "trigger").ForJob("output").
                WithSchedule(CronScheduleBuilder.DailyAtHourAndMinute(setHour.Text, setMinute.Text)).
                Build()
    MsgBox("end")

End Sub



和工作班


and the job class

Public Class OutputJob
    Implements IJob
    
    Public Sub Execute(context As IJobExecutionContext) Implements IJob.Execute
    
        Output()
    
    End Sub
    
    Public Sub Output()
    
        Dim b = Convert.FromBase64String(HttpContext.Current.Request.Form("encodedhtml"))
        Dim html = System.Text.Encoding.UTF8.GetString(b)
            
        HttpContext.Current.Response.Clear()
        HttpContext.Current.Response.ContentType = "text/html"
        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=""Dashboard.html""")
        HttpContext.Current.Response.Write(html)
        HttpContext.Current.Response.End()
    
    End Sub
    
End Class



Web.config文件


Web.config file

<configuration>
  <configSections>
    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>
  <common>
    <logging>
      <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1213">
        <arg key="configType" value="INLINE"/>
        <arg key="configFile" value="~/log4net.config"/>
        <arg key="level" value="INFO" />
      </factoryAdapter>
    </logging>
  </common>
  <log4net>
    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%d [%t] %-5p %l - %m%n" />
      </layout>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="EventLogAppender" />
    </root>
  </log4net>
</configuration>



当我尝试运行代码时,异常发生在 Dim sf As ISchedulerFactory = New StdSchedulerFactory()


When I try to run the code, an exception occurred in Dim sf As ISchedulerFactory = New StdSchedulerFactory()

Quote:

在something.dll中发生类型'System.TypeInitializationException'的异常,但未在用户代码中处理其他信息:'Quartz.Impl.StdSchedulerFactory'的类型初始化程序引发了异常。

An exception of type 'System.TypeInitializationException' occurred in something.dll but was not handled in user codeAdditional information: The type initializer for 'Quartz.Impl.StdSchedulerFactory' threw an exception.



输出中的异常消息(显示在Visual Studio的底部):


Exception messages in the Output (shown at the bottom of Visual Studio):

Quote:

A C中发生了'Common.Logging.ConfigurationException'类型的第一次机会异常ommon.Logging.dll

在something.dll中发生'System.TypeInitializationException'类型的第一次机会异常

A first chance exception of type 'Common.Logging.ConfigurationException' occurred in Common.Logging.dll
A first chance exception of type 'System.TypeInitializationException' occurred in something.dll



如何修复异常?

以及代码中可能导致错误/异常的任何其他部分?



我尝试了什么:



我一直在努力争取这个并且已经寻找了很多解决方案,但是他们都没有真正帮助我(或者我只是不知道如何修改以适应我的代码)因为我真的缺乏关于任务调度和配置设置的知识。


How can I fix the exception?
And any other parts in the code that can cause errors/exceptions?

What I have tried:

I have struggled for long about this and have searched for a lot of solutions, but none of them can actually help me (or just I don't know how to modify in order to fit my code) because I really lack knowledge about task scheduling and configuration settings.

推荐答案

Quote:

因为我真的缺乏关于任务调度和配置设置的知识。

because I really lack knowledge about task scheduling and configuration settings.





什么版本的Quartz.Net和ASP。您使用的NET? Quartz.Net有一个网站,提供有关其用法的综合文档: Quartz Enterprise Scheduler .NET | Quartz.NET文档 [ ^ ]



只需选择您使用的版本,然后导航到相应的文档。如果您不熟悉它,请按照示例开始,只需进行简单的计划。如果它有效,你需要首先测试,所以从简单的开始。一旦您能够进行简单的调度工作,然后按照文档开始根据您的需要进行修改。



这是一篇很棒的文章,你也可以参考入门:使用Quartz.Net的ASP.NET中的计划任务 [ ^ ]


这篇关于无法通过quartz.net安排任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆