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 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>
When I try to run the code, an exception occurred in
Dim sf As ISchedulerFactory = New StdSchedulerFactory()
Quote:
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.
Exception messages in the Output (shown at the bottom of Visual Studio):
Quote:
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.