2011-05-29 65 views
0

我按照Quartz手冊的要點操作,但仍然不確定爲什麼它不在GetDeal.vb(Quartz作業)中Global.asax。它永遠不會走進_scheduler.JobGroupNames_scheduler.TriggerGroupNames循環如下:似乎無法在VB.Net Web應用程序項目上生成Quartz .Net工作

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) 

    Dim factory As ISchedulerFactory = New StdSchedulerFactory() 
    _scheduler = factory.GetScheduler() 
    _scheduler.Start() 

    If _scheduler.IsStarted Then 
     Dim jobs As String = "" 
     Dim jobGroup As String = "" 
     For Each jobGroup In _scheduler.JobGroupNames 
      Dim jobName As String 
      For Each jobName In _scheduler.GetJobNames(jobGroup) 
       jobs = jobs + " " + jobName 
      Next 
     Next 

     jobs = "" 
     For Each jobGroup In _scheduler.TriggerGroupNames 
      Dim jobName As String 
      For Each jobName In _scheduler.GetTriggerNames(jobGroup) 
       jobs = jobs + " " + jobName 
      Next 
     Next 
    End If 

End Sub 

我們已經附上一個鏈接到這裏下載我的項目。有關如何使其工作的任何建議? - http://www.uniquevolve.com/YouMeCoupon.zip

回答

1

換工作的命名空間是這樣的:Namespace Jobs

這是一個完整的文件:

Imports Quartz 

' Namespace YouMeCoupon.Jobs 
Namespace Jobs 

Public Class GetDeal : Implements Quartz.IJob 


    Public Sub Execute(ByVal context As Quartz.JobExecutionContext) Implements Quartz.IJob.Execute 
     Dim data As JobDataMap = context.MergedJobDataMap 
     'Dim url As String = data.GetString("URL") 

     Try 
      Dim a As String 
      a = "testing" 

     Catch ex As Exception 

     End Try 

    End Sub 
End Class 

End Namespace 

我會建議你使用日誌系統調試Quartz.net。 你必須有這些引用:

Common.Logging.dll Common.Logging.NLog.dll NLog.dll

然後你就可以添加一個配置文件NLOG(NLog.config)

<?xml version="1.0" encoding="utf-8" ?> 
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > 
    <targets> 
     <target name="DebugHandler" type="File" filename="${basedir}/_Logs/${date:format=yyyyMMdd}_${level}.Log" 
      layout="${longdate} ${logger} ${aspnet-session:variable=UserName} ${threadid} ${environment} ${identity} ${aspnet-request} ${message} ${exception}" /> 
     <target name="ErrorHandler" type="File" filename="${basedir}/_Logs/${date:format=yyyyMMdd}_${level}.Log" 
      layout="${longdate} ${logger} ${aspnet-session:variable=UserName} ${threadid} ${environment} ${aspnet-request} ${message} ${exception}" /> 
     <target name="FatalHandler" type="File" filename="${basedir}/_Logs/${date:format=yyyyMMdd}_${level}.Log" 
      layout="${longdate} ${logger} ${aspnet-session:variable=UserName} ${threadid} ${environment} ${aspnet-request} ${message} ${exception}" /> 
     <target name="GenericHandler" type="File" filename="${basedir}/_Logs/${date:format=yyyyMMdd}_${level}.Log" 
      layout="${longdate} ${logger} ${aspnet-session:variable=UserName} ${threadid} ${environment} ${aspnet-request} ${message} ${exception}" /> 
    </targets> 
    <rules> 
     <logger name="*" level="Debug" appendTo="DebugHandler" /> 
     <logger name="*" level="Error" appendTo="ErrorHandler" /> 
     <logger name="*" level="Fatal" appendTo="FatalHandler" /> 
     <logger name="*" levels="Info,Warn" appendTo="GenericHandler" /> 
    </rules> 
</nlog> 

,改變你的web.config中添加以下部分:

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

<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> 

現在,一切都應該追溯到您的_Logs(您必須添加到您的項目中)。你更容易理解發生的事情。
您可以通過日誌記錄here找到更新的解決方案。 也檢查Quartz.net版本。在我看來,你沒有使用最後一個:1.3。

+0

將名稱空間從YouMeCoupon.Jobs更改爲作業完成了這項工作。你,萊夫蒂爵士,真是太棒了!感謝您向我展示如何完成日誌記錄。在此之前,我不知道如何寫入日誌。 :) – 2011-05-29 10:41:31

+0

記錄是非常重要的。這就是我發現你的問題;-) – LeftyX 2011-05-29 12:28:19

相關問題