|
|
@ -86,7 +86,8 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var pendingTimer in pendingJobs)
|
|
|
|
foreach (var pendingTimer in pendingJobs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var timerClass = _jobs.Where(t => t.GetType().ToString() == pendingTimer.TypeName).FirstOrDefault();
|
|
|
|
var timer = pendingTimer;
|
|
|
|
|
|
|
|
var timerClass = _jobs.Where(t => t.GetType().ToString() == timer.TypeName).FirstOrDefault();
|
|
|
|
Execute(timerClass.GetType());
|
|
|
|
Execute(timerClass.GetType());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -103,7 +104,6 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
/// Starts the execution of a job asynchronously
|
|
|
|
/// Starts the execution of a job asynchronously
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="jobType">Type of the job that should be executed.</param>
|
|
|
|
/// <param name="jobType">Type of the job that should be executed.</param>
|
|
|
|
/// <param name="queueAllowed">If the job is allowed to be queued in case another task is aready running.</param>
|
|
|
|
|
|
|
|
/// <param name="targetId">The targetId could be any Id parameter eg. SeriesId. it will be passed to the job implementation
|
|
|
|
/// <param name="targetId">The targetId could be any Id parameter eg. SeriesId. it will be passed to the job implementation
|
|
|
|
/// to allow it to filter it's target of execution.</param>
|
|
|
|
/// to allow it to filter it's target of execution.</param>
|
|
|
|
/// <returns>True if ran, false if skipped</returns>
|
|
|
|
/// <returns>True if ran, false if skipped</returns>
|
|
|
@ -221,8 +221,8 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
/// to allow it to filter it's target of execution</param>
|
|
|
|
/// to allow it to filter it's target of execution</param>
|
|
|
|
private void Execute(Type jobType, int targetId = 0)
|
|
|
|
private void Execute(Type jobType, int targetId = 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var timerClass = _jobs.Where(t => t.GetType() == jobType).FirstOrDefault();
|
|
|
|
var jobImplementation = _jobs.Where(t => t.GetType() == jobType).FirstOrDefault();
|
|
|
|
if (timerClass == null)
|
|
|
|
if (jobImplementation == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Error("Unable to locate implementation for '{0}'. Make sure its properly registered.", jobType.ToString());
|
|
|
|
Logger.Error("Unable to locate implementation for '{0}'. Make sure its properly registered.", jobType.ToString());
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -230,28 +230,28 @@ namespace NzbDrone.Core.Providers.Jobs
|
|
|
|
|
|
|
|
|
|
|
|
var settings = All().Where(j => j.TypeName == jobType.ToString()).FirstOrDefault();
|
|
|
|
var settings = All().Where(j => j.TypeName == jobType.ToString()).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
using (_notification = new ProgressNotification(timerClass.Name))
|
|
|
|
using (_notification = new ProgressNotification(jobImplementation.Name))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Logger.Debug("Starting job '{0}'. Last execution {1}", settings.Name, settings.LastExecution);
|
|
|
|
Logger.Debug("Starting job '{0}'. Last execution {1}", settings.Name, settings.LastExecution);
|
|
|
|
settings.LastExecution = DateTime.Now;
|
|
|
|
|
|
|
|
var sw = Stopwatch.StartNew();
|
|
|
|
var sw = Stopwatch.StartNew();
|
|
|
|
|
|
|
|
|
|
|
|
_notificationProvider.Register(_notification);
|
|
|
|
_notificationProvider.Register(_notification);
|
|
|
|
timerClass.Start(_notification, targetId);
|
|
|
|
jobImplementation.Start(_notification, targetId);
|
|
|
|
_notification.Status = ProgressNotificationStatus.Completed;
|
|
|
|
_notification.Status = ProgressNotificationStatus.Completed;
|
|
|
|
|
|
|
|
settings.LastExecution = DateTime.Now;//TODO: Should only be updated if targetId is 0.
|
|
|
|
settings.Success = true;
|
|
|
|
settings.Success = true;
|
|
|
|
sw.Stop();
|
|
|
|
sw.Stop();
|
|
|
|
Logger.Debug("Job '{0}' successfully completed in {1} seconds", timerClass.Name, sw.Elapsed.Minutes,
|
|
|
|
Logger.Debug("Job '{0}' successfully completed in {1} seconds", jobImplementation.Name, sw.Elapsed.Minutes,
|
|
|
|
sw.Elapsed.Seconds);
|
|
|
|
sw.Elapsed.Seconds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
settings.Success = false;
|
|
|
|
settings.Success = false;
|
|
|
|
Logger.ErrorException("An error has occurred while executing timer job " + timerClass.Name, e);
|
|
|
|
Logger.ErrorException("An error has occurred while executing timer job " + jobImplementation.Name, e);
|
|
|
|
_notification.CurrentMessage = timerClass.Name + " Failed.";
|
|
|
|
_notification.CurrentMessage = jobImplementation.Name + " Failed.";
|
|
|
|
_notification.Status = ProgressNotificationStatus.Failed;
|
|
|
|
_notification.Status = ProgressNotificationStatus.Failed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|