mirror of https://github.com/Radarr/Radarr
ConfigProvider now uses PetaPoco
This commit is contained in:
parent
b1130855cf
commit
190ce6b142
|
@ -1,4 +1,5 @@
|
||||||
using AutoMoq;
|
using AutoMoq;
|
||||||
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
|
@ -13,52 +14,81 @@ namespace NzbDrone.Core.Test
|
||||||
public class ConfigProviderTest : TestBase
|
public class ConfigProviderTest : TestBase
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void Overwrite_existing_value()
|
public void Add_new_value_to_database()
|
||||||
{
|
{
|
||||||
const string key = "MY_KEY";
|
const string key = "MY_KEY";
|
||||||
const string value = "MY_VALUE";
|
const string value = "MY_VALUE";
|
||||||
|
|
||||||
//Arrange
|
|
||||||
var config = new Config {Key = key, Value = value};
|
|
||||||
|
|
||||||
var mocker = new AutoMoqer();
|
var mocker = new AutoMoqer();
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
mocker.GetMock<IRepository>()
|
mocker.SetConstant(db);
|
||||||
.Setup(r => r.Single<Config>(key))
|
|
||||||
.Returns(config);
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<ConfigProvider>().SetValue(key, value);
|
mocker.Resolve<ConfigProvider>().SetValue(key, value);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
mocker.GetMock<IRepository>().Verify(c => c.Update(config));
|
mocker.Resolve<ConfigProvider>().GetValue(key, "").Should().Be(value);
|
||||||
mocker.GetMock<IRepository>().Verify(c => c.Add(It.IsAny<Config>()), Times.Never());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Add_new_value()
|
public void Get_value_from_database()
|
||||||
{
|
{
|
||||||
const string key = "MY_KEY";
|
const string key = "MY_KEY";
|
||||||
const string value = "MY_VALUE";
|
const string value = "MY_VALUE";
|
||||||
|
|
||||||
//Arrange
|
|
||||||
var mocker = new AutoMoqer();
|
var mocker = new AutoMoqer();
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
mocker.GetMock<IRepository>()
|
db.Insert(new Config { Key = key, Value = value });
|
||||||
.Setup(r => r.Single<Config>(It.IsAny<string>()))
|
|
||||||
.Returns<Config>(null)
|
|
||||||
.Verifiable();
|
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<ConfigProvider>().SetValue(key, value);
|
var result = mocker.Resolve<ConfigProvider>().GetValue(key, "");
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
mocker.GetMock<IRepository>().Verify();
|
result.Should().Be(value);
|
||||||
mocker.GetMock<IRepository>().Verify(r => r.Update(It.IsAny<Config>()), Times.Never());
|
|
||||||
mocker.GetMock<IRepository>().Verify(r => r.Add(It.Is<Config>(c => c.Key == key && c.Value == value)),
|
|
||||||
Times.Once());
|
|
||||||
|
|
||||||
Assert.Pass();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Get_value_should_return_default_when_no_value()
|
||||||
|
{
|
||||||
|
const string key = "MY_KEY";
|
||||||
|
const string value = "MY_VALUE";
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
|
|
||||||
|
//Act
|
||||||
|
var result = mocker.Resolve<ConfigProvider>().GetValue(key, value);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().Be(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void New_value_should_update_old_value()
|
||||||
|
{
|
||||||
|
const string key = "MY_KEY";
|
||||||
|
const string originalValue = "OLD_VALUE";
|
||||||
|
const string newValue = "NEW_VALUE";
|
||||||
|
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
var db = MockLib.GetEmptyDatabase();
|
||||||
|
mocker.SetConstant(db);
|
||||||
|
|
||||||
|
db.Insert(new Config { Key = key, Value = originalValue });
|
||||||
|
|
||||||
|
//Act
|
||||||
|
mocker.Resolve<ConfigProvider>().SetValue(key, newValue);
|
||||||
|
var result = mocker.Resolve<ConfigProvider>().GetValue(key, "");
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
result.Should().Be(newValue);
|
||||||
|
db.Fetch<Config>().Should().HaveCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -126,8 +126,6 @@ namespace NzbDrone.Core.Test.Framework
|
||||||
|
|
||||||
private static void ForceMigration(IRepository repository)
|
private static void ForceMigration(IRepository repository)
|
||||||
{
|
{
|
||||||
repository.All<Series>().Count();
|
|
||||||
repository.All<Episode>().Count();
|
|
||||||
repository.All<EpisodeFile>().Count();
|
repository.All<EpisodeFile>().Count();
|
||||||
repository.All<QualityProfile>().Count();
|
repository.All<QualityProfile>().Count();
|
||||||
repository.All<History>().Count();
|
repository.All<History>().Count();
|
||||||
|
|
|
@ -45,6 +45,12 @@ namespace NzbDrone.Core.Datastore.Migrations
|
||||||
.WithNullableColumn("GrabDate", DbType.DateTime);
|
.WithNullableColumn("GrabDate", DbType.DateTime);
|
||||||
|
|
||||||
|
|
||||||
|
db.CreateTable("Config")
|
||||||
|
.WithNotNullableColumn("Key", DbType.String).Unique()
|
||||||
|
.WithNotNullableColumn("Value", DbType.String);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ using Ninject;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
|
using PetaPoco;
|
||||||
using SubSonic.Repository;
|
using SubSonic.Repository;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers.Core
|
namespace NzbDrone.Core.Providers.Core
|
||||||
|
@ -12,17 +13,18 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
public class ConfigProvider
|
public class ConfigProvider
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly IRepository _repository;
|
private readonly IDatabase _database;
|
||||||
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public ConfigProvider(IRepository repository)
|
public ConfigProvider(IDatabase database)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_database = database;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<Config> All()
|
public IList<Config> All()
|
||||||
{
|
{
|
||||||
return _repository.All<Config>().ToList();
|
return _database.Fetch<Config>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigProvider()
|
public ConfigProvider()
|
||||||
|
@ -129,7 +131,7 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
|
|
||||||
public virtual String SabHost
|
public virtual String SabHost
|
||||||
{
|
{
|
||||||
get { return GetValue("SabHost", "localhost", true); }
|
get { return GetValue("SabHost", "localhost"); }
|
||||||
|
|
||||||
set { SetValue("SabHost", value); }
|
set { SetValue("SabHost", value); }
|
||||||
}
|
}
|
||||||
|
@ -164,7 +166,7 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
|
|
||||||
public virtual String SabTvCategory
|
public virtual String SabTvCategory
|
||||||
{
|
{
|
||||||
get { return GetValue("SabTvCategory", "TV", false); }
|
get { return GetValue("SabTvCategory", "TV"); }
|
||||||
|
|
||||||
set { SetValue("SabTvCategory", value); }
|
set { SetValue("SabTvCategory", value); }
|
||||||
}
|
}
|
||||||
|
@ -178,7 +180,7 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
|
|
||||||
public virtual String SabDropDirectory
|
public virtual String SabDropDirectory
|
||||||
{
|
{
|
||||||
get { return GetValue("SabTvDropDirectory", "", false); }
|
get { return GetValue("SabTvDropDirectory"); }
|
||||||
|
|
||||||
set { SetValue("SabTvDropDirectory", value); }
|
set { SetValue("SabTvDropDirectory", value); }
|
||||||
}
|
}
|
||||||
|
@ -230,7 +232,7 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
|
|
||||||
public virtual string SeasonFolderFormat
|
public virtual string SeasonFolderFormat
|
||||||
{
|
{
|
||||||
get { return GetValue("Sorting_SeasonFolderFormat", "Season %s", false); }
|
get { return GetValue("Sorting_SeasonFolderFormat", "Season %s"); }
|
||||||
set { SetValue("Sorting_SeasonFolderFormat", value); }
|
set { SetValue("Sorting_SeasonFolderFormat", value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,31 +263,29 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
|
|
||||||
private string GetValue(string key)
|
private string GetValue(string key)
|
||||||
{
|
{
|
||||||
return GetValue(key, String.Empty, false);
|
return GetValue(key, String.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool GetValueBoolean(string key, bool defaultValue = false)
|
private bool GetValueBoolean(string key, bool defaultValue = false)
|
||||||
{
|
{
|
||||||
return Convert.ToBoolean(GetValue(key, defaultValue, false));
|
return Convert.ToBoolean(GetValue(key, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetValueInt(string key, int defaultValue = 0)
|
private int GetValueInt(string key, int defaultValue = 0)
|
||||||
{
|
{
|
||||||
return Convert.ToInt16(GetValue(key, defaultValue, false));
|
return Convert.ToInt16(GetValue(key, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string GetValue(string key, object defaultValue, bool makePermanent)
|
public virtual string GetValue(string key, object defaultValue)
|
||||||
{
|
{
|
||||||
string value;
|
string value;
|
||||||
|
|
||||||
var dbValue = _repository.Single<Config>(key);
|
var dbValue = _database.SingleOrDefault<Config>(key);
|
||||||
|
|
||||||
if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value))
|
if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value))
|
||||||
return dbValue.Value;
|
return dbValue.Value;
|
||||||
|
|
||||||
Logger.Debug("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue);
|
Logger.Debug("Unable to find config key '{0}' defaultValue:'{1}'", key, defaultValue);
|
||||||
if (makePermanent)
|
|
||||||
SetValue(key, defaultValue.ToString());
|
|
||||||
value = defaultValue.ToString();
|
value = defaultValue.ToString();
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -310,20 +310,16 @@ namespace NzbDrone.Core.Providers.Core
|
||||||
|
|
||||||
Logger.Debug("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value);
|
Logger.Debug("Writing Setting to file. Key:'{0}' Value:'{1}'", key, value);
|
||||||
|
|
||||||
var dbValue = _repository.Single<Config>(key);
|
var dbValue = _database.SingleOrDefault<Config>("WHERE KEY=@0", key);
|
||||||
|
|
||||||
if (dbValue == null)
|
if (dbValue == null)
|
||||||
{
|
{
|
||||||
_repository.Add(new Config
|
_database.Insert(new Config { Key = key, Value = value });
|
||||||
{
|
|
||||||
Key = key,
|
|
||||||
Value = value
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dbValue.Value = value;
|
dbValue.Value = value;
|
||||||
_repository.Update(dbValue);
|
_database.Update(dbValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ namespace NzbDrone.Core.Providers.ExternalNotification
|
||||||
{
|
{
|
||||||
const string header = "NzbDrone [TV] - Grabbed";
|
const string header = "NzbDrone [TV] - Grabbed";
|
||||||
|
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false)))
|
||||||
{
|
{
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false)))
|
||||||
{
|
{
|
||||||
_logger.Trace("Sending Notification to XBMC");
|
_logger.Trace("Sending Notification to XBMC");
|
||||||
_xbmcProvider.Notify(header, message);
|
_xbmcProvider.Notify(header, message);
|
||||||
|
@ -41,21 +41,21 @@ namespace NzbDrone.Core.Providers.ExternalNotification
|
||||||
{
|
{
|
||||||
const string header = "NzbDrone [TV] - Downloaded";
|
const string header = "NzbDrone [TV] - Downloaded";
|
||||||
|
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false)))
|
||||||
{
|
{
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false)))
|
||||||
{
|
{
|
||||||
_logger.Trace("Sending Notification to XBMC");
|
_logger.Trace("Sending Notification to XBMC");
|
||||||
_xbmcProvider.Notify(header, message);
|
_xbmcProvider.Notify(header, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload", false)))
|
||||||
{
|
{
|
||||||
_logger.Trace("Sending Update Request to XBMC");
|
_logger.Trace("Sending Update Request to XBMC");
|
||||||
_xbmcProvider.Update(seriesId);
|
_xbmcProvider.Update(seriesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false)))
|
||||||
{
|
{
|
||||||
_logger.Trace("Sending Clean DB Request to XBMC");
|
_logger.Trace("Sending Clean DB Request to XBMC");
|
||||||
_xbmcProvider.Clean();
|
_xbmcProvider.Clean();
|
||||||
|
@ -69,19 +69,19 @@ namespace NzbDrone.Core.Providers.ExternalNotification
|
||||||
{
|
{
|
||||||
const string header = "NzbDrone [TV] - Renamed";
|
const string header = "NzbDrone [TV] - Renamed";
|
||||||
|
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false)))
|
||||||
{
|
{
|
||||||
_logger.Trace("Sending Notification to XBMC");
|
_logger.Trace("Sending Notification to XBMC");
|
||||||
_xbmcProvider.Notify(header, message);
|
_xbmcProvider.Notify(header, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false)))
|
||||||
{
|
{
|
||||||
_logger.Trace("Sending Update Request to XBMC");
|
_logger.Trace("Sending Update Request to XBMC");
|
||||||
_xbmcProvider.Update(seriesId);
|
_xbmcProvider.Update(seriesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false)))
|
||||||
{
|
{
|
||||||
_logger.Trace("Sending Clean DB Request to XBMC");
|
_logger.Trace("Sending Clean DB Request to XBMC");
|
||||||
_xbmcProvider.Clean();
|
_xbmcProvider.Clean();
|
||||||
|
|
|
@ -8,9 +8,7 @@ using NLog;
|
||||||
using NzbDrone.Core.Helpers;
|
using NzbDrone.Core.Helpers;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
using NzbDrone.Core.Repository.Quality;
|
|
||||||
using PetaPoco;
|
using PetaPoco;
|
||||||
using SubSonic.Repository;
|
|
||||||
using TvdbLib.Data;
|
using TvdbLib.Data;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Providers
|
namespace NzbDrone.Core.Providers
|
||||||
|
@ -18,17 +16,15 @@ namespace NzbDrone.Core.Providers
|
||||||
public class SeriesProvider
|
public class SeriesProvider
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly IRepository _repository;
|
|
||||||
private readonly ConfigProvider _configProvider;
|
private readonly ConfigProvider _configProvider;
|
||||||
private readonly TvDbProvider _tvDbProvider;
|
private readonly TvDbProvider _tvDbProvider;
|
||||||
private readonly IDatabase _database;
|
private readonly IDatabase _database;
|
||||||
private readonly QualityProvider _qualityProvider;
|
private readonly QualityProvider _qualityProvider;
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public SeriesProvider(ConfigProvider configProviderProvider, IRepository repository, TvDbProvider tvDbProviderProvider, IDatabase database, QualityProvider qualityProvider)
|
public SeriesProvider(ConfigProvider configProviderProvider, TvDbProvider tvDbProviderProvider, IDatabase database, QualityProvider qualityProvider)
|
||||||
{
|
{
|
||||||
_configProvider = configProviderProvider;
|
_configProvider = configProviderProvider;
|
||||||
_repository = repository;
|
|
||||||
_tvDbProvider = tvDbProviderProvider;
|
_tvDbProvider = tvDbProviderProvider;
|
||||||
_database = database;
|
_database = database;
|
||||||
_qualityProvider = qualityProvider;
|
_qualityProvider = qualityProvider;
|
||||||
|
@ -100,7 +96,7 @@ namespace NzbDrone.Core.Providers
|
||||||
repoSeries.Monitored = true; //New shows should be monitored
|
repoSeries.Monitored = true; //New shows should be monitored
|
||||||
repoSeries.QualityProfileId = qualityProfileId;
|
repoSeries.QualityProfileId = qualityProfileId;
|
||||||
if (qualityProfileId == 0)
|
if (qualityProfileId == 0)
|
||||||
repoSeries.QualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", "1", true));
|
repoSeries.QualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", "1"));
|
||||||
|
|
||||||
repoSeries.SeasonFolder = _configProvider.UseSeasonFolder;
|
repoSeries.SeasonFolder = _configProvider.UseSeasonFolder;
|
||||||
|
|
||||||
|
@ -127,30 +123,29 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual void DeleteSeries(int seriesId)
|
public virtual void DeleteSeries(int seriesId)
|
||||||
{
|
{
|
||||||
Logger.Warn("Deleting Series [{0}]", seriesId);
|
var series = GetSeries(seriesId);
|
||||||
var series = _repository.Single<Series>(seriesId);
|
Logger.Warn("Deleting Series [{0}]", series.Title);
|
||||||
|
|
||||||
//Delete Files, Episodes, Seasons then the Series
|
using (var tran = _database.GetTransaction())
|
||||||
//Can't use providers because episode provider needs series provider - Cyclic Dependency Injection, this will work
|
{
|
||||||
|
//Delete History, Files, Episodes, Seasons then the Series
|
||||||
|
|
||||||
//Delete History Items for any episodes that belong to this series
|
Logger.Debug("Deleting History Items from DB for Series: {0}", series.Title);
|
||||||
Logger.Debug("Deleting History Items from DB for Series: {0}", series.SeriesId);
|
_database.Delete<History>("WHERE SeriesId=@0", seriesId);
|
||||||
var episodes = series.Episodes.Select(e => e.EpisodeId).ToList();
|
|
||||||
episodes.ForEach(e => _repository.DeleteMany<History>(h => h.EpisodeId == e));
|
|
||||||
|
|
||||||
//Delete all episode files from the DB for episodes in this series
|
Logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.Title);
|
||||||
Logger.Debug("Deleting EpisodeFiles from DB for Series: {0}", series.SeriesId);
|
_database.Delete<EpisodeFile>("WHERE SeriesId=@0", seriesId);
|
||||||
_repository.DeleteMany(series.EpisodeFiles);
|
|
||||||
|
|
||||||
//Delete all episodes for this series from the DB
|
Logger.Debug("Deleting Episodes from DB for Series: {0}", series.Title);
|
||||||
Logger.Debug("Deleting Episodes from DB for Series: {0}", series.SeriesId);
|
_database.Delete<Episode>("WHERE SeriesId=@0", seriesId);
|
||||||
_repository.DeleteMany(series.Episodes);
|
|
||||||
|
|
||||||
//Delete the Series
|
Logger.Debug("Deleting Series from DB {0}", series.Title);
|
||||||
Logger.Debug("Deleting Series from DB {0}", series.Title);
|
_database.Delete<Series>("WHERE SeriesId=@0", seriesId);
|
||||||
_repository.Delete<Series>(seriesId);
|
|
||||||
|
|
||||||
Logger.Info("Successfully deleted Series [{0}]", seriesId);
|
Logger.Info("Successfully deleted Series [{0}]", series.Title);
|
||||||
|
|
||||||
|
tran.Complete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool SeriesPathExists(string cleanPath)
|
public virtual bool SeriesPathExists(string cleanPath)
|
||||||
|
|
|
@ -25,10 +25,10 @@ namespace NzbDrone.Core.Providers
|
||||||
public virtual void Notify(string header, string message)
|
public virtual void Notify(string header, string message)
|
||||||
{
|
{
|
||||||
//Get time in seconds and convert to ms
|
//Get time in seconds and convert to ms
|
||||||
var time = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", "3", true)) * 1000;
|
var time = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", "3")) * 1000;
|
||||||
var command = String.Format("ExecBuiltIn(Notification({0},{1},{2}))", header, message, time);
|
var command = String.Format("ExecBuiltIn(Notification({0},{1},{2}))", header, message, time);
|
||||||
|
|
||||||
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)))
|
if (Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false)))
|
||||||
{
|
{
|
||||||
//Todo: Get the actual port that NzbDrone is running on...
|
//Todo: Get the actual port that NzbDrone is running on...
|
||||||
var serverInfo = String.Format("http://{0}:{1}", Environment.MachineName, "8989");
|
var serverInfo = String.Format("http://{0}:{1}", Environment.MachineName, "8989");
|
||||||
|
@ -37,7 +37,7 @@ namespace NzbDrone.Core.Providers
|
||||||
command = String.Format("ExecBuiltIn(Notification({0},{1},{2}, {3}))", header, message, time, imageUrl);
|
command = String.Format("ExecBuiltIn(Notification({0},{1},{2}, {3}))", header, message, time, imageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(','))
|
foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80").Split(','))
|
||||||
{
|
{
|
||||||
Logger.Trace("Sending Notifcation to XBMC Host: {0}", host);
|
Logger.Trace("Sending Notifcation to XBMC Host: {0}", host);
|
||||||
SendCommand(host, command);
|
SendCommand(host, command);
|
||||||
|
@ -46,14 +46,14 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual void Update(int seriesId)
|
public virtual void Update(int seriesId)
|
||||||
{
|
{
|
||||||
foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(','))
|
foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80").Split(','))
|
||||||
{
|
{
|
||||||
Logger.Trace("Sending Update DB Request to XBMC Host: {0}", host);
|
Logger.Trace("Sending Update DB Request to XBMC Host: {0}", host);
|
||||||
var xbmcSeriesPath = GetXbmcSeriesPath(host, seriesId);
|
var xbmcSeriesPath = GetXbmcSeriesPath(host, seriesId);
|
||||||
|
|
||||||
//If the path is not found & the user wants to update the entire library, do it now.
|
//If the path is not found & the user wants to update the entire library, do it now.
|
||||||
if (String.IsNullOrEmpty(xbmcSeriesPath) &&
|
if (String.IsNullOrEmpty(xbmcSeriesPath) &&
|
||||||
Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)))
|
Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false)))
|
||||||
{
|
{
|
||||||
//Update the entire library
|
//Update the entire library
|
||||||
Logger.Trace("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", seriesId, host);
|
Logger.Trace("Series [{0}] doesn't exist on XBMC host: {1}, Updating Entire Library", seriesId, host);
|
||||||
|
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual void Clean()
|
public virtual void Clean()
|
||||||
{
|
{
|
||||||
foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80", true).Split(','))
|
foreach (var host in _configProvider.GetValue("XbmcHosts", "localhost:80").Split(','))
|
||||||
{
|
{
|
||||||
Logger.Trace("Sending DB Clean Request to XBMC Host: {0}", host);
|
Logger.Trace("Sending DB Clean Request to XBMC Host: {0}", host);
|
||||||
var command = String.Format("ExecBuiltIn(CleanLibrary(video))");
|
var command = String.Format("ExecBuiltIn(CleanLibrary(video))");
|
||||||
|
@ -78,8 +78,8 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
private string SendCommand(string host, string command)
|
private string SendCommand(string host, string command)
|
||||||
{
|
{
|
||||||
var username = _configProvider.GetValue("XbmcUsername", String.Empty, true);
|
var username = _configProvider.GetValue("XbmcUsername", String.Empty);
|
||||||
var password = _configProvider.GetValue("XbmcPassword", String.Empty, true);
|
var password = _configProvider.GetValue("XbmcPassword", String.Empty);
|
||||||
var url = String.Format("http://{0}/xbmcCmds/xbmcHttp?command={1}", host, command);
|
var url = String.Format("http://{0}/xbmcCmds/xbmcHttp?command={1}", host, command);
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(username))
|
if (!String.IsNullOrEmpty(username))
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using SubSonic.SqlGeneration.Schema;
|
using PetaPoco;
|
||||||
|
using SubSonic.SqlGeneration.Schema;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Repository
|
namespace NzbDrone.Core.Repository
|
||||||
{
|
{
|
||||||
[SubSonicTableNameOverride("Config")]
|
[PrimaryKey("Key", autoIncrement = false)]
|
||||||
public class Config
|
public class Config
|
||||||
{
|
{
|
||||||
[SubSonicPrimaryKey]
|
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
|
|
||||||
public string Value { get; set; }
|
public string Value { get; set; }
|
||||||
|
|
|
@ -7,6 +7,7 @@ using SubSonic.SqlGeneration.Schema;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Repository
|
namespace NzbDrone.Core.Repository
|
||||||
{
|
{
|
||||||
|
[PrimaryKey("SeriesId", autoIncrement = false)]
|
||||||
public class Series
|
public class Series
|
||||||
{
|
{
|
||||||
[SubSonicPrimaryKey(false)]
|
[SubSonicPrimaryKey(false)]
|
||||||
|
|
|
@ -148,20 +148,20 @@ namespace NzbDrone.Web.Controllers
|
||||||
|
|
||||||
var model = new NotificationSettingsModel
|
var model = new NotificationSettingsModel
|
||||||
{
|
{
|
||||||
XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)),
|
XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false)),
|
||||||
XbmcNotifyOnGrab = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)),
|
XbmcNotifyOnGrab = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false)),
|
||||||
XbmcNotifyOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)),
|
XbmcNotifyOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false)),
|
||||||
XbmcNotifyOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)),
|
XbmcNotifyOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false)),
|
||||||
XbmcNotificationImage = Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)),
|
XbmcNotificationImage = Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false)),
|
||||||
XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3, true)),
|
XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3)),
|
||||||
XbmcUpdateOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)),
|
XbmcUpdateOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false)),
|
||||||
XbmcUpdateOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)),
|
XbmcUpdateOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false)),
|
||||||
XbmcFullUpdate = Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)),
|
XbmcFullUpdate = Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false)),
|
||||||
XbmcCleanOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)),
|
XbmcCleanOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false)),
|
||||||
XbmcCleanOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)),
|
XbmcCleanOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false)),
|
||||||
XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80", true),
|
XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80"),
|
||||||
XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty, true),
|
XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty),
|
||||||
XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty, true)
|
XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty)
|
||||||
};
|
};
|
||||||
|
|
||||||
return View("Index", model);
|
return View("Index", model);
|
||||||
|
@ -240,7 +240,7 @@ namespace NzbDrone.Web.Controllers
|
||||||
{
|
{
|
||||||
var profiles = _qualityProvider.GetAllProfiles().ToList();
|
var profiles = _qualityProvider.GetAllProfiles().ToList();
|
||||||
var defaultQualityQualityProfileId =
|
var defaultQualityQualityProfileId =
|
||||||
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId, true));
|
Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].QualityProfileId));
|
||||||
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
|
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
|
||||||
|
|
||||||
return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, QualityProfileSelectList = selectList };
|
return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, QualityProfileSelectList = selectList };
|
||||||
|
|
Loading…
Reference in New Issue