mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 03:52:33 +02:00
removed sqlce
This commit is contained in:
parent
b76c6329fe
commit
beb2f7c7fd
@ -62,17 +62,6 @@ public void Config_path_test()
|
||||
GetEnviromentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISConfig_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetIISConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\AppServer\applicationhost.config");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IISExe_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetIISExe().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\IISExpress.exe");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NlogConfig_path_test()
|
||||
|
@ -8,16 +8,12 @@ public static class PathExtentions
|
||||
private const string WEB_FOLDER = "NzbDrone.Web\\";
|
||||
private const string APP_DATA = "App_Data\\";
|
||||
private const string WEB_BIN = "bin\\";
|
||||
public const string IIS_FOLDER = "IISExpress";
|
||||
public const string IIS_EXE = "iisexpress.exe";
|
||||
|
||||
private const string LOG_CONFIG_FILE = "log.config";
|
||||
private const string APP_CONFIG_FILE = "config.xml";
|
||||
|
||||
public const string NZBDRONE_EXE = "NzbDrone.exe";
|
||||
public const string NZBDRONE_SQLCE_DB_FILE = "nzbdrone.sdf";
|
||||
|
||||
public const string LOG_SQLCE_DB_FILE = "log.sdf";
|
||||
public const string OBJ_DB_FOLDER = "objDb";
|
||||
|
||||
private const string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
|
||||
@ -45,20 +41,8 @@ public static string NormalizePath(this string path)
|
||||
}
|
||||
|
||||
|
||||
public static string GetIISFolder(this EnvironmentProvider environmentProvider)
|
||||
{
|
||||
return Path.Combine(environmentProvider.ApplicationPath, IIS_FOLDER);
|
||||
}
|
||||
|
||||
public static string GetIISExe(this EnvironmentProvider environmentProvider)
|
||||
{
|
||||
return Path.Combine(environmentProvider.GetIISFolder(), IIS_EXE);
|
||||
}
|
||||
|
||||
public static string GetIISConfigPath(this EnvironmentProvider environmentProvider)
|
||||
{
|
||||
return Path.Combine(environmentProvider.GetIISFolder(), "AppServer", "applicationhost.config");
|
||||
}
|
||||
|
||||
public static string GetWebRoot(this EnvironmentProvider environmentProvider)
|
||||
{
|
||||
@ -85,16 +69,6 @@ public static string GetConfigPath(this EnvironmentProvider environmentProvider)
|
||||
return Path.Combine(environmentProvider.ApplicationPath, APP_CONFIG_FILE);
|
||||
}
|
||||
|
||||
public static string GetSqlCeMainDbPath(this EnvironmentProvider environmentProvider)
|
||||
{
|
||||
return Path.Combine(environmentProvider.GetAppDataPath(), NZBDRONE_SQLCE_DB_FILE);
|
||||
}
|
||||
|
||||
public static string GetSqlCeLogDbPath(this EnvironmentProvider environmentProvider)
|
||||
{
|
||||
return Path.Combine(environmentProvider.GetAppDataPath(), LOG_SQLCE_DB_FILE);
|
||||
}
|
||||
|
||||
public static string GetObjectDbFolder(this EnvironmentProvider environmentProvider)
|
||||
{
|
||||
return Path.Combine(environmentProvider.GetAppDataPath(), OBJ_DB_FOLDER);
|
||||
|
@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<!-- Supported values: nunit, xunit and mstest -->
|
||||
<add key="FluentAssertions.TestFramework" value="nunit" />
|
||||
@ -15,11 +12,4 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="System.Data.SqlServerCe.4.0" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
</entityFramework>
|
||||
</configuration>
|
@ -36,11 +36,6 @@ class CentralDispatchFixture : CoreTest
|
||||
|
||||
public CentralDispatchFixture()
|
||||
{
|
||||
if (EnvironmentProvider.IsMono)
|
||||
{
|
||||
throw new IgnoreException("SqlCe is not supported");
|
||||
}
|
||||
|
||||
InitLogging();
|
||||
}
|
||||
|
||||
@ -116,11 +111,6 @@ public void indexers_are_initialized()
|
||||
kernel.Resolve<IIndexerService>().All().Select(c => c.Type).Should().BeEquivalentTo(indexers);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void metadata_clients_are_initialized()
|
||||
{
|
||||
kernel.Resolve<MetadataProvider>().All().Should().HaveSameCount(metadata);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void quality_profile_initialized()
|
||||
|
@ -5,7 +5,7 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Test.Configuration
|
||||
{
|
||||
|
@ -1,146 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Test.Common;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
public abstract class SqlCeTest : CoreTest
|
||||
{
|
||||
private string _dbTemplateName;
|
||||
|
||||
[SetUp]
|
||||
public void CoreTestSetup()
|
||||
{
|
||||
if (EnvironmentProvider.IsMono)
|
||||
{
|
||||
throw new IgnoreException("SqlCe is not supported in mono.");
|
||||
}
|
||||
|
||||
if (NCrunch.Framework.NCrunchEnvironment.NCrunchIsResident())
|
||||
{
|
||||
_dbTemplateName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()) + ".sdf";
|
||||
}
|
||||
else
|
||||
{
|
||||
_dbTemplateName = "db_template.sdf";
|
||||
}
|
||||
|
||||
CreateDataBaseTemplate();
|
||||
}
|
||||
|
||||
private IDatabase GetEmptyDatabase(string fileName = "")
|
||||
{
|
||||
Console.WriteLine("====================DataBase====================");
|
||||
Console.WriteLine("Cloning database from template.");
|
||||
|
||||
if (String.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
fileName = Guid.NewGuid() + ".sdf";
|
||||
}
|
||||
|
||||
File.Copy(_dbTemplateName, fileName);
|
||||
|
||||
var connectionString = ConnectionFactory.GetConnectionString(fileName);
|
||||
var database = ConnectionFactory.GetPetaPocoDb(connectionString);
|
||||
|
||||
Console.WriteLine("====================DataBase====================");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
|
||||
return database;
|
||||
}
|
||||
|
||||
private void CreateDataBaseTemplate()
|
||||
{
|
||||
Console.WriteLine("Creating an empty PetaPoco database");
|
||||
var connectionString = ConnectionFactory.GetConnectionString(_dbTemplateName);
|
||||
var database = ConnectionFactory.GetPetaPocoDb(connectionString);
|
||||
database.Dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private IDatabase _db;
|
||||
protected IDatabase Db
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_db == null)
|
||||
throw new InvalidOperationException("Test db doesn't exists. Make sure you call WithRealDb() if you intend to use an actual database.");
|
||||
|
||||
return _db;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void WithRealDb()
|
||||
{
|
||||
if (EnvironmentProvider.IsMono)
|
||||
{
|
||||
throw new IgnoreException("SqlCe is not supported in mono.");
|
||||
}
|
||||
|
||||
_db = GetEmptyDatabase();
|
||||
Mocker.SetConstant(Db);
|
||||
}
|
||||
|
||||
|
||||
[TearDown]
|
||||
public void CoreTestTearDown()
|
||||
{
|
||||
ConfigService.ClearCache();
|
||||
|
||||
if (EnvironmentProvider.IsMono)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_db != null && _db.Connection != null && File.Exists(_db.Connection.Database))
|
||||
{
|
||||
var file = _db.Connection.Database;
|
||||
_db.Dispose();
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
|
||||
}
|
||||
catch (IOException) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SqlCeTest<TSubject> : SqlCeTest where TSubject : class
|
||||
{
|
||||
|
||||
private TSubject _subject;
|
||||
|
||||
|
||||
protected TSubject Subject
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_subject == null)
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
|
||||
return _subject;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void InitiateSubject()
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
|
@ -1,34 +0,0 @@
|
||||
using System;
|
||||
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Jobs;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.JobTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class EpisodeSearchJobTest:SqlCeTest
|
||||
{
|
||||
[TestCase(0)]
|
||||
[TestCase(-1)]
|
||||
[TestCase(-100)]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void start_target_id_less_than_0_throws_exception(int target)
|
||||
{
|
||||
WithStrictMocker();
|
||||
Mocker.Resolve<EpisodeSearchJob>().Start(new ProgressNotification("Test"), new { EpisodeId = target });
|
||||
}
|
||||
|
||||
[TestCase(-1)]
|
||||
[TestCase(-100)]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void start_secondary_target_id_less_than_0_throws_exception(int target)
|
||||
{
|
||||
WithStrictMocker();
|
||||
Mocker.Resolve<SeasonSearchJob>().Start(new ProgressNotification("Test"), new { SeriesId = 1, SeasonNumber = target });
|
||||
}
|
||||
}
|
||||
}
|
@ -75,21 +75,6 @@ public void should_log_warning_if_no_episode_files_are_found()
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_if_no_episodes_are_moved()
|
||||
{
|
||||
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 5 });
|
||||
|
||||
Mocker.GetMock<MetadataProvider>().Verify(v => v.RemoveForEpisodeFiles(It.IsAny<List<EpisodeFile>>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_process_metadata_if_files_are_moved()
|
||||
{
|
||||
WithMovedFiles();
|
||||
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 5 });
|
||||
|
||||
Mocker.GetMock<MetadataProvider>().Verify(v => v.RemoveForEpisodeFiles(It.IsAny<List<EpisodeFile>>()), Times.Once());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,132 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Test.MediaFileTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class CleanUpDatabaseFixture : SqlCeTest
|
||||
{
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
}
|
||||
|
||||
private void WithAutoIgnore(bool autoIgnore)
|
||||
{
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
.SetupGet(c => c.AutoIgnorePreviouslyDownloadedEpisodes).Returns(autoIgnore);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void CleanUpDatabse_should_detach_none_existing_file_from_episodes_with_auto_ignore()
|
||||
{
|
||||
WithAutoIgnore(true);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(3)
|
||||
.All().With(c => c.GrabDate = DateTime.Now)
|
||||
.And(c => c.Ignored = false)
|
||||
.And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
|
||||
.Build();
|
||||
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<Episode>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveSameCount(episodes);
|
||||
result.Should().OnlyContain(e => e.EpisodeFileId == 0);
|
||||
result.Should().OnlyContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
|
||||
result.Should().OnlyContain(e => e.Ignored);
|
||||
result.Should().OnlyContain(e => e.GrabDate == null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CleanUpDatabse_should_detach_none_existing_file_from_episodes_with_no_auto_ignore()
|
||||
{
|
||||
WithAutoIgnore(false);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(3)
|
||||
.All().With(c => c.GrabDate = DateTime.Now)
|
||||
.And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
|
||||
.TheFirst(2).With(c => c.Ignored = true)
|
||||
.TheLast(1).With(c => c.Ignored = false)
|
||||
.Build();
|
||||
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<Episode>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveSameCount(episodes);
|
||||
result.Should().OnlyContain(e => e.EpisodeFileId == 0);
|
||||
result.Should().OnlyContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
|
||||
result.Should().OnlyContain(e => e.GrabDate == null);
|
||||
result.Should().Contain(c => c.Ignored == true);
|
||||
result.Should().Contain(c => c.Ignored == false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CleanUpDatabse_should_not_change_episodes_with_no_file_id()
|
||||
{
|
||||
//Setup
|
||||
var episodes = Builder<Episode>.CreateListOfSize(3)
|
||||
.All().With(c => c.GrabDate = DateTime.Now)
|
||||
.And(c => c.Ignored = false)
|
||||
.And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<Episode>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveSameCount(episodes);
|
||||
result.Should().OnlyContain(e => e.EpisodeFileId == 0);
|
||||
result.Should().NotContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
|
||||
result.Should().NotContain(e => e.Ignored);
|
||||
result.Should().NotContain(e => e.GrabDate == null);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void DeleteOrphanedEpisodeFiles()
|
||||
{
|
||||
//Setup
|
||||
var episodeFiles = Builder<EpisodeFile>
|
||||
.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.Quality = Quality.DVD)
|
||||
.Build();
|
||||
var episodes = Builder<Episode>.CreateListOfSize(5).Build();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
Db.InsertMany(episodeFiles);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<EpisodeFile>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
result.Should().OnlyContain(e => e.Id > 0);
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class MediaFileServiceTest : SqlCeTest
|
||||
public class MediaFileServiceTest : ObjectDbTest
|
||||
{
|
||||
[Test]
|
||||
public void get_series_files()
|
||||
@ -36,8 +36,6 @@ public void get_series_files()
|
||||
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.InsertMany(firstSeriesFiles);
|
||||
Db.InsertMany(secondSeriesFiles);
|
||||
@ -66,7 +64,6 @@ public void get_season_files()
|
||||
.Build();
|
||||
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.InsertMany(firstSeriesFiles);
|
||||
Db.InsertMany(secondSeriesFiles);
|
||||
@ -148,23 +145,18 @@ public void DeleteEpisodeFile()
|
||||
.Build();
|
||||
|
||||
|
||||
WithRealDb();
|
||||
Db.InsertMany(episodeFiles);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<IMediaFileService>().Delete(1);
|
||||
var result = Db.Fetch<EpisodeFile>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(9);
|
||||
result.Should().NotContain(e => e.Id == 1);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetFileByPath_should_return_null_if_file_does_not_exist_in_database()
|
||||
{
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<IMediaFileService>().GetFileByPath(@"C:\Test\EpisodeFile.avi");
|
||||
@ -179,7 +171,6 @@ public void GetFileByPath_should_return_EpisodeFile_if_file_exists_in_database()
|
||||
var path = @"C:\Test\EpisodeFile.avi";
|
||||
|
||||
//Setup
|
||||
WithRealDb();
|
||||
var episodeFile = Builder<EpisodeFile>.CreateNew()
|
||||
.With(c => c.Quality = Quality.SDTV)
|
||||
.With(f => f.Path = path.NormalizePath())
|
||||
|
@ -199,8 +199,6 @@
|
||||
<Compile Include="DecisionEngineTests\QualityUpgradeSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\UpgradePossibleSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\BlackholeProviderFixture.cs" />
|
||||
<Compile Include="MediaFileTests\CleanUpDatabaseFixture.cs" />
|
||||
<Compile Include="ProviderTests\ReferenceDataProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\NotificationProviderTests\NotificationProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\QueueFixture.cs" />
|
||||
<Compile Include="Indexers\NewznabServiceTest.cs" />
|
||||
@ -209,7 +207,6 @@
|
||||
<Compile Include="ProviderTests\GrowlProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\ExtractArchiveFixture.cs" />
|
||||
<Compile Include="ProviderTests\PostDownloadProviderTests\GetFolderNameWithStatusFixture.cs" />
|
||||
<Compile Include="JobTests\EpisodeSearchJobTest.cs" />
|
||||
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDownloadFixture.cs" />
|
||||
<Compile Include="JobTests\TestJobs.cs" />
|
||||
<Compile Include="JobTests\AppUpdateJobFixture.cs" />
|
||||
@ -233,7 +230,6 @@
|
||||
<Compile Include="FluentTest.cs" />
|
||||
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
||||
<Compile Include="MediaFileTests\GetNewFilenameFixture.cs" />
|
||||
<Compile Include="Framework\SqlCeTest.cs" />
|
||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTests\DownloadProviderFixture.cs" />
|
||||
<Compile Include="EpisodeStatusTest.cs" />
|
||||
|
@ -303,7 +303,6 @@ public void when_files_are_imported_and_folder_is_small_enough_dir_should_be_del
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.DeleteFolder(droppedFolder.FullName, true));
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.FolderExists(fakeSeries.Path)).Returns(true);
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.IsFolderLocked(droppedFolder.FullName)).Returns(false);
|
||||
Mocker.GetMock<MetadataProvider>().Setup(s => s.CreateForEpisodeFiles(It.IsAny<List<EpisodeFile>>()));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
@ -17,7 +17,7 @@
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||
|
@ -17,7 +17,7 @@
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||
|
@ -17,7 +17,7 @@
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||
|
@ -17,7 +17,7 @@
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
using PetaPoco;
|
||||
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
|
||||
|
@ -1,212 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class ReferenceDataProviderTest : SqlCeTest
|
||||
{
|
||||
private const string validSeriesIds = "[1,2,3,4,5]";
|
||||
private const string invalidSeriesIds = "[1,2,NaN,4,5]";
|
||||
|
||||
private const string url = "http://services.nzbdrone.com/DailySeries/AllIds";
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<IConfigService>().SetupGet(s => s.ServiceRootUrl)
|
||||
.Returns("http://services.nzbdrone.com");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetDailySeriesIds_should_return_list_of_int_when_all_are_valid()
|
||||
{
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().GetDailySeriesIds();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDailySeriesIds_should_return_empty_list_when_unable_to_parse()
|
||||
{
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(invalidSeriesIds);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().GetDailySeriesIds();
|
||||
|
||||
//Assert
|
||||
result.Should().BeEmpty();
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDailySeriesIds_should_return_empty_list_of_int_when_server_is_unavailable()
|
||||
{
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Throws(new Exception());
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().GetDailySeriesIds();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(0);
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsDailySeries_should_return_true()
|
||||
{
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().IsSeriesDaily(1);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsDailySeries_should_return_false()
|
||||
{
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().IsSeriesDaily(10);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateDailySeries_should_update_series_that_match_daily_series_list()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.SeriesType = SeriesType.Standard)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateDailySeries_should_update_series_should_skip_series_that_dont_match()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.SeriesType = SeriesType.Standard)
|
||||
.TheFirst(1)
|
||||
.With(s => s.Id = 10)
|
||||
.TheNext(1)
|
||||
.With(s => s.Id = 11)
|
||||
.TheNext(1)
|
||||
.With(s => s.Id = 12)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
result.Where(s => s.SeriesType == SeriesType.Standard).Should().HaveCount(3);
|
||||
result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateDailySeries_should_update_series_should_not_overwrite_existing_isDaily()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.SeriesType = SeriesType.Standard)
|
||||
.TheFirst(1)
|
||||
.With(s => s.Id = 10)
|
||||
.With(s => s.SeriesType = SeriesType.Daily)
|
||||
.TheNext(1)
|
||||
.With(s => s.Id = 11)
|
||||
.TheNext(1)
|
||||
.With(s => s.Id = 12)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(3);
|
||||
result.Where(s => s.SeriesType == SeriesType.Standard).Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void broken_service_should_not_cause_this_call_to_fail()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<string>()))
|
||||
.Throws(new WebException())
|
||||
.Verifiable();
|
||||
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,17 +7,14 @@
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SceneMappingProviderTest : SqlCeTest
|
||||
public class SceneMappingProviderTest : ObjectDbTest
|
||||
{
|
||||
private const string SceneMappingUrl = "http://services.nzbdrone.com/SceneMapping/Active";
|
||||
|
||||
@ -27,7 +24,6 @@ public void Setup()
|
||||
Mocker.GetMock<IConfigService>().SetupGet(s => s.ServiceRootUrl)
|
||||
.Returns("http://services.nzbdrone.com");
|
||||
|
||||
WithRealDb();
|
||||
}
|
||||
|
||||
private void WithValidJson()
|
||||
@ -47,12 +43,11 @@ private void WithErrorDownloadingJson()
|
||||
[Test]
|
||||
public void GetSceneName_exists()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.CleanTitle = "laworder")
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.SeasonNumber = -1)
|
||||
.Build();
|
||||
@ -60,7 +55,7 @@ public void GetSceneName_exists()
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
//Act
|
||||
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
||||
var sceneName = Mocker.Resolve<SceneMappingService>().GetSceneName(fakeMap.TvdbId);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
||||
@ -69,11 +64,10 @@ public void GetSceneName_exists()
|
||||
[Test]
|
||||
public void GetSeriesId_exists()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.SceneName = "laworder")
|
||||
.Build();
|
||||
@ -82,20 +76,19 @@ public void GetSeriesId_exists()
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
//Act
|
||||
var seriesId = Mocker.Resolve<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle);
|
||||
var seriesId = Mocker.Resolve<SceneMappingService>().GetTvDbId(fakeMap.CleanTitle);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(fakeMap.SeriesId, seriesId);
|
||||
Assert.AreEqual(fakeMap.TvdbId, seriesId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSceneName_null()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.SceneName = "laworder")
|
||||
.Build();
|
||||
@ -104,7 +97,7 @@ public void GetSceneName_null()
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
//Act
|
||||
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(54321);
|
||||
var sceneName = Mocker.Resolve<SceneMappingService>().GetSceneName(54321);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(null, sceneName);
|
||||
@ -113,11 +106,10 @@ public void GetSceneName_null()
|
||||
[Test]
|
||||
public void GetSeriesId_null()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.CleanTitle = "laworder")
|
||||
.Build();
|
||||
@ -125,7 +117,7 @@ public void GetSeriesId_null()
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
//Act
|
||||
var seriesId = Mocker.Resolve<SceneMappingProvider>().GetSeriesId("notlaworder");
|
||||
var seriesId = Mocker.Resolve<SceneMappingService>().GetTvDbId("notlaworder");
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(null, seriesId);
|
||||
@ -134,20 +126,19 @@ public void GetSeriesId_null()
|
||||
[Test]
|
||||
public void GetSceneName_multiple_clean_names()
|
||||
{
|
||||
WithRealDb();
|
||||
//Test that ensures a series with clean names (office, officeus) can be looked up by seriesId
|
||||
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.CleanTitle = "office")
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "The Office")
|
||||
.With(f => f.SeasonNumber = -1)
|
||||
.Build();
|
||||
|
||||
var fakeMap2 = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.CleanTitle = "officeus")
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "The Office")
|
||||
.With(f => f.SeasonNumber = -1)
|
||||
.Build();
|
||||
@ -158,7 +149,7 @@ public void GetSceneName_multiple_clean_names()
|
||||
Db.Insert(fakeMap2);
|
||||
|
||||
//Act
|
||||
var sceneName = Mocker.Resolve<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
||||
var sceneName = Mocker.Resolve<SceneMappingService>().GetSceneName(fakeMap.TvdbId);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(fakeMap.SceneName, sceneName);
|
||||
@ -167,10 +158,10 @@ public void GetSceneName_multiple_clean_names()
|
||||
[Test]
|
||||
public void GetSceneName_should_be_null_when_seasonNumber_does_not_match()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.SceneName = "laworder")
|
||||
.With(f => f.SeasonNumber = 10)
|
||||
@ -178,7 +169,7 @@ public void GetSceneName_should_be_null_when_seasonNumber_does_not_match()
|
||||
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
Mocker.Resolve<SceneMappingProvider>().GetSceneName(54321, 5).Should().BeNull();
|
||||
Mocker.Resolve<SceneMappingService>().GetSceneName(54321, 5).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -187,12 +178,10 @@ public void UpdateMappings_should_add_all_mappings_to_database()
|
||||
WithValidJson();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SceneMappingProvider>().UpdateMappings();
|
||||
Mocker.Resolve<SceneMappingService>().UpdateMappings();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
var result = Db.Fetch<SceneMapping>();
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -200,7 +189,7 @@ public void UpdateMappings_should_overwrite_existing_mappings()
|
||||
{
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.SceneName = "laworder")
|
||||
.Build();
|
||||
@ -209,12 +198,10 @@ public void UpdateMappings_should_overwrite_existing_mappings()
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SceneMappingProvider>().UpdateMappings();
|
||||
Mocker.Resolve<SceneMappingService>().UpdateMappings();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
var result = Db.Fetch<SceneMapping>();
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -222,7 +209,7 @@ public void UpdateMappings_should_not_delete_if_csv_download_fails()
|
||||
{
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.TvdbId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.SceneName = "laworder")
|
||||
.Build();
|
||||
@ -231,46 +218,11 @@ public void UpdateMappings_should_not_delete_if_csv_download_fails()
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SceneMappingProvider>().UpdateMappings();
|
||||
Mocker.Resolve<SceneMappingService>().UpdateMappings();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
var result = Db.Fetch<SceneMapping>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateIfEmpty_should_not_update_if_count_is_not_zero()
|
||||
{
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.CreateNew()
|
||||
.With(f => f.SeriesId = 12345)
|
||||
.With(f => f.SceneName = "Law and Order")
|
||||
.With(f => f.SceneName = "laworder")
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeMap);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SceneMappingProvider>().UpdateIfEmpty();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateIfEmpty_should_update_if_count_is_zero()
|
||||
{
|
||||
//Setup
|
||||
WithValidJson();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SceneMappingProvider>().UpdateIfEmpty();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
var result = Db.Fetch<SceneMapping>();
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Search;
|
||||
@ -28,7 +29,7 @@ public void Setup()
|
||||
|
||||
private void WithSceneMapping()
|
||||
{
|
||||
Mocker.GetMock<SceneMappingProvider>()
|
||||
Mocker.GetMock<SceneMappingService>()
|
||||
.Setup(s => s.GetSceneName(_series.Id, -1))
|
||||
.Returns("Hawaii Five 0 2010");
|
||||
}
|
||||
@ -52,7 +53,7 @@ public void should_return_scene_mapping_when_one_exists()
|
||||
[Test]
|
||||
public void should_return_season_scene_name_when_one_exists()
|
||||
{
|
||||
Mocker.GetMock<SceneMappingProvider>()
|
||||
Mocker.GetMock<SceneMappingService>()
|
||||
.Setup(s => s.GetSceneName(_series.Id, 5))
|
||||
.Returns("Hawaii Five 0 2010 - Season 5");
|
||||
|
||||
@ -85,7 +86,7 @@ public void should_replace_some_special_characters(string input, string expected
|
||||
{
|
||||
_series.Title = input;
|
||||
|
||||
Mocker.GetMock<SceneMappingProvider>()
|
||||
Mocker.GetMock<SceneMappingService>()
|
||||
.Setup(s => s.GetSceneName(_series.Id, -1))
|
||||
.Returns("");
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
@ -20,9 +21,9 @@ public class TestSearch : SearchBase
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider,
|
||||
IIndexerService indexerService, SceneMappingProvider sceneMappingProvider,
|
||||
IIndexerService indexerService, SceneMappingService sceneMappingService,
|
||||
AllowedDownloadSpecification allowedDownloadSpecification, ISeriesRepository seriesRepository)
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||
allowedDownloadSpecification)
|
||||
{
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model.TvRage;
|
||||
using NzbDrone.Core.Providers;
|
||||
@ -49,7 +50,7 @@ public void Setup()
|
||||
.Setup(s => s.GetEpisode(_series.Id, 1, 1))
|
||||
.Returns(_episode);
|
||||
|
||||
Mocker.GetMock<SceneMappingProvider>()
|
||||
Mocker.GetMock<SceneMappingService>()
|
||||
.Setup(s => s.GetCleanName(_series.Id))
|
||||
.Returns("");
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
/*
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -16,19 +17,19 @@
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using PetaPoco;
|
||||
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest : SqlCeTest
|
||||
public class EpisodeProviderTest : ObjectDbTest
|
||||
{
|
||||
[Test]
|
||||
public void GetEpisodes_exists()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
@ -48,7 +49,7 @@ public void GetEpisodes_exists()
|
||||
[Test]
|
||||
public void GetEpisodes_by_season_episode_exists()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 1)
|
||||
@ -72,7 +73,7 @@ public void GetEpisodes_by_season_episode_exists()
|
||||
[Test]
|
||||
public void GetEpisodes_by_season_episode_doesnt_exists()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
|
||||
@ -84,7 +85,7 @@ public void GetEpisodes_by_season_episode_doesnt_exists()
|
||||
[Test]
|
||||
public void GetEpisode_with_EpisodeFile()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.Id).With(c => c.Quality = Quality.SDTV).Build();
|
||||
@ -108,7 +109,7 @@ public void GetEpisode_with_EpisodeFile()
|
||||
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
|
||||
public void GetEpisodes_invalid_series()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Mocker.Resolve<SeriesService>();
|
||||
|
||||
@ -126,7 +127,7 @@ public void GetEpisodes_invalid_series()
|
||||
[Test]
|
||||
public void GetEpisodesBySeason_success()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 12)
|
||||
@ -165,7 +166,7 @@ public void RefreshEpisodeInfo_emptyRepo()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -199,7 +200,7 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -240,7 +241,7 @@ public void RefreshEpisodeInfo_should_set_older_than_1900_to_null_for_existing_e
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
|
||||
@ -277,7 +278,7 @@ public void RefreshEpisodeInfo_ignore_episode_zero()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -316,7 +317,7 @@ public void RefreshEpisodeInfo_should_skip_future_episodes_with_no_title()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -354,7 +355,7 @@ public void RefreshEpisodeInfo_should_skip_older_than_1900_year_episodes_with_no
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -387,7 +388,7 @@ public void RefreshEpisodeInfo_should_add_future_episodes_with_title()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -420,7 +421,7 @@ public void RefreshEpisodeInfo_should_add_old_episodes_with_no_title()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -455,7 +456,7 @@ public void RefreshEpisodeInfo_ignore_season_zero()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -787,7 +788,7 @@ public void RefreshEpisodeInfo_should_ignore_new_episode_for_ignored_season()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeEpisode);
|
||||
@ -814,7 +815,7 @@ public void RefreshEpisodeInfo_should_ignore_new_episode_for_ignored_season()
|
||||
[Explicit]
|
||||
public void Add_daily_show_episodes()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
Mocker.Resolve<TvDbProvider>();
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
@ -843,7 +844,7 @@ public void Add_daily_show_episodes()
|
||||
[Test]
|
||||
public void GetEpisode_by_Season_Episode_none_existing()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
//Act
|
||||
var episode = Mocker.Resolve<EpisodeService>().GetEpisode(1, 1, 1);
|
||||
@ -855,7 +856,7 @@ public void GetEpisode_by_Season_Episode_none_existing()
|
||||
[Test]
|
||||
public void GetEpisode_by_Season_Episode_with_EpisodeFile()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.Id).With(c => c.Quality = Quality.SDTV).Build();
|
||||
@ -878,7 +879,7 @@ public void GetEpisode_by_Season_Episode_with_EpisodeFile()
|
||||
[Test]
|
||||
public void GetEpisode_by_Season_Episode_without_EpisodeFile()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
@ -899,7 +900,7 @@ public void GetEpisode_by_Season_Episode_without_EpisodeFile()
|
||||
[Test]
|
||||
public void GetEpisode_by_AirDate_with_EpisodeFile()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.CreateNew().With(f => f.Id).With(c => c.Quality = Quality.SDTV).Build();
|
||||
@ -922,7 +923,7 @@ public void GetEpisode_by_AirDate_with_EpisodeFile()
|
||||
[Test]
|
||||
public void GetEpisode_by_AirDate_without_EpisodeFile()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
@ -959,7 +960,7 @@ public void MarkEpisodeAsFetched()
|
||||
[Test]
|
||||
public void AddEpisode_episode_is_ignored_when_full_season_is_ignored()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
@ -997,7 +998,7 @@ public void AddEpisode_episode_is_ignored_when_full_season_is_ignored()
|
||||
[Test]
|
||||
public void AddEpisode_episode_is_not_ignored_when_full_season_is_not_ignored()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
@ -1031,7 +1032,7 @@ public void AddEpisode_episode_is_not_ignored_when_full_season_is_not_ignored()
|
||||
[Test]
|
||||
public void AddEpisode_episode_is_not_ignored_when_not_full_season_is_not_ignored()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
@ -1067,7 +1068,7 @@ public void AddEpisode_episode_is_not_ignored_when_not_full_season_is_not_ignore
|
||||
[Test]
|
||||
public void IgnoreEpisode_Ignore()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
@ -1093,7 +1094,7 @@ public void IgnoreEpisode_Ignore()
|
||||
[Test]
|
||||
public void IgnoreEpisode_RemoveIgnore()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
@ -1119,7 +1120,7 @@ public void IgnoreEpisode_RemoveIgnore()
|
||||
[Test]
|
||||
public void EpisodesWithoutFiles_no_specials()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 10)
|
||||
@ -1162,7 +1163,7 @@ public void EpisodesWithoutFiles_no_specials()
|
||||
[Test]
|
||||
public void EpisodesWithoutFiles_with_specials()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 10)
|
||||
@ -1206,7 +1207,7 @@ public void EpisodesWithoutFiles_with_specials()
|
||||
[Test]
|
||||
public void EpisodesWithFiles_success()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 10)
|
||||
@ -1250,7 +1251,7 @@ public void EpisodesWithFiles_success()
|
||||
[Test]
|
||||
public void EpisodesWithFiles_no_files()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 10)
|
||||
@ -1279,7 +1280,7 @@ public void EpisodesWithFiles_no_files()
|
||||
[Test]
|
||||
public void GetEpisodesByFileId_multi_episodes()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 10)
|
||||
@ -1306,7 +1307,7 @@ public void GetEpisodesByFileId_multi_episodes()
|
||||
[Test]
|
||||
public void GetEpisodesByFileId_single_episode()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 10)
|
||||
@ -1333,7 +1334,7 @@ public void GetEpisodesByFileId_single_episode()
|
||||
[Test]
|
||||
public void IsFirstOrLastEpisodeInSeason_false()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
@ -1353,7 +1354,7 @@ public void IsFirstOrLastEpisodeInSeason_false()
|
||||
[Test]
|
||||
public void IsFirstOrLastEpisodeInSeason_true_first()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
@ -1373,7 +1374,7 @@ public void IsFirstOrLastEpisodeInSeason_true_first()
|
||||
[Test]
|
||||
public void IsFirstOrLastEpisodeInSeason_true_last()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
@ -1398,7 +1399,7 @@ public void IsFirstOrLastEpisodeInSeason_true_last()
|
||||
[TestCase("The Office (US) - Season 01 - Episode Title", PostDownloadStatusType.Failed, 10)]
|
||||
public void SetPostDownloadStatus(string folderName, PostDownloadStatusType postDownloadStatus, int episodeCount)
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 12345)
|
||||
@ -1428,7 +1429,7 @@ public void SetPostDownloadStatus(string folderName, PostDownloadStatusType post
|
||||
[Test]
|
||||
public void SetPostDownloadStatus_Invalid_EpisodeId()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var postDownloadStatus = PostDownloadStatusType.Failed;
|
||||
|
||||
@ -1492,7 +1493,7 @@ public void RefreshEpisodeInfo_should_ignore_episode_zero_except_if_season_one()
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@ -1513,3 +1514,4 @@ public void RefreshEpisodeInfo_should_ignore_episode_zero_except_if_season_one()
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -1,4 +1,5 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
/*
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -15,7 +16,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class EpisodeProviderTest_GetEpisodesByParseResult : SqlCeTest
|
||||
public class EpisodeProviderTest_GetEpisodesByParseResult : ObjectDbTest
|
||||
{
|
||||
private IEpisodeService episodeService;
|
||||
|
||||
@ -53,7 +54,7 @@ public void Setup()
|
||||
.With(e => e.Title = "Daily Episode 1")
|
||||
.Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
episodeService = Mocker.Resolve<EpisodeService>();
|
||||
}
|
||||
@ -76,7 +77,7 @@ public void existing_single_episode_should_return_single_existing_episode()
|
||||
ep.Should().HaveCount(1);
|
||||
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title);
|
||||
VerifyEpisode(ep[0], fakeEpisode);
|
||||
Db.Fetch<Episode>().Should().HaveCount(1);
|
||||
Db<Episode>().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -273,3 +274,4 @@ private void VerifyEpisode(Episode actual, Episode excpected)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class GetEpisodeBySceneNumberFixture : SqlCeTest
|
||||
public class GetEpisodeBySceneNumberFixture : ObjectDbTest
|
||||
{
|
||||
private Series _series;
|
||||
private Episode _episode;
|
||||
@ -19,7 +19,7 @@ public class GetEpisodeBySceneNumberFixture : SqlCeTest
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
_series = Builder<Series>
|
||||
.CreateNew()
|
||||
@ -36,7 +36,6 @@ public void WithNullSceneNumbering()
|
||||
.Build();
|
||||
|
||||
Db.Insert(_episode);
|
||||
Db.Execute("UPDATE Episodes SET SceneSeasonNumber = NULL, SceneEpisodeNumber = NULL");
|
||||
}
|
||||
|
||||
public void WithSceneNumbering()
|
||||
|
@ -13,46 +13,15 @@ namespace NzbDrone.Core.Test.TvTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class SeasonProviderTest : SqlCeTest
|
||||
public class SeasonProviderTest : ObjectDbTest
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
}
|
||||
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void SetIgnore_should_update_ignored_status(bool ignoreFlag)
|
||||
{
|
||||
var fakeSeason = Builder<Season>.CreateNew()
|
||||
.With(s => s.Ignored = !ignoreFlag)
|
||||
.Build();
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
.With(c => c.SeriesId = fakeSeason.SeriesId)
|
||||
.With(c => c.SeasonNumber = fakeSeason.Id)
|
||||
.With(c => c.Ignored = !ignoreFlag)
|
||||
.Build().ToList();
|
||||
|
||||
fakeEpisodes.ForEach(c => Db.Insert(c));
|
||||
|
||||
var id = Db.Insert(fakeSeason);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ISeasonService>().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, ignoreFlag);
|
||||
|
||||
//Assert
|
||||
var season = Db.SingleOrDefault<Season>(id);
|
||||
season.Ignored.Should().Be(ignoreFlag);
|
||||
|
||||
var episodes = Db.Fetch<Episode>();
|
||||
episodes.Should().HaveSameCount(fakeEpisodes);
|
||||
episodes.Should().OnlyContain(c => c.Ignored == ignoreFlag);
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void IsIgnored_should_return_ignored_status_of_season(bool ignoreFlag)
|
||||
@ -111,7 +80,7 @@ public void All_should_return_all_seasons_with_episodes()
|
||||
const int seriesId = 10;
|
||||
|
||||
//Setup
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var seasons = Builder<Season>.CreateListOfSize(5)
|
||||
.All()
|
||||
|
@ -1,13 +1,3 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
</configSections>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="System.Data.SqlServerCe.4.0" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
</entityFramework>
|
||||
</configuration>
|
@ -11,7 +11,6 @@
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Providers.Metadata;
|
||||
using NzbDrone.Core.Providers.Search;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core
|
||||
{
|
||||
@ -62,15 +61,7 @@ private static void InitDatabase(this ContainerBuilder container)
|
||||
var appDataPath = new EnvironmentProvider().GetAppDataPath();
|
||||
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
||||
|
||||
container.Register(c => c.Resolve<ConnectionFactory>().GetMainPetaPocoDb())
|
||||
.As<IDatabase>();
|
||||
|
||||
container.Register(c => c.Resolve<ConnectionFactory>().GetLogPetaPocoDb(false))
|
||||
.SingleInstance()
|
||||
.Named<IDatabase>("DatabaseTarget");
|
||||
|
||||
container.Register(c => c.Resolve<ConnectionFactory>().GetLogPetaPocoDb())
|
||||
.Named<IDatabase>("LogProvider");
|
||||
|
||||
container.Register(c =>
|
||||
{
|
||||
@ -78,9 +69,6 @@ private static void InitDatabase(this ContainerBuilder container)
|
||||
}).As<IObjectDatabase>().SingleInstance();
|
||||
|
||||
container.RegisterGeneric(typeof(BasicRepository<>)).As(typeof(IBasicRepository<>));
|
||||
|
||||
container.RegisterType<DatabaseTarget>().WithParameter(ResolvedParameter.ForNamed<IDatabase>("DatabaseTarget"));
|
||||
container.RegisterType<LogService>().WithParameter(ResolvedParameter.ForNamed<IDatabase>("LogProvider"));
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public interface IBasicRepository<TModel>
|
||||
public interface IBasicRepository<TModel> where TModel : ModelBase, new()
|
||||
{
|
||||
IEnumerable<TModel> All();
|
||||
int Count();
|
||||
@ -15,6 +15,7 @@ public interface IBasicRepository<TModel>
|
||||
IList<TModel> InsertMany(IList<TModel> model);
|
||||
IList<TModel> UpdateMany(IList<TModel> model);
|
||||
void Purge();
|
||||
bool HasItems();
|
||||
}
|
||||
|
||||
public class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : ModelBase, new()
|
||||
@ -90,5 +91,10 @@ public void Purge()
|
||||
{
|
||||
DeleteMany(Queryable.Select(c => c.Id));
|
||||
}
|
||||
|
||||
public bool HasItems()
|
||||
{
|
||||
return Queryable.Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,160 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class ConnectionFactory
|
||||
{
|
||||
private readonly EnvironmentProvider _environmentProvider;
|
||||
private static readonly Logger logger = LogManager.GetLogger("ConnectionFactory");
|
||||
private static readonly DbProviderFactory _factory;
|
||||
|
||||
static ConnectionFactory()
|
||||
{
|
||||
Database.Mapper = new CustomeMapper();
|
||||
|
||||
if (EnvironmentProvider.IsMono) return;
|
||||
|
||||
var dataSet = (DataSet)ConfigurationManager.GetSection("system.data");
|
||||
dataSet.Tables[0].Rows.Add("Microsoft SQL Server Compact Data Provider 4.0"
|
||||
, "System.Data.SqlServerCe.4.0"
|
||||
, ".NET Framework Data Provider for Microsoft SQL Server Compact"
|
||||
,
|
||||
"System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
|
||||
|
||||
_factory = SqlCeProxy.GetSqlCeProviderFactory();
|
||||
}
|
||||
|
||||
|
||||
public ConnectionFactory(EnvironmentProvider environmentProvider)
|
||||
{
|
||||
_environmentProvider = environmentProvider;
|
||||
}
|
||||
|
||||
public String MainConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetConnectionString(_environmentProvider.GetSqlCeMainDbPath());
|
||||
}
|
||||
}
|
||||
|
||||
public String LogConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetConnectionString(_environmentProvider.GetSqlCeLogDbPath());
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetConnectionString(string path)
|
||||
{
|
||||
return String.Format("Data Source=\"{0}\"; Max Database Size = 512;", path);
|
||||
}
|
||||
|
||||
public IDatabase GetMainPetaPocoDb(Boolean profiled = true)
|
||||
{
|
||||
return GetPetaPocoDb(MainConnectionString, profiled);
|
||||
}
|
||||
|
||||
public IDatabase GetLogPetaPocoDb(Boolean profiled = true)
|
||||
{
|
||||
return GetPetaPocoDb(LogConnectionString, profiled);
|
||||
}
|
||||
|
||||
|
||||
static readonly HashSet<String> initilized = new HashSet<string>();
|
||||
|
||||
|
||||
|
||||
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
|
||||
{
|
||||
if (EnvironmentProvider.IsMono)
|
||||
{
|
||||
throw new NotSupportedException("SqlCe is not supported in mono");
|
||||
}
|
||||
|
||||
lock (initilized)
|
||||
{
|
||||
if (!initilized.Contains(connectionString))
|
||||
{
|
||||
//VerifyDatabase(connectionString);
|
||||
MigrationsHelper.Run(connectionString, true);
|
||||
initilized.Add(connectionString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var db = new Database(connectionString, _factory, Database.DBType.SqlServerCE)
|
||||
{
|
||||
KeepConnectionAlive = true,
|
||||
ForceDateTimesToUtc = false,
|
||||
};
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
/*private static void VerifyDatabase(string connectionString)
|
||||
{
|
||||
logger.Debug("Verifying database {0}", connectionString);
|
||||
|
||||
var sqlConnection = new SqlCeConnection(connectionString);
|
||||
|
||||
if (!File.Exists(sqlConnection.Database))
|
||||
{
|
||||
logger.Debug("database file doesn't exist. {0}", sqlConnection.Database);
|
||||
return;
|
||||
}
|
||||
|
||||
using (var sqlEngine = new SqlCeEngine(connectionString))
|
||||
{
|
||||
|
||||
if (sqlEngine.Verify(VerifyOption.Default))
|
||||
{
|
||||
logger.Debug("Database integrity verified.");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error("Database verification failed.");
|
||||
RepairDatabase(connectionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void RepairDatabase(string connectionString)
|
||||
{
|
||||
logger.Info("Attempting to repair database: {0}", connectionString);
|
||||
using (var sqlEngine = new SqlCeEngine(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
sqlEngine.Repair(connectionString, RepairOption.RecoverAllOrFail);
|
||||
logger.Info("Recovery was successful without any data loss {0}", connectionString);
|
||||
}
|
||||
catch (SqlCeException e)
|
||||
{
|
||||
if (e.Message.Contains("file sharing violation"))
|
||||
{
|
||||
logger.WarnException("file is in use. skipping.", e);
|
||||
return;
|
||||
}
|
||||
logger.WarnException(
|
||||
"Safe recovery failed. will attempts a more aggressive strategy. might cause loss of data.",
|
||||
e);
|
||||
sqlEngine.Repair(connectionString, RepairOption.DeleteCorruptedRows);
|
||||
logger.Warn("Database was recovered. some data might have been lost");
|
||||
|
||||
//TODO: do db cleanup to avoid broken relationships.
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class CustomeMapper : DefaultMapper
|
||||
{
|
||||
public override Func<object, object> GetToDbConverter(Type sourceType)
|
||||
{
|
||||
if (sourceType == typeof(Quality))
|
||||
{
|
||||
return delegate(object s)
|
||||
{
|
||||
var source = (Quality)s;
|
||||
return source.Id;
|
||||
};
|
||||
}
|
||||
|
||||
return base.GetToDbConverter(sourceType);
|
||||
}
|
||||
|
||||
public override Func<object, object> GetFromDbConverter(Type destinationType, Type sourceType)
|
||||
{
|
||||
if ((sourceType == typeof(Int32) || sourceType == typeof(Int64)) && destinationType.IsGenericType && destinationType.GetGenericTypeDefinition() == typeof(Nullable<>))
|
||||
{
|
||||
// If it is NULLABLE, then get the underlying type. eg if "Nullable<int>" then this will return just "int"
|
||||
Type genericArgument = destinationType.GetGenericArguments()[0];
|
||||
if (genericArgument == typeof(DayOfWeek))
|
||||
{
|
||||
return delegate(object s)
|
||||
{
|
||||
int value;
|
||||
Int32.TryParse(s.ToString(), out value);
|
||||
return (DayOfWeek?)value;
|
||||
};
|
||||
}
|
||||
|
||||
return delegate(object s)
|
||||
{
|
||||
int value;
|
||||
Int32.TryParse(s.ToString(), out value);
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
if ((sourceType == typeof(Int32) || sourceType == typeof(Int64)) && destinationType == typeof(Quality))
|
||||
{
|
||||
return delegate(object s)
|
||||
{
|
||||
int value;
|
||||
Int32.TryParse(s.ToString(), out value);
|
||||
var quality = (Quality)value;
|
||||
return quality;
|
||||
};
|
||||
}
|
||||
|
||||
return base.GetFromDbConverter(destinationType, sourceType);
|
||||
}
|
||||
|
||||
public override Func<object, object> GetFromDbConverter(PropertyInfo propertyInfo, Type sourceType)
|
||||
{
|
||||
//Only needed if using dynamic as the return type from DB, not implemented currently as it has no use right now
|
||||
//if (propertyInfo == null)
|
||||
// return null;
|
||||
|
||||
if (propertyInfo == null) return base.GetFromDbConverter(propertyInfo, sourceType);
|
||||
|
||||
return GetFromDbConverter(propertyInfo.PropertyType, sourceType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Migrator.Framework;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class MigrationLogger : ILogger
|
||||
{
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public void Started(List<long> currentVersion, long finalVersion)
|
||||
{
|
||||
Logger.Debug("Starting database migration {0} -> {1}", String.Join(",", currentVersion), finalVersion);
|
||||
}
|
||||
|
||||
public void MigrateUp(long version, string migrationName)
|
||||
{
|
||||
Logger.Info("Starting migration {0} [{1}]", version, migrationName);
|
||||
}
|
||||
|
||||
public void MigrateDown(long version, string migrationName)
|
||||
{
|
||||
Logger.Info("Starting MigrateDown {0} [{1}]", version, migrationName);
|
||||
}
|
||||
|
||||
public void Skipping(long version)
|
||||
{
|
||||
Logger.Info("Skipping MigrateDown {0}", version);
|
||||
}
|
||||
|
||||
public void RollingBack(long originalVersion)
|
||||
{
|
||||
Logger.Info("Rolling Back to {0}", originalVersion);
|
||||
}
|
||||
|
||||
public void ApplyingDBChange(string sql)
|
||||
{
|
||||
Logger.Info("Applying DB Change {0}", sql);
|
||||
}
|
||||
|
||||
public void Exception(long version, string migrationName, Exception ex)
|
||||
{
|
||||
Logger.ErrorException(migrationName + " " + version, ex);
|
||||
}
|
||||
|
||||
public void Exception(string message, Exception ex)
|
||||
{
|
||||
Logger.ErrorException(message, ex);
|
||||
}
|
||||
|
||||
public void Finished(List<long> currentVersion, long finalVersion)
|
||||
{
|
||||
Logger.Info("Finished Datastore migration {0} -> {1}", String.Join(",", currentVersion), finalVersion);
|
||||
}
|
||||
|
||||
public void Log(string format, params object[] args)
|
||||
{
|
||||
Logger.Info(format, args);
|
||||
}
|
||||
|
||||
public void Warn(string format, params object[] args)
|
||||
{
|
||||
Logger.Warn(format, args);
|
||||
}
|
||||
|
||||
public void Trace(string format, params object[] args)
|
||||
{
|
||||
//Logger.Trace(format, args);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,167 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20110707)]
|
||||
public class Migration20110707 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddTable("Series", new[]
|
||||
{
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("Title", DbType.String, ColumnProperty.Null),
|
||||
new Column("CleanTitle", DbType.String, ColumnProperty.Null),
|
||||
new Column("Status", DbType.String, ColumnProperty.Null),
|
||||
new Column("Overview", DbType.String,4000, ColumnProperty.Null),
|
||||
new Column("AirsDayOfWeek", DbType.Int32, ColumnProperty.Null),
|
||||
new Column("AirTimes", DbType.String, ColumnProperty.Null),
|
||||
new Column("Language", DbType.String, ColumnProperty.Null),
|
||||
new Column("Path", DbType.String,4000, ColumnProperty.NotNull),
|
||||
new Column("Monitored", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("QualityProfileId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SeasonFolder", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("LastInfoSync", DbType.DateTime, ColumnProperty.Null),
|
||||
new Column("LastDiskSync", DbType.DateTime, ColumnProperty.Null)
|
||||
});
|
||||
|
||||
Database.AddTable("Episodes", new[]
|
||||
{
|
||||
new Column("EpisodeId", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("TvDbEpisodeId", DbType.Int32, ColumnProperty.Null),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("EpisodeNumber", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Title", DbType.String,100, ColumnProperty.Null),
|
||||
new Column("Overview", DbType.String,4000, ColumnProperty.Null),
|
||||
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("EpisodeFileId", DbType.Int32, ColumnProperty.Null),
|
||||
new Column("AirDate", DbType.DateTime, ColumnProperty.Null),
|
||||
new Column("GrabDate", DbType.DateTime, ColumnProperty.Null)
|
||||
});
|
||||
|
||||
var indexName = MigrationsHelper.GetIndexName("Episodes", "SeriesId");
|
||||
Database.AddIndex(indexName, "Episodes", "SeriesId");
|
||||
|
||||
indexName = MigrationsHelper.GetIndexName("Episodes", "EpisodeFileId");
|
||||
Database.AddIndex(indexName, "Episodes", "EpisodeFileId");
|
||||
|
||||
indexName = MigrationsHelper.GetIndexName("Episodes", "AirDate");
|
||||
Database.AddIndex(indexName, "Episodes", "AirDate");
|
||||
|
||||
indexName = MigrationsHelper.GetIndexName("Episodes", "TvDbEpisodeId");
|
||||
Database.AddIndex(indexName, "Episodes", "TvDbEpisodeId");
|
||||
|
||||
|
||||
Database.AddTable("EpisodeFiles", new[]
|
||||
{
|
||||
new Column("EpisodeFileId", DbType.Int32,
|
||||
ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Path", DbType.String,4000, ColumnProperty.NotNull),
|
||||
new Column("Quality", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Proper", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Size", DbType.Int64, ColumnProperty.NotNull),
|
||||
new Column("DateAdded", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
indexName = MigrationsHelper.GetIndexName("EpisodeFiles", "SeriesId");
|
||||
Database.AddIndex(indexName, "Episodes", "SeriesId");
|
||||
|
||||
|
||||
Database.AddTable("Config", new[]
|
||||
{
|
||||
new Column("Key", DbType.String, ColumnProperty.PrimaryKey),
|
||||
new Column("Value", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("SceneMappings", new[]
|
||||
{
|
||||
new Column("CleanTitle", DbType.String, ColumnProperty.PrimaryKey),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SceneName", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("History", new[]
|
||||
{
|
||||
new Column("HistoryId", DbType.Int64, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("EpisodeId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("NzbTitle", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Date", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("Quality", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("IsProper", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("Indexer", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
indexName = MigrationsHelper.GetIndexName("History", "EpisodeId");
|
||||
Database.AddIndex(indexName, "History", "EpisodeId");
|
||||
|
||||
indexName = MigrationsHelper.GetIndexName("History", "SeriesId");
|
||||
Database.AddIndex(indexName, "History", "SeriesId");
|
||||
|
||||
Database.AddTable("RootDirs", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Path", DbType.String, 4000, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("ExternalNotificationSettings", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enabled", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("NotifierName", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("JobDefinitions", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("TypeName", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Interval", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("LastExecution", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("Success", DbType.Boolean, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("QualityProfiles", new[]
|
||||
{
|
||||
new Column("QualityProfileId", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Cutoff", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SonicAllowed", DbType.String, ColumnProperty.NotNull),
|
||||
});
|
||||
|
||||
Database.AddTable("IndexerDefinitions", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("IndexProviderType", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected override void LogDbUpgrade()
|
||||
{
|
||||
|
||||
Database.AddTable("Logs", new[]
|
||||
{
|
||||
new Column("LogId", DbType.Int64, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Message", DbType.String,4000, ColumnProperty.NotNull),
|
||||
new Column("Time", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("Logger", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Method", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Exception", DbType.String,4000, ColumnProperty.Null),
|
||||
new Column("ExceptionType", DbType.String, ColumnProperty.Null),
|
||||
new Column("Level", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20110726)]
|
||||
public class Migration20110726 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.RemoveTable("ExternalNotificationSettings");
|
||||
|
||||
Database.AddTable("ExternalNotificationDefinitions", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("ExternalNotificationProviderType", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20110909)]
|
||||
public class Migration20110909 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Series", "Runtime", DbType.Int32, ColumnProperty.Null);
|
||||
Database.AddColumn("Series", "BannerUrl", DbType.String, ColumnProperty.Null);
|
||||
|
||||
Database.AddTable("QualityTypes", new[]
|
||||
{
|
||||
new Column("QualityTypeId", DbType.Int32, ColumnProperty.PrimaryKey),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("MinSize", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("MaxSize", DbType.Int32, ColumnProperty.NotNull)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20111011)]
|
||||
public class Migration20111011 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Episodes", "PostDownloadStatus", DbType.Int32, ColumnProperty.Null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20111112)]
|
||||
public class Migration2011112 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddTable("NewznabDefinitions", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.Null),
|
||||
new Column("Url", DbType.String, ColumnProperty.Null),
|
||||
new Column("ApiKey", DbType.String, ColumnProperty.Null)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20111125)]
|
||||
public class Migration2011125 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Series", "IsDaily", DbType.Boolean, ColumnProperty.Null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120118)]
|
||||
public class Migration20120118 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.ExecuteNonQuery("DELETE FROM SERIES WHERE SeriesID = 0");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20120123)]
|
||||
public class Migration20120123 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Series", "BacklogSetting", DbType.Int32, ColumnProperty.Null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120220)]
|
||||
public class Migration20120220 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddTable("Seasons", new[]
|
||||
{
|
||||
new Column("SeasonId", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.ExecuteNonQuery(@"INSERT INTO Seasons (SeriesId, SeasonNumber, Ignored)
|
||||
SELECT SeriesId, SeasonNumber,
|
||||
CASE WHEN Count(*) =
|
||||
SUM(CASE WHEN Ignored = 1 THEN 1 ELSE 0 END) THEN 1 ELSE 0 END AS Ignored
|
||||
FROM Episodes
|
||||
GROUP BY SeriesId, SeasonNumber");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120227)]
|
||||
public class Migration20120227 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.ExecuteNonQuery(@"DELETE FROM Seasons WHERE SeasonNumber NOT IN
|
||||
(
|
||||
SELECT DISTINCT SeasonNumber
|
||||
FROM Episodes
|
||||
WHERE Seasons.SeriesId = Episodes.SeriesId
|
||||
)");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120228)]
|
||||
public class Migration20120228 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Series", "Network", DbType.String, ColumnProperty.Null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20120420)]
|
||||
public class Migration20120420 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddTable("SearchHistory", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("SeasonNumber", DbType.Int32, ColumnProperty.Null),
|
||||
new Column("EpisodeId", DbType.Int32, ColumnProperty.Null),
|
||||
new Column("SearchTime", DbType.DateTime, ColumnProperty.NotNull),
|
||||
new Column("SuccessfulDownload", DbType.Boolean, ColumnProperty.NotNull)
|
||||
});
|
||||
|
||||
Database.AddTable("SearchHistoryItems", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("SearchHistoryId", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("ReportTitle", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Indexer", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("NzbUrl", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("NzbInfoUrl", DbType.String, ColumnProperty.Null),
|
||||
new Column("Success", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("SearchError", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Quality", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Proper", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("Age", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Language", DbType.Int32, ColumnProperty.NotNull),
|
||||
new Column("Size", DbType.Int64, ColumnProperty.NotNull),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120430)]
|
||||
public class Migration20120430 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("History", "NzbInfoUrl", DbType.String, ColumnProperty.Null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120504)]
|
||||
public class Migration20120504 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("NewznabDefinitions", "BuiltIn", DbType.Boolean, ColumnProperty.Null);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120707)]
|
||||
public class Migration20120707 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddTable("MetadataDefinitions", new[]
|
||||
{
|
||||
new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
|
||||
new Column("Enable", DbType.Boolean, ColumnProperty.NotNull),
|
||||
new Column("MetadataProviderType", DbType.String, ColumnProperty.NotNull),
|
||||
new Column("Name", DbType.String, ColumnProperty.NotNull)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120727)]
|
||||
public class Migration20120727 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.ExecuteNonQuery(@"DELETE FROM History
|
||||
WHERE HistoryId IN
|
||||
(
|
||||
SELECT History.HistoryId
|
||||
FROM History
|
||||
LEFT OUTER JOIN Episodes
|
||||
ON History.EpisodeId = Episodes.EpisodeId
|
||||
WHERE Episodes.Title is null
|
||||
)");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120802)]
|
||||
public class Migration20120802 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("EpisodeFiles", new Column("SceneName", DbType.String, ColumnProperty.Null));
|
||||
Database.AddColumn("EpisodeFiles", new Column("ReleaseGroup", DbType.String, ColumnProperty.Null));
|
||||
Database.AddColumn("History", new Column("ReleaseGroup", DbType.String, ColumnProperty.Null));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120918)]
|
||||
public class Migration20120918 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Series", new Column("DownloadEpisodesAiredAfter", DbType.DateTime, ColumnProperty.Null));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20120919)]
|
||||
public class Migration20120919 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Series", new Column("CustomStartDate", DbType.DateTime, ColumnProperty.Null));
|
||||
|
||||
Database.ExecuteNonQuery("UPDATE Series SET CustomStartDate = DownloadEpisodesAiredAfter");
|
||||
|
||||
Database.RemoveColumn("Series", "DownloadEpisodesAiredAfter");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
|
||||
[Migration(20121012)]
|
||||
public class Migration20121012 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Episodes", new Column("AbsoluteEpisodeNumber", DbType.Int32, ColumnProperty.Null));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20121016)]
|
||||
public class Migration20121016 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Episodes", new Column("SceneAbsoluteEpisodeNumber", DbType.Int32, ColumnProperty.Null));
|
||||
Database.AddColumn("Episodes", new Column("SceneSeasonNumber", DbType.Int32, ColumnProperty.Null));
|
||||
Database.AddColumn("Episodes", new Column("SceneEpisodeNumber", DbType.Int32, ColumnProperty.Null));
|
||||
|
||||
Database.AddColumn("Series", new Column("UseSceneNumbering", DbType.Boolean, ColumnProperty.Null));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20121122)]
|
||||
public class Migration20121122 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.ExecuteNonQuery("UPDATE Config SET [KEY] = 'SabBacklogTvPriority' WHERE [KEY] = 'SabTvPriority'");
|
||||
Database.ExecuteNonQuery("UPDATE Config SET [KEY] = 'DownloadClientTvDirectory' WHERE [KEY] = 'SabTvDropDirectory'");
|
||||
|
||||
var priority = Database.ExecuteScalar("SELECT [Value] FROM Config WHERE [Key] = 'SabBacklogTvPriority'");
|
||||
|
||||
if (priority != null)
|
||||
Database.ExecuteNonQuery("INSERT INTO Config ([Key], [Value]) VALUES('SabRecentTvPriority', '" + priority + "')");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20121202)]
|
||||
public class Migration20121202 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.ExecuteNonQuery("DELETE FROM Config WHERE [KEY] = 'NewzbinUsername'");
|
||||
Database.ExecuteNonQuery("DELETE FROM Config WHERE [KEY] = 'NewzbinPassword'");
|
||||
Database.ExecuteNonQuery("DELETE FROM IndexerDefinitions WHERE IndexProviderType = 'NzbDrone.Core.Providers.Indexer.Newzbin'");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20121209)]
|
||||
public class Migration20121209 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.ExecuteNonQuery("DELETE FROM Config WHERE [KEY] = 'NzbMatrixUsername'");
|
||||
Database.ExecuteNonQuery("DELETE FROM Config WHERE [KEY] = 'NzbMatrixApiKey'");
|
||||
Database.ExecuteNonQuery("DELETE FROM IndexerDefinitions WHERE IndexProviderType = 'NzbDrone.Core.Providers.Indexer.NzbMatrix'");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20121218)]
|
||||
public class Migration20121218 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Series", new Column("TvRageId", DbType.Int32, ColumnProperty.Null));
|
||||
Database.AddColumn("Series", new Column("TvRageTitle", DbType.String, ColumnProperty.Null));
|
||||
Database.AddColumn("Series", new Column("UtcOffset", DbType.Int32, ColumnProperty.Null));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20121223)]
|
||||
public class Migration20121223 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("SceneMappings", new Column("SeasonNumber", DbType.Int32, ColumnProperty.Null));
|
||||
Database.ExecuteNonQuery("UPDATE SceneMappings SET SeasonNumber = -1 WHERE SeasonNumber IS NULL");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20121226)]
|
||||
public class Migration20121226 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Database.AddColumn("Series", new Column("FirstAired", DbType.DateTime, ColumnProperty.Null));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
[Migration(20130203)]
|
||||
public class Migration20130203 : NzbDroneMigration
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
var objectDb = GetObjectDb();
|
||||
|
||||
using (var dataReader = Database.ExecuteQuery("SELECT * from RootDirs"))
|
||||
{
|
||||
var dirs = new List<RootFolder>();
|
||||
while (dataReader.Read())
|
||||
{
|
||||
var rootFolder = new RootFolder { Path = dataReader["Path"].ToString() };
|
||||
dirs.Add(rootFolder);
|
||||
}
|
||||
objectDb.InsertMany(dirs);
|
||||
}
|
||||
|
||||
//Database.RemoveTable("RootDirs");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
public abstract class NzbDroneMigration : Migration
|
||||
{
|
||||
protected virtual void MainDbUpgrade()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void LogDbUpgrade()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Up()
|
||||
{
|
||||
if (Database.ConnectionString.Contains(PathExtentions.NZBDRONE_SQLCE_DB_FILE))
|
||||
{
|
||||
MainDbUpgrade();
|
||||
}
|
||||
else if (Database.ConnectionString.Contains(PathExtentions.LOG_SQLCE_DB_FILE))
|
||||
{
|
||||
LogDbUpgrade();
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDbUpgrade();
|
||||
MainDbUpgrade();
|
||||
}
|
||||
}
|
||||
|
||||
protected IObjectDatabase GetObjectDb()
|
||||
{
|
||||
var sqlCeConnection = SqlCeProxy.EnsureDatabase(Database.ConnectionString);
|
||||
|
||||
var eqPath = sqlCeConnection.Database.Replace(".sdf", ".eq");
|
||||
return new SiaqoDbFactory(new DiskProvider(),new EnvironmentProvider()).Create(eqPath);
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migrations
|
||||
{
|
||||
public class SchemaInfo
|
||||
{
|
||||
public int Version { get; set; }
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public class MigrationsHelper
|
||||
{
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
|
||||
public static void Run(string connectionString, bool trace)
|
||||
{
|
||||
SqlCeProxy.EnsureDatabase(connectionString);
|
||||
|
||||
logger.Trace("Preparing to run database migration");
|
||||
|
||||
try
|
||||
{
|
||||
Migrator.Migrator migrator;
|
||||
if (trace)
|
||||
{
|
||||
migrator = new Migrator.Migrator("sqlserverce", connectionString, Assembly.GetAssembly(typeof(MigrationsHelper)), true, new MigrationLogger());
|
||||
}
|
||||
else
|
||||
{
|
||||
migrator = new Migrator.Migrator("sqlserverce", connectionString, Assembly.GetAssembly(typeof(MigrationsHelper)));
|
||||
}
|
||||
|
||||
migrator.MigrateToLastVersion();
|
||||
logger.Info("Database migration completed");
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.FatalException("An error has occurred while migrating database", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string GetIndexName(string tableName, params string[] columns)
|
||||
{
|
||||
return String.Format("IX_{0}_{1}", tableName, String.Join("_", columns));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
// ReSharper disable CheckNamespace
|
||||
namespace PetaPoco
|
||||
{
|
||||
public class EpisodeSeasonRelator
|
||||
{
|
||||
public Season _current;
|
||||
public Season MapIt(Season season, Episode episode, EpisodeFile episodeFile)
|
||||
{
|
||||
// Terminating call. Since we can return null from this function
|
||||
// we need to be ready for PetaPoco to callback later with null
|
||||
// parameters
|
||||
if (season == null)
|
||||
return _current;
|
||||
|
||||
//Todo: Find a Query that doesn't require this check
|
||||
//Map EpisodeFile to Episode (Map to null if 0, because PetaPoco is returning a POCO when it should be null)
|
||||
episode.EpisodeFile = (episode.EpisodeFileId == 0 ? null : episodeFile);
|
||||
|
||||
// Is this the same season as the current one we're processing
|
||||
if (_current != null && _current.Id == season.Id)
|
||||
{
|
||||
// Yes, just add this post to the current author's collection of posts
|
||||
_current.Episodes.Add(episode);
|
||||
|
||||
// Return null to indicate we're not done with this author yet
|
||||
return null;
|
||||
}
|
||||
|
||||
// This is season different author to the current one, or this is the
|
||||
// first time through and we don't have an season yet
|
||||
|
||||
// Save the current author
|
||||
var prev = _current;
|
||||
|
||||
// Setup the new current season
|
||||
_current = season;
|
||||
_current.Episodes = new List<Episode>();
|
||||
_current.Episodes.Add(episode);
|
||||
|
||||
// Return the now populated previous season (or null if first time through)
|
||||
return prev;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
public static class SqlCeProxy
|
||||
{
|
||||
private static readonly object instance;
|
||||
private static readonly Type proxyType;
|
||||
|
||||
static SqlCeProxy()
|
||||
{
|
||||
proxyType = Assembly.Load("NzbDrone.SqlCe").GetExportedTypes()[0];
|
||||
instance = Activator.CreateInstance(proxyType);
|
||||
}
|
||||
|
||||
public static DbConnection EnsureDatabase(string connectionString)
|
||||
{
|
||||
var factoryMethod = proxyType.GetMethod("EnsureDatabase");
|
||||
return (DbConnection)factoryMethod.Invoke(instance, new object[] { connectionString });
|
||||
}
|
||||
|
||||
public static DbProviderFactory GetSqlCeProviderFactory()
|
||||
{
|
||||
var factoryMethod = proxyType.GetMethod("GetSqlCeProviderFactory");
|
||||
return (DbProviderFactory)factoryMethod.Invoke(instance, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.ExternalNotification
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
using System.Net;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Indexers
|
||||
{
|
||||
|
@ -15,17 +15,15 @@ public class RefreshEpisodeMetadata : IJob
|
||||
{
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RefreshEpisodeMetadata(IMediaFileService mediaFileService, ISeriesService seriesService,
|
||||
MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
ISeriesRepository seriesRepository)
|
||||
{
|
||||
_mediaFileService = mediaFileService;
|
||||
_seriesService = seriesService;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
@ -68,16 +66,6 @@ private void RefreshMetadata(ProgressNotification notification, Series series)
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_metadataProvider.CreateForEpisodeFiles(episodeFiles.ToList());
|
||||
}
|
||||
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.WarnException("An error has occurred while refreshing episode metadata", e);
|
||||
}
|
||||
|
||||
notification.CurrentMessage = String.Format("Epsiode metadata refresh completed for {0}", series.Title);
|
||||
}
|
||||
}
|
||||
|
@ -16,20 +16,16 @@ public class RenameSeasonJob : IJob
|
||||
{
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RenameSeasonJob(IMediaFileService mediaFileService, DiskScanProvider diskScanProvider, ISeriesService seriesService,
|
||||
MetadataProvider metadataProvider, ISeriesRepository seriesRepository, IEventAggregator eventAggregator)
|
||||
ISeriesRepository seriesRepository, IEventAggregator eventAggregator)
|
||||
{
|
||||
_mediaFileService = mediaFileService;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_seriesService = seriesService;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
@ -96,14 +92,7 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
return;
|
||||
}
|
||||
|
||||
//Remove & Create Metadata for episode files
|
||||
//Todo: Add a metadata manager to avoid this hack
|
||||
_metadataProvider.RemoveForEpisodeFiles(oldEpisodeFiles);
|
||||
_metadataProvider.CreateForEpisodeFiles(newEpisodeFiles);
|
||||
|
||||
//Start AfterRename
|
||||
var message = String.Format("Renamed: Series {0}, Season: {1}", series.Title, options.SeasonNumber);
|
||||
|
||||
_eventAggregator.Publish(new SeriesRenamedEvent(series));
|
||||
|
||||
notification.CurrentMessage = String.Format("Rename completed for {0} Season {1}", series.Title, options.SeasonNumber);
|
||||
|
@ -15,18 +15,16 @@ public class RenameSeriesJob : IJob
|
||||
{
|
||||
private readonly IMediaFileService _mediaFileService;
|
||||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public RenameSeriesJob(IMediaFileService mediaFileService, DiskScanProvider diskScanProvider,
|
||||
MetadataProvider metadataProvider,ISeriesRepository seriesRepository,IEventAggregator eventAggregator)
|
||||
ISeriesRepository seriesRepository,IEventAggregator eventAggregator)
|
||||
{
|
||||
_mediaFileService = mediaFileService;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
_eventAggregator = eventAggregator;
|
||||
}
|
||||
@ -91,10 +89,6 @@ public void Start(ProgressNotification notification, dynamic options)
|
||||
}
|
||||
}
|
||||
|
||||
//Remove & Create Metadata for episode files
|
||||
_metadataProvider.RemoveForEpisodeFiles(oldEpisodeFiles);
|
||||
_metadataProvider.CreateForEpisodeFiles(newEpisodeFiles);
|
||||
|
||||
//Start AfterRename
|
||||
|
||||
_eventAggregator.Publish(new SeriesRenamedEvent(series));
|
||||
|
@ -4,6 +4,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Helpers;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
@ -17,17 +18,17 @@ public class UpdateInfoJob : IJob
|
||||
{
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly IEpisodeService _episodeService;
|
||||
private readonly ReferenceDataProvider _referenceDataProvider;
|
||||
private readonly DailySeriesService _dailySeriesService;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public UpdateInfoJob(ISeriesService seriesService, IEpisodeService episodeService,
|
||||
ReferenceDataProvider referenceDataProvider, IConfigService configService, ISeriesRepository seriesRepository)
|
||||
DailySeriesService dailySeriesService, IConfigService configService, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_seriesService = seriesService;
|
||||
_episodeService = episodeService;
|
||||
_referenceDataProvider = referenceDataProvider;
|
||||
_dailySeriesService = dailySeriesService;
|
||||
_configService = configService;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
@ -67,7 +68,7 @@ public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
}
|
||||
|
||||
//Update any Daily Series in the DB with the IsDaily flag
|
||||
_referenceDataProvider.UpdateDailySeries();
|
||||
_dailySeriesService.UpdateDailySeries();
|
||||
|
||||
foreach (var seriesToUpdate in ListOfSeriesToUpdate)
|
||||
{
|
||||
|
@ -2,16 +2,17 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
|
||||
namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
public class UpdateSceneMappingsJob : IJob
|
||||
{
|
||||
private readonly SceneMappingProvider _sceneNameMappingProvider;
|
||||
private readonly SceneMappingService _sceneNameMappingService;
|
||||
|
||||
public UpdateSceneMappingsJob(SceneMappingProvider sceneNameMappingProvider)
|
||||
public UpdateSceneMappingsJob(SceneMappingService sceneNameMappingService)
|
||||
{
|
||||
_sceneNameMappingProvider = sceneNameMappingProvider;
|
||||
_sceneNameMappingService = sceneNameMappingService;
|
||||
}
|
||||
|
||||
public UpdateSceneMappingsJob()
|
||||
@ -31,7 +32,7 @@ public TimeSpan DefaultInterval
|
||||
|
||||
public virtual void Start(ProgressNotification notification, dynamic options)
|
||||
{
|
||||
_sceneNameMappingProvider.UpdateMappings();
|
||||
_sceneNameMappingService.UpdateMappings();
|
||||
}
|
||||
}
|
||||
}
|
@ -151,18 +151,6 @@
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Migrator, Version=0.9.1.26254, Culture=neutral, PublicKeyToken=3b3586e9632ecfce, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Migrator.NET\Migrator.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Migrator.Framework, Version=0.0.0.0, Culture=neutral, PublicKeyToken=3b3586e9632ecfce, processorArchitecture=x86">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Migrator.NET\Migrator.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Migrator.Providers, Version=0.0.0.0, Culture=neutral, PublicKeyToken=3b3586e9632ecfce, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libraries\Migrator.NET\Migrator.Providers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
@ -221,45 +209,8 @@
|
||||
<Compile Include="ContainerExtentions.cs" />
|
||||
<Compile Include="Datastore\ModelBase.cs" />
|
||||
<Compile Include="Datastore\BasicRepository.cs" />
|
||||
<Compile Include="Datastore\ConnectionFactory.cs" />
|
||||
<Compile Include="Datastore\ObjectDbFactory.cs" />
|
||||
<Compile Include="Datastore\SiaqodbProxy.cs" />
|
||||
<Compile Include="Datastore\CustomeMapper.cs" />
|
||||
<Compile Include="Datastore\MigrationLogger.cs" />
|
||||
<Compile Include="Datastore\MigrationsHelper.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20110707.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20110726.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20110909.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20111011.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20111112.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20111125.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120118.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120123.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120220.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120227.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120228.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120420.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120430.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120504.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120707.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120727.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120802.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120918.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20120919.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121012.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121016.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121122.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121202.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121209.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121218.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121223.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20121226.cs" />
|
||||
<Compile Include="Datastore\Migrations\Migration20130203.cs" />
|
||||
<Compile Include="Datastore\Migrations\NzbDroneMigration.cs" />
|
||||
<Compile Include="Datastore\Migrations\SchemaInfo.cs" />
|
||||
<Compile Include="Datastore\PetaPoco\EpisodeSeasonRelator.cs" />
|
||||
<Compile Include="Datastore\PetaPoco\PetaPoco.cs" />
|
||||
<Compile Include="Datastore\SqlCeProxy.cs" />
|
||||
<Compile Include="Download\EpisodeDownloadedEvent.cs" />
|
||||
<Compile Include="Download\EpisodeGrabbedEvent.cs" />
|
||||
<Compile Include="Download\SeriesRenamedEvent.cs" />
|
||||
@ -310,6 +261,9 @@
|
||||
<Compile Include="Model\MisnamedEpisodeModel.cs" />
|
||||
<Compile Include="Qualities\QualitySizeRepository.cs" />
|
||||
<Compile Include="Qualities\QualityProfileRepository.cs" />
|
||||
<Compile Include="ReferenceData\DailySeriesDataProxy.cs" />
|
||||
<Compile Include="ReferenceData\SceneMappingProxy.cs" />
|
||||
<Compile Include="ReferenceData\SceneMappingRepository.cs" />
|
||||
<Compile Include="Tv\EpisodeService.cs" />
|
||||
<Compile Include="Tv\Events\SeriesAddedEvent.cs" />
|
||||
<Compile Include="Tv\SeasonRepository.cs" />
|
||||
@ -356,7 +310,6 @@
|
||||
<Compile Include="Indexers\FileSharingTalk.cs" />
|
||||
<Compile Include="Indexers\Omgwtfnzbs.cs" />
|
||||
<Compile Include="Indexers\Wombles.cs" />
|
||||
<Compile Include="Providers\MetadataProvider.cs" />
|
||||
<Compile Include="Providers\Metadata\MetadataBase.cs" />
|
||||
<Compile Include="Providers\Metadata\Xbmc.cs" />
|
||||
<Compile Include="Providers\RecycleBinProvider.cs" />
|
||||
@ -392,7 +345,6 @@
|
||||
<Compile Include="Providers\TvRageProvider.cs" />
|
||||
<Compile Include="Providers\XemCommunicationProvider.cs" />
|
||||
<Compile Include="Providers\XemProvider.cs" />
|
||||
<Compile Include="Repository\MetadataDefinition.cs" />
|
||||
<Compile Include="Qualities\Quality.cs" />
|
||||
<Compile Include="Repository\Search\SearchHistoryItem.cs" />
|
||||
<Compile Include="Repository\Search\SearchHistory.cs" />
|
||||
@ -534,14 +486,14 @@
|
||||
<Compile Include="Qualities\QualitySizeService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Providers\ReferenceDataProvider.cs">
|
||||
<Compile Include="ReferenceData\DailySeriesService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="RootFolders\UnmappedFolder.cs" />
|
||||
<Compile Include="RootFolders\RootFolderService.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Providers\SceneMappingProvider.cs">
|
||||
<Compile Include="ReferenceData\SceneMappingProvider.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Providers\SearchProvider.cs">
|
||||
@ -593,7 +545,7 @@
|
||||
<Compile Include="Qualities\QualitySize.cs" />
|
||||
<Compile Include="Qualities\QualityProfile.cs" />
|
||||
<Compile Include="RootFolders\RootFolder.cs" />
|
||||
<Compile Include="Repository\SceneMapping.cs" />
|
||||
<Compile Include="ReferenceData\SceneMapping.cs" />
|
||||
<Compile Include="Tv\Series.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tvdb\Tvdb.cs" />
|
||||
|
@ -23,13 +23,11 @@ public BackupProvider()
|
||||
|
||||
public virtual string CreateBackupZip()
|
||||
{
|
||||
var dbFile = _environmentProvider.GetSqlCeMainDbPath();
|
||||
var configFile = _environmentProvider.GetConfigPath();
|
||||
var zipFile = _environmentProvider.GetConfigBackupFile();
|
||||
|
||||
using (var zip = new ZipFile())
|
||||
{
|
||||
zip.AddFile(dbFile, String.Empty);
|
||||
zip.AddFile(configFile, String.Empty);
|
||||
zip.Save(zipFile);
|
||||
}
|
||||
|
@ -1,172 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Providers.Metadata;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
using TvdbLib.Data;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class MetadataProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IDatabase _database;
|
||||
|
||||
private IList<MetadataBase> _metadataProviders;
|
||||
private readonly TvDbProvider _tvDbProvider;
|
||||
|
||||
public MetadataProvider(IDatabase database, IEnumerable<MetadataBase> metadataProviders,
|
||||
TvDbProvider tvDbProvider)
|
||||
{
|
||||
_database = database;
|
||||
_metadataProviders = metadataProviders.ToList();
|
||||
_tvDbProvider = tvDbProvider;
|
||||
|
||||
Initialize(_metadataProviders);
|
||||
}
|
||||
|
||||
public MetadataProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual List<MetadataDefinition> All()
|
||||
{
|
||||
return _database.Fetch<MetadataDefinition>();
|
||||
}
|
||||
|
||||
public virtual void SaveSettings(MetadataDefinition settings)
|
||||
{
|
||||
if (settings.Id == 0)
|
||||
{
|
||||
Logger.Debug("Adding Metabase definition for {0}", settings.Name);
|
||||
_database.Insert(settings);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Logger.Debug("Updating Metabase definition for {0}", settings.Name);
|
||||
_database.Update(settings);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual MetadataDefinition GetSettings(Type type)
|
||||
{
|
||||
return _database.SingleOrDefault<MetadataDefinition>("WHERE MetadataProviderType = @0", type.ToString());
|
||||
}
|
||||
|
||||
public virtual IList<MetadataBase> GetEnabledMetabaseProviders()
|
||||
{
|
||||
var all = All();
|
||||
return _metadataProviders.Where(i => all.Exists(c => c.MetadataProviderType == i.GetType().ToString() && c.Enable)).ToList();
|
||||
}
|
||||
|
||||
private void Initialize(IList<MetadataBase> metabaseProviders)
|
||||
{
|
||||
Logger.Debug("Initializing metabases. Count {0}", metabaseProviders.Count);
|
||||
|
||||
_metadataProviders = metabaseProviders;
|
||||
|
||||
var currentNotifiers = All();
|
||||
|
||||
foreach (var notificationProvider in metabaseProviders)
|
||||
{
|
||||
MetadataBase metadataProviderLocal = notificationProvider;
|
||||
if (!currentNotifiers.Exists(c => c.MetadataProviderType == metadataProviderLocal.GetType().ToString()))
|
||||
{
|
||||
var settings = new MetadataDefinition
|
||||
{
|
||||
Enable = false,
|
||||
MetadataProviderType = metadataProviderLocal.GetType().ToString(),
|
||||
Name = metadataProviderLocal.Name
|
||||
};
|
||||
|
||||
SaveSettings(settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void CreateForSeries(Series series)
|
||||
{
|
||||
var tvDbSeries = _tvDbProvider.GetSeries(series.TvDbId, false, true);
|
||||
|
||||
CreateForSeries(series, tvDbSeries);
|
||||
}
|
||||
|
||||
public virtual void CreateForSeries(Series series, TvdbSeries tvDbSeries)
|
||||
{
|
||||
foreach (var provider in _metadataProviders.Where(i => GetSettings(i.GetType()).Enable))
|
||||
{
|
||||
provider.CreateForSeries(series, tvDbSeries);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void CreateForEpisodeFile(EpisodeFile episodeFile)
|
||||
{
|
||||
var tvDbSeries = _tvDbProvider.GetSeries(episodeFile.SeriesId, true, true);
|
||||
|
||||
CreateForEpisodeFile(episodeFile, tvDbSeries);
|
||||
}
|
||||
|
||||
public virtual void CreateForEpisodeFile(EpisodeFile episodeFile, TvdbSeries tvDbSeries)
|
||||
{
|
||||
foreach (var provider in _metadataProviders.Where(i => GetSettings(i.GetType()).Enable))
|
||||
{
|
||||
provider.CreateForEpisodeFile(episodeFile, tvDbSeries);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void CreateForEpisodeFiles(List<EpisodeFile> episodeFiles)
|
||||
{
|
||||
if (episodeFiles == null || !episodeFiles.Any())
|
||||
{
|
||||
Logger.Warn("No episode files, no metadata will be created.");
|
||||
throw new ArgumentException("EpsiodeFiles must not be null or empty", "episodeFiles");
|
||||
}
|
||||
|
||||
Logger.Trace("Creating metadata for {0} files.", episodeFiles.Count);
|
||||
|
||||
var tvDbSeries = _tvDbProvider.GetSeries(episodeFiles.First().SeriesId, true, true);
|
||||
|
||||
foreach(var episodeFile in episodeFiles)
|
||||
{
|
||||
foreach (var provider in _metadataProviders.Where(i => GetSettings(i.GetType()).Enable))
|
||||
{
|
||||
Logger.Trace("Creating {0} metadata for {1}", provider.Name, episodeFile.Id);
|
||||
provider.CreateForEpisodeFile(episodeFile, tvDbSeries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveForSeries(Series series)
|
||||
{
|
||||
foreach (var provider in _metadataProviders.Where(i => GetSettings(i.GetType()).Enable))
|
||||
{
|
||||
provider.RemoveForSeries(series);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveForEpisodeFile(EpisodeFile episodeFile)
|
||||
{
|
||||
foreach (var provider in _metadataProviders.Where(i => GetSettings(i.GetType()).Enable))
|
||||
{
|
||||
provider.RemoveForEpisodeFile(episodeFile);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveForEpisodeFiles(List<EpisodeFile> episodeFiles)
|
||||
{
|
||||
foreach (var episodeFile in episodeFiles)
|
||||
{
|
||||
foreach (var provider in _metadataProviders.Where(i => GetSettings(i.GetType()).Enable))
|
||||
{
|
||||
provider.RemoveForEpisodeFile(episodeFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,17 +16,13 @@ public class PostDownloadProvider
|
||||
private static readonly Regex StatusRegex = new Regex(@"^_[\w_]*_", RegexOptions.Compiled);
|
||||
private readonly DiskProvider _diskProvider;
|
||||
private readonly DiskScanProvider _diskScanProvider;
|
||||
private readonly ISeriesService _seriesService;
|
||||
private readonly MetadataProvider _metadataProvider;
|
||||
private readonly ISeriesRepository _seriesRepository;
|
||||
|
||||
public PostDownloadProvider(DiskProvider diskProvider, DiskScanProvider diskScanProvider,
|
||||
ISeriesService seriesService, MetadataProvider metadataProvider,ISeriesRepository seriesRepository)
|
||||
ISeriesService seriesService, ISeriesRepository seriesRepository)
|
||||
{
|
||||
_diskProvider = diskProvider;
|
||||
_diskScanProvider = diskScanProvider;
|
||||
_seriesService = seriesService;
|
||||
_metadataProvider = metadataProvider;
|
||||
_seriesRepository = seriesRepository;
|
||||
}
|
||||
|
||||
@ -108,10 +104,6 @@ public virtual void ProcessDownload(DirectoryInfo subfolderInfo)
|
||||
var importedFiles = _diskScanProvider.Scan(series, subfolderInfo.FullName);
|
||||
importedFiles.ForEach(file => _diskScanProvider.MoveEpisodeFile(file, true));
|
||||
|
||||
//Create Metadata for all the episode files found
|
||||
if (importedFiles.Any())
|
||||
_metadataProvider.CreateForEpisodeFiles(importedFiles);
|
||||
|
||||
//Delete the folder only if folder is small enough
|
||||
if (_diskProvider.GetDirectorySize(subfolderInfo.FullName) < Constants.IgnoreFileSize)
|
||||
{
|
||||
@ -176,7 +168,6 @@ public virtual void ProcessVideoFile(string videoFile)
|
||||
if (episodeFile != null)
|
||||
{
|
||||
_diskScanProvider.MoveEpisodeFile(episodeFile, true);
|
||||
_metadataProvider.CreateForEpisodeFile(episodeFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,70 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class ReferenceDataProvider
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public ReferenceDataProvider(IDatabase database, HttpProvider httpProvider, IConfigService configService)
|
||||
{
|
||||
_database = database;
|
||||
_httpProvider = httpProvider;
|
||||
_configService = configService;
|
||||
}
|
||||
|
||||
public virtual void UpdateDailySeries()
|
||||
{
|
||||
//Update all series in DB
|
||||
//DailySeries.csv
|
||||
|
||||
var seriesIds = GetDailySeriesIds();
|
||||
|
||||
if (seriesIds.Any())
|
||||
{
|
||||
var dailySeriesString = String.Join(", ", seriesIds);
|
||||
var sql = String.Format("UPDATE Series SET IsDaily = 1 WHERE SeriesId in ({0})", dailySeriesString);
|
||||
|
||||
_database.Execute(sql);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsSeriesDaily(int seriesId)
|
||||
{
|
||||
return GetDailySeriesIds().Contains(seriesId);
|
||||
}
|
||||
|
||||
public List<int> GetDailySeriesIds()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds");
|
||||
|
||||
var seriesIds = JsonConvert.DeserializeObject<List<int>>(dailySeriesIds);
|
||||
|
||||
return seriesIds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WarnException("Failed to get Daily Series", ex);
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class SceneMappingProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly IDatabase _database;
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
public SceneMappingProvider(IDatabase database, HttpProvider httpProvider, IConfigService configService)
|
||||
{
|
||||
_database = database;
|
||||
_httpProvider = httpProvider;
|
||||
_configService = configService;
|
||||
}
|
||||
|
||||
public SceneMappingProvider()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual bool UpdateMappings()
|
||||
{
|
||||
try
|
||||
{
|
||||
var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active");
|
||||
var mappings = JsonConvert.DeserializeObject<List<SceneMapping>>(mappingsJson);
|
||||
|
||||
Logger.Debug("Deleting all existing Scene Mappings.");
|
||||
_database.Delete<SceneMapping>(String.Empty);
|
||||
|
||||
Logger.Debug("Adding Scene Mappings");
|
||||
_database.InsertMany(mappings);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoException("Failed to Update Scene Mappings:", ex);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual string GetSceneName(int seriesId, int seasonNumber = -1)
|
||||
{
|
||||
UpdateIfEmpty();
|
||||
|
||||
var item = _database.FirstOrDefault<SceneMapping>("WHERE SeriesId = @0 AND SeasonNumber = @1", seriesId, seasonNumber);
|
||||
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
return item.SceneName;
|
||||
}
|
||||
|
||||
public virtual Nullable<Int32> GetSeriesId(string cleanName)
|
||||
{
|
||||
UpdateIfEmpty();
|
||||
|
||||
var item = _database.SingleOrDefault<SceneMapping>("WHERE CleanTitle = @0", cleanName);
|
||||
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
return item.SeriesId;
|
||||
}
|
||||
|
||||
public void UpdateIfEmpty()
|
||||
{
|
||||
var count = _database.ExecuteScalar<int>("SELECT COUNT(*) FROM SceneMappings");
|
||||
|
||||
if (count == 0)
|
||||
UpdateMappings();
|
||||
}
|
||||
|
||||
public virtual bool SubmitMapping(int id, string postTitle)
|
||||
{
|
||||
Logger.Trace("Parsing example post");
|
||||
var episodeParseResult = Parser.ParseTitle(postTitle);
|
||||
var cleanTitle = episodeParseResult.CleanTitle;
|
||||
var title = episodeParseResult.SeriesTitle.Replace('.', ' ');
|
||||
Logger.Trace("Example post parsed. CleanTitle: {0}, Title: {1}", cleanTitle, title);
|
||||
|
||||
var newMapping = String.Format("/SceneMapping/AddPending?cleanTitle={0}&id={1}&title={2}", cleanTitle, id, title);
|
||||
var response = _httpProvider.DownloadString(_configService.ServiceRootUrl + newMapping);
|
||||
|
||||
if (JsonConvert.DeserializeObject<String>(response).Equals("Ok"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual string GetCleanName(int seriesId)
|
||||
{
|
||||
var item = _database.FirstOrDefault<SceneMapping>("WHERE SeriesId = @0", seriesId);
|
||||
|
||||
if (item == null)
|
||||
return null;
|
||||
|
||||
return item.CleanTitle;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
@ -21,9 +22,9 @@ public class DailyEpisodeSearch : SearchBase
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DailyEpisodeSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
ISeriesRepository seriesRepository)
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||
allowedDownloadSpecification)
|
||||
{
|
||||
_seriesRepository = seriesRepository;
|
||||
|
@ -6,6 +6,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
@ -20,9 +21,9 @@ public class EpisodeSearch : SearchBase
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public EpisodeSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
ISeriesRepository seriesRepository)
|
||||
: base(seriesService,seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
|
||||
: base(seriesService,seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||
allowedDownloadSpecification)
|
||||
{
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
@ -20,9 +21,9 @@ public class PartialSeasonSearch : SearchBase
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public PartialSeasonSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService,
|
||||
SceneMappingProvider sceneMappingProvider, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification,
|
||||
ISeriesRepository seriesRepository)
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
|
||||
: base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
|
||||
allowedDownloadSpecification)
|
||||
{
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Download;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
@ -21,13 +22,13 @@ public abstract class SearchBase
|
||||
protected readonly IEpisodeService _episodeService;
|
||||
protected readonly DownloadProvider _downloadProvider;
|
||||
protected readonly IIndexerService _indexerService;
|
||||
protected readonly SceneMappingProvider _sceneMappingProvider;
|
||||
protected readonly SceneMappingService _sceneMappingService;
|
||||
protected readonly AllowedDownloadSpecification _allowedDownloadSpecification;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
protected SearchBase(ISeriesService seriesService,ISeriesRepository seriesRepository, IEpisodeService episodeService, DownloadProvider downloadProvider,
|
||||
IIndexerService indexerService, SceneMappingProvider sceneMappingProvider,
|
||||
IIndexerService indexerService, SceneMappingService sceneMappingService,
|
||||
AllowedDownloadSpecification allowedDownloadSpecification)
|
||||
{
|
||||
_seriesService = seriesService;
|
||||
@ -35,7 +36,7 @@ protected SearchBase(ISeriesService seriesService,ISeriesRepository seriesReposi
|
||||
_episodeService = episodeService;
|
||||
_downloadProvider = downloadProvider;
|
||||
_indexerService = indexerService;
|
||||
_sceneMappingProvider = sceneMappingProvider;
|
||||
_sceneMappingService = sceneMappingService;
|
||||
_allowedDownloadSpecification = allowedDownloadSpecification;
|
||||
}
|
||||
|
||||
@ -168,12 +169,12 @@ public virtual Boolean DownloadReport(ProgressNotification notification, Episode
|
||||
|
||||
public virtual string GetSearchTitle(Series series, int seasonNumber = -1)
|
||||
{
|
||||
var seasonTitle = _sceneMappingProvider.GetSceneName(series.Id, seasonNumber);
|
||||
var seasonTitle = _sceneMappingService.GetSceneName(series.Id, seasonNumber);
|
||||
|
||||
if(!String.IsNullOrWhiteSpace(seasonTitle))
|
||||
return seasonTitle;
|
||||
|
||||
var title = _sceneMappingProvider.GetSceneName(series.Id);
|
||||
var title = _sceneMappingService.GetSceneName(series.Id);
|
||||
|
||||
if (String.IsNullOrWhiteSpace(title))
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.ReferenceData;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Core.Model.TvRage;
|
||||
using NzbDrone.Core.Repository;
|
||||
@ -12,16 +13,16 @@ namespace NzbDrone.Core.Providers
|
||||
{
|
||||
public class TvRageMappingProvider
|
||||
{
|
||||
private readonly SceneMappingProvider _sceneMappingProvider;
|
||||
private readonly SceneMappingService _sceneMappingService;
|
||||
private readonly TvRageProvider _tvRageProvider;
|
||||
private readonly IEpisodeService _episodeService;
|
||||
|
||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public TvRageMappingProvider(SceneMappingProvider sceneMappingProvider,
|
||||
public TvRageMappingProvider(SceneMappingService sceneMappingService,
|
||||
TvRageProvider tvRageProvider, IEpisodeService episodeService)
|
||||
{
|
||||
_sceneMappingProvider = sceneMappingProvider;
|
||||
_sceneMappingService = sceneMappingService;
|
||||
_tvRageProvider = tvRageProvider;
|
||||
_episodeService = episodeService;
|
||||
}
|
||||
@ -34,7 +35,7 @@ public Series FindMatchingTvRageSeries(Series series)
|
||||
{
|
||||
var firstEpisode = _episodeService.GetEpisode(series.Id, 1, 1);
|
||||
|
||||
var cleanName = _sceneMappingProvider.GetCleanName(series.Id);
|
||||
var cleanName = _sceneMappingService.GetCleanName(series.Id);
|
||||
var results = _tvRageProvider.SearchSeries(series.Title);
|
||||
var result = ProcessResults(results, series, cleanName, firstEpisode);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
using NLog;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Qualities
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Qualities
|
||||
{
|
||||
|
48
NzbDrone.Core/ReferenceData/DailySeriesDataProxy.cs
Normal file
48
NzbDrone.Core/ReferenceData/DailySeriesDataProxy.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
|
||||
public interface IDailySeriesDataProxy
|
||||
{
|
||||
IEnumerable<int> GetDailySeriesIds();
|
||||
}
|
||||
|
||||
public class DailySeriesDataProxy : IDailySeriesDataProxy
|
||||
{
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly IConfigService _configService;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public DailySeriesDataProxy(HttpProvider httpProvider, IConfigService configService, Logger logger)
|
||||
{
|
||||
_httpProvider = httpProvider;
|
||||
_configService = configService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IEnumerable<int> GetDailySeriesIds()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dailySeriesIds = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/DailySeries/AllIds");
|
||||
|
||||
var seriesIds = JsonConvert.DeserializeObject<List<int>>(dailySeriesIds);
|
||||
|
||||
return seriesIds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.WarnException("Failed to get Daily Series", ex);
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,66 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using PetaPoco;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
public class DailySeriesService
|
||||
{
|
||||
private readonly IDatabase _database;
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly ConfigProvider _configProvider;
|
||||
private readonly IDailySeriesDataProxy _proxy;
|
||||
private readonly ISeriesService _seriesService;
|
||||
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DailySeriesService(IDatabase database, HttpProvider httpProvider, ConfigProvider configProvider)
|
||||
public DailySeriesService(IDailySeriesDataProxy proxy, ISeriesService seriesService)
|
||||
{
|
||||
_database = database;
|
||||
_httpProvider = httpProvider;
|
||||
_configProvider = configProvider;
|
||||
_proxy = proxy;
|
||||
_seriesService = seriesService;
|
||||
}
|
||||
|
||||
public virtual void UpdateDailySeries()
|
||||
{
|
||||
//Update all series in DB
|
||||
//DailySeries.csv
|
||||
var dailySeries = _proxy.GetDailySeriesIds();
|
||||
|
||||
var seriesIds = GetDailySeriesIds();
|
||||
|
||||
if (seriesIds.Any())
|
||||
foreach (var tvdbId in dailySeries)
|
||||
{
|
||||
var dailySeriesString = String.Join(", ", seriesIds);
|
||||
var sql = String.Format("UPDATE Series SET IsDaily = 1 WHERE SeriesId in ({0})", dailySeriesString);
|
||||
var series = _seriesService.FindByTvdbId(tvdbId);
|
||||
|
||||
_database.Execute(sql);
|
||||
if (series != null)
|
||||
{
|
||||
_seriesService.SetSeriesType(series.Id, SeriesType.Daily);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool IsSeriesDaily(int seriesId)
|
||||
{
|
||||
return GetDailySeriesIds().Contains(seriesId);
|
||||
}
|
||||
|
||||
public List<int> GetDailySeriesIds()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dailySeriesIds = _httpProvider.DownloadString(_configProvider.ServiceRootUrl + "/DailySeries/AllIds");
|
||||
|
||||
var seriesIds = JsonConvert.DeserializeObject<List<int>>(dailySeriesIds);
|
||||
|
||||
return seriesIds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.WarnException("Failed to get Daily Series", ex);
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
13
NzbDrone.Core/ReferenceData/SceneMapping.cs
Normal file
13
NzbDrone.Core/ReferenceData/SceneMapping.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
public class SceneMapping : ModelBase
|
||||
{
|
||||
public string CleanTitle { get; set; }
|
||||
public int TvdbId { get; set; }
|
||||
public string SceneName { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
}
|
||||
}
|
73
NzbDrone.Core/ReferenceData/SceneMappingProvider.cs
Normal file
73
NzbDrone.Core/ReferenceData/SceneMappingProvider.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Lifecycle;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
public class SceneMappingService : IInitializable
|
||||
{
|
||||
private readonly ISceneMappingRepository _repository;
|
||||
private readonly ISceneMappingProxy _sceneMappingProxy;
|
||||
private readonly Logger _logger;
|
||||
|
||||
public SceneMappingService(ISceneMappingRepository repository, ISceneMappingProxy sceneMappingProxy, Logger logger)
|
||||
{
|
||||
_repository = repository;
|
||||
_sceneMappingProxy = sceneMappingProxy;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void UpdateMappings()
|
||||
{
|
||||
try
|
||||
{
|
||||
var mappings = _sceneMappingProxy.Fetch();
|
||||
|
||||
_repository.Purge();
|
||||
_repository.InsertMany(mappings);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.InfoException("Failed to Update Scene Mappings:", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string GetSceneName(int tvdbId, int seasonNumber = -1)
|
||||
{
|
||||
var mapping = _repository.FindByTvdbId(tvdbId);
|
||||
|
||||
if(mapping == null) return null;
|
||||
|
||||
return mapping.SceneName;
|
||||
}
|
||||
|
||||
public virtual Nullable<Int32> GetTvDbId(string cleanName)
|
||||
{
|
||||
var mapping = _repository.FindByCleanTitle(cleanName);
|
||||
|
||||
if (mapping == null)
|
||||
return null;
|
||||
|
||||
return mapping.TvdbId;
|
||||
}
|
||||
|
||||
|
||||
public virtual string GetCleanName(int tvdbId)
|
||||
{
|
||||
var mapping = _repository.FindByTvdbId(tvdbId);
|
||||
|
||||
if (mapping == null) return null;
|
||||
|
||||
return mapping.CleanTitle;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (!_repository.HasItems())
|
||||
{
|
||||
UpdateMappings();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
49
NzbDrone.Core/ReferenceData/SceneMappingProxy.cs
Normal file
49
NzbDrone.Core/ReferenceData/SceneMappingProxy.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Configuration;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
public interface ISceneMappingProxy
|
||||
{
|
||||
List<SceneMapping> Fetch();
|
||||
}
|
||||
|
||||
public class SceneMappingProxy : ISceneMappingProxy
|
||||
{
|
||||
private readonly HttpProvider _httpProvider;
|
||||
private readonly IConfigService _configService;
|
||||
|
||||
public SceneMappingProxy(HttpProvider httpProvider, IConfigService configService)
|
||||
{
|
||||
_httpProvider = httpProvider;
|
||||
_configService = configService;
|
||||
}
|
||||
|
||||
public List<SceneMapping> Fetch()
|
||||
{
|
||||
var mappingsJson = _httpProvider.DownloadString(_configService.ServiceRootUrl + "/SceneMapping/Active");
|
||||
return JsonConvert.DeserializeObject<List<SceneMapping>>(mappingsJson);
|
||||
}
|
||||
|
||||
|
||||
/* public virtual bool SubmitMapping(int id, string postTitle)
|
||||
{
|
||||
Logger.Trace("Parsing example post");
|
||||
var episodeParseResult = Parser.ParseTitle(postTitle);
|
||||
var cleanTitle = episodeParseResult.CleanTitle;
|
||||
var title = episodeParseResult.SeriesTitle.Replace('.', ' ');
|
||||
Logger.Trace("Example post parsed. CleanTitle: {0}, Title: {1}", cleanTitle, title);
|
||||
|
||||
var newMapping = String.Format("/SceneMapping/AddPending?cleanTitle={0}&id={1}&title={2}", cleanTitle, id, title);
|
||||
var response = _httpProvider.DownloadString(_configService.ServiceRootUrl + newMapping);
|
||||
|
||||
if (JsonConvert.DeserializeObject<String>(response).Equals("Ok"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
30
NzbDrone.Core/ReferenceData/SceneMappingRepository.cs
Normal file
30
NzbDrone.Core/ReferenceData/SceneMappingRepository.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Datastore;
|
||||
|
||||
namespace NzbDrone.Core.ReferenceData
|
||||
{
|
||||
public interface ISceneMappingRepository : IBasicRepository<SceneMapping>
|
||||
{
|
||||
SceneMapping FindByTvdbId(int tvdbId);
|
||||
SceneMapping FindByCleanTitle(string cleanTitle);
|
||||
|
||||
}
|
||||
|
||||
public class SceneMappingRepository : BasicRepository<SceneMapping>, ISceneMappingRepository
|
||||
{
|
||||
public SceneMappingRepository(IObjectDatabase objectDatabase)
|
||||
: base(objectDatabase)
|
||||
{
|
||||
}
|
||||
|
||||
public SceneMapping FindByTvdbId(int tvdbId)
|
||||
{
|
||||
return Queryable.SingleOrDefault(c => c.TvdbId == tvdbId);
|
||||
}
|
||||
|
||||
public SceneMapping FindByCleanTitle(string cleanTitle)
|
||||
{
|
||||
return Queryable.SingleOrDefault(c => c.CleanTitle == cleanTitle);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Repository
|
||||
{
|
||||
[TableName("MetadataDefinitions")]
|
||||
[PrimaryKey("Id", autoIncrement = true)]
|
||||
public class MetadataDefinition
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public bool Enable { get; set; }
|
||||
|
||||
public string MetadataProviderType { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using PetaPoco;
|
||||
|
||||
namespace NzbDrone.Core.Repository
|
||||
{
|
||||
[TableName("SceneMappings")]
|
||||
[PrimaryKey("CleanTitle", autoIncrement = false)]
|
||||
public class SceneMapping
|
||||
{
|
||||
public string CleanTitle { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "Id")]
|
||||
public int SeriesId { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "Title")]
|
||||
public string SceneName { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "Season")]
|
||||
public int SeasonNumber { get; set; }
|
||||
}
|
||||
}
|
@ -2,12 +2,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using NzbDrone.Core.Model;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Repository.Search
|
||||
{
|
||||
[PrimaryKey("Id", autoIncrement = true)]
|
||||
[TableName("SearchHistory")]
|
||||
public class SearchHistory
|
||||
{
|
||||
public int Id { get; set; }
|
||||
@ -17,31 +15,22 @@ public class SearchHistory
|
||||
public DateTime SearchTime { get; set; }
|
||||
public bool SuccessfulDownload { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public List<SearchHistoryItem> SearchHistoryItems { get; set; }
|
||||
|
||||
[Ignore]
|
||||
public List<int> Successes { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public string SeriesTitle { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public bool IsDaily { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public int? EpisodeNumber { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public string EpisodeTitle { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public DateTime AirDate { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public int TotalItems { get; set; }
|
||||
|
||||
[ResultColumn]
|
||||
public int SuccessfulCount { get; set; }
|
||||
}
|
||||
}
|
@ -1,14 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Repository.Search
|
||||
{
|
||||
[PrimaryKey("Id", autoIncrement = true)]
|
||||
[TableName("SearchHistoryItems")]
|
||||
public class SearchHistoryItem
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using PetaPoco;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user