in Job.Download/Download.cs [84:140]
public async Task Execute(IJobExecutionContext context)
{
try
{
log4net.Config.XmlConfigurator.Configure();
_context = context;
_settings.Initialize(context);
if (_settings.IndefinitePause)
{
await context.Scheduler.PauseJob(context.JobDetail.Key);
Log.InfoFormat(CultureInfo.InvariantCulture,
string.Format(Resources.Job_0_was_paused_indefinitely, _context.JobDetail.Key));
return;
}
_retryPolicyForIo = Policy.Handle<IOException>().WaitAndRetry(
retryCount: _settings.RetryCount,
sleepDurationProvider: attempt => TimeSpan.FromSeconds(_settings.RetryDelay),
onRetry: (exception, calculatedWaitDuration) =>
{
Log.WarnFormat(CultureInfo.InvariantCulture, string.Format(Resources.Job_0_Retrying_IO_operation_Exception_1, _context.JobDetail.Key, exception.Message));
});
if (_settings.LogVerbose || Log.IsDebugEnabled)
{
Log.DebugFormat(CultureInfo.InvariantCulture, string.Format(Resources.Job_0_starting, _context.JobDetail.Key));
}
await Process();
if (_settings.LogVerbose || Log.IsDebugEnabled)
{
Log.DebugFormat(CultureInfo.InvariantCulture, string.Format(Resources.Job_0_ended, _context.JobDetail.Key));
}
}
catch (Exception ex)
{
if (_settings.PauseJobOnException)
{
await context.Scheduler.PauseJob(context.JobDetail.Key);
Log.WarnFormat(CultureInfo.InvariantCulture,
string.Format(Resources.Job_0_was_paused_because_of_error, _context.JobDetail.Key));
}
if (_settings.LogVerbose || Log.IsDebugEnabled)
{
if (!string.IsNullOrEmpty(ex.Message))
{
Log.Error(ex.Message, ex);
}
}
if (context.Scheduler.SchedulerName != "Private")//only throw error when running as service
{
throw new JobExecutionException(string.Format(Resources.Download_job_0_failed, _context.JobDetail.Key), ex, false);
}
Log.Error(string.Format(Resources.Job_0_thrown_an_error_1, _context.JobDetail.Key, ex.Message));
}
}