mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
Moved Jobs to their own folder.
This commit is contained in:
parent
cc8c70d7f5
commit
fabc4c84bd
52 changed files with 124 additions and 132 deletions
59
NzbDrone.Core/Jobs/DeleteSeriesJob.cs
Normal file
59
NzbDrone.Core/Jobs/DeleteSeriesJob.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Jobs;
|
||||
|
||||
namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class DeleteSeriesJob : IJob
|
||||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
[Inject]
|
||||
public DeleteSeriesJob(SeriesProvider seriesProvider)
|
||||
{
|
||||
_seriesProvider = seriesProvider;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Delete Series"; }
|
||||
}
|
||||
|
||||
public int DefaultInterval
|
||||
{
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
|
||||
{
|
||||
DeleteSeries(notification, targetId);
|
||||
}
|
||||
|
||||
private void DeleteSeries(ProgressNotification notification, int seriesId)
|
||||
{
|
||||
Logger.Warn("Deleting Series [{0}]", seriesId);
|
||||
|
||||
try
|
||||
{
|
||||
var title = _seriesProvider.GetSeries(seriesId).Title;
|
||||
|
||||
notification.CurrentMessage = String.Format("Deleting '{0}' from database", title);
|
||||
|
||||
_seriesProvider.DeleteSeries(seriesId);
|
||||
|
||||
notification.CurrentMessage = String.Format("Successfully deleted '{0}' from database", title);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorException("An error has occurred while deleting series: " + seriesId, e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue