Removed subsonic completely

This commit is contained in:
kay.one 2011-06-17 18:46:22 -07:00
parent f11b4af305
commit acf23d4fc2
65 changed files with 72 additions and 5368 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -37,32 +37,6 @@ namespace NzbDrone.Core.Test.Framework
}
public static IRepository GetEmptyRepository(bool enableLogging = false, string fileName = "")
{
Console.WriteLine("Creating an empty Subsonic repository");
if (String.IsNullOrWhiteSpace(fileName))
{
fileName = Guid.NewGuid() + ".db";
}
var provider = Connection.GetDataProvider(Connection.GetConnectionString(fileName));
var repo = Connection.CreateSimpleRepository(provider);
ForceMigration(repo);
//Migrations.Run(Connection.GetConnectionString(fileName), false);
if (enableLogging)
{
provider.Log = new NlogWriter();
}
Console.WriteLine("**********************************************************************************");
Console.WriteLine("*****************************REPO IS READY****************************************");
Console.WriteLine("**********************************************************************************");
return repo;
}
public static IDatabase GetEmptyDatabase(bool enableLogging = false, string fileName = "")
{
Console.WriteLine("Creating an empty PetaPoco database");
@ -71,9 +45,9 @@ namespace NzbDrone.Core.Test.Framework
{
fileName = Guid.NewGuid() + ".db";
}
var connectionString = Connection.GetConnectionString(fileName);
var database = Connection.GetPetaPocoDb(connectionString);
return database;

View File

@ -116,7 +116,6 @@
<Compile Include="Framework\ExceptionVerification.cs" />
<Compile Include="JobProviderTest.cs" />
<Compile Include="QualityTest.cs" />
<Compile Include="RepositoryProviderTest.cs" />
<Compile Include="RootDirProviderTest.cs" />
<Compile Include="IndexerProviderTest.cs" />
<Compile Include="HistoryProviderTest.cs" />
@ -128,7 +127,6 @@
<Compile Include="ParserTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QualityProfileTest.cs" />
<Compile Include="RepoTest.cs" />
<Compile Include="SabProviderTest.cs" />
<Compile Include="SceneMappingTest.cs" />
<Compile Include="SeriesProviderTest.cs" />

View File

@ -1,109 +0,0 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using NLog;
using NLog.Config;
using NUnit.Framework;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using LogLevel = NLog.LogLevel;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class RepoTest : TestBase
{
[Test]
public void to_many__series_to_episode()
{
//Arrange
var fakeSeries = Builder<Series>.CreateNew().With(s => s.SeriesId = 69).Build();
var fakeEpisode = Builder<Episode>.CreateNew().With(c => c.SeriesId = 69).Build();
//Act
var repo = MockLib.GetEmptyRepository(true);
repo.Add(fakeSeries);
repo.Add(fakeEpisode);
var fetchedSeries = repo.Single<Series>(fakeSeries.SeriesId);
//Assert
Assert.AreEqual(fakeSeries.SeriesId, fetchedSeries.SeriesId);
Assert.AreEqual(fakeSeries.Title, fetchedSeries.Title);
fetchedSeries.Episodes.Should().HaveCount(1);
Assert.AreEqual(fetchedSeries.Episodes[0].EpisodeId, fakeEpisode.EpisodeId);
Assert.AreEqual(fetchedSeries.Episodes[0].SeriesId, fakeEpisode.SeriesId);
Assert.AreEqual(fetchedSeries.Episodes[0].Title, fakeEpisode.Title);
}
[Test]
public void query_scratch_pad()
{
var repo = MockLib.GetEmptyRepository(true);
repo.All<Episode>().Where(e => !e.Ignored && e.AirDate <= DateTime.Today && e.AirDate.Year > 1900).Select(
s => s.Title).ToList();
}
[Test]
[Ignore]
public void episode_proxy_to_string()
{
var episode = Builder<Episode>.CreateNew()
.Build();
var series = Builder<Series>.CreateNew()
.With(s => s.SeriesId = episode.SeriesId)
.Build();
var repo = MockLib.GetEmptyRepository(true);
repo.Add(episode);
repo.Add(series);
//Act
var result = repo.Single<Episode>(episode.EpisodeId).ToString();
//Assert
Console.WriteLine(result);
result.Should().Contain(series.Title);
result.Should().Contain(episode.EpisodeNumber.ToString());
result.Should().Contain(episode.SeasonNumber.ToString());
}
[Test]
[Description(
"This test confirms that the tvdb id stored in the db is preserved rather than being replaced by an auto incrementing value"
)]
public void tvdbid_is_preserved()
{
//Arrange
var sonicRepo = MockLib.GetEmptyRepository(true);
var series = Builder<Series>.CreateNew().With(c => c.SeriesId = 18).Build();
//Act
var addId = sonicRepo.Add(series);
//Assert
Assert.AreEqual(18, addId);
var allSeries = sonicRepo.All<Series>();
allSeries.Should().HaveCount(1);
Assert.AreEqual(18, allSeries.First().SeriesId);
}
[Test]
public void enteties_toString()
{
Console.WriteLine(new Episode().ToString());
Console.WriteLine(new Series().ToString());
Console.WriteLine(new EpisodeFile().ToString());
}
}
}

View File

@ -1,175 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using FluentAssertions;
using Migrator.Framework;
using Migrator.Providers.SQLite;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using SubSonic.DataProviders;
using SubSonic.Repository;
using SubSonic.Schema;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class RepositoryProviderTest : TestBase
{
[Test]
public void Get_Assembly_repos()
{
var provider = new RepositoryProvider();
var types = provider.GetRepositoryTypes();
types.Should().Contain(typeof(Config));
types.Should().Contain(typeof(Episode));
types.Should().Contain(typeof(EpisodeFile));
types.Should().Contain(typeof(ExternalNotificationSetting));
types.Should().Contain(typeof(History));
types.Should().Contain(typeof(IndexerSetting));
types.Should().Contain(typeof(JobSetting));
types.Should().Contain(typeof(RootDir));
types.Should().Contain(typeof(Series));
types.Should().Contain(typeof(QualityProfile));
types.Should().NotContain(typeof(QualityTypes));
}
[Test]
public void Get_table_columns()
{
var provider = new RepositoryProvider();
var typeTable = provider.GetSchemaFromType(typeof(TestRepoType));
Assert.IsNotNull(typeTable.Columns);
typeTable.Columns.Should().HaveCount(3);
Assert.AreEqual("TestRepoTypes", typeTable.Name);
}
[Test]
public void ConvertToMigratorColumn()
{
var provider = new RepositoryProvider();
var subsonicColumn = new DatabaseColumn
{
Name = "Name",
DataType = DbType.Boolean,
IsPrimaryKey = true,
IsNullable = true
};
var migColumn = provider.ConvertToMigratorColumn(subsonicColumn);
Assert.IsTrue(migColumn.IsPrimaryKey);
Assert.AreEqual(ColumnProperty.Null | ColumnProperty.PrimaryKey, migColumn.ColumnProperty);
}
[Test]
public void GetDbColumns()
{
string connectionString = "Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True";
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
var repo = new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations);
var sqliteDatabase = new SQLiteTransformationProvider(new SQLiteDialect(), connectionString);
repo.Add(new TestRepoType() { Value = "Dummy" });
var repositoryProvider = new RepositoryProvider();
var columns = repositoryProvider.GetColumnsFromDatabase(sqliteDatabase, "TestRepoTypes");
columns.Should().HaveCount(3);
}
[Test]
public void DeleteColumns()
{
string connectionString = "Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True";
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
var sqliteDatabase = new SQLiteTransformationProvider(new SQLiteDialect(), connectionString);
var repo = new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations);
repo.Add(new TestRepoType() { Value = "Dummy" });
var repositoryProvider = new RepositoryProvider();
var typeSchema = repositoryProvider.GetSchemaFromType(typeof(TestRepoType2));
var columns = repositoryProvider.GetColumnsFromDatabase(sqliteDatabase, "TestRepoTypes");
var deletedColumns = repositoryProvider.GetDeletedColumns(typeSchema, columns);
deletedColumns.Should().HaveCount(1);
Assert.AreEqual("NewName", deletedColumns[0].Name.Trim('[', ']'));
}
[Test]
public void NewColumns()
{
string connectionString = "Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True";
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
var repo = new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations);
var sqliteDatabase = new SQLiteTransformationProvider(new SQLiteDialect(), connectionString);
repo.Add(new TestRepoType2() { Value = "dummy" });
var repositoryProvider = new RepositoryProvider();
var typeSchema = repositoryProvider.GetSchemaFromType(typeof(TestRepoType));
var columns = repositoryProvider.GetColumnsFromDatabase(sqliteDatabase, "TestRepoType2s");
var deletedColumns = repositoryProvider.GetNewColumns(typeSchema, columns);
deletedColumns.Should().HaveCount(1);
Assert.AreEqual("NewName", deletedColumns[0].Name.Trim('[', ']'));
}
}
public class TestRepoType
{
[SubSonicPrimaryKey]
public int TestId { get; set; }
[SubSonicColumnNameOverride("NewName")]
public Boolean BaddBoolean { get; set; }
public string Value { get; set; }
[SubSonicIgnore]
public Boolean BaddBooleanIgnored { get; set; }
}
public class TestRepoType2
{
[SubSonicPrimaryKey]
public int TestId { get; set; }
public string Value { get; set; }
[SubSonicIgnore]
public Boolean BaddBooleanIgnored { get; set; }
}
}

View File

@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test
private readonly List<int> seriesIds = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
private readonly List<Episode> episodes = new List<Episode>();
private readonly List<EpisodeFile> files = new List<EpisodeFile>();
private readonly IRepository repo = MockLib.GetEmptyRepository();
[TestFixtureSetUp]
public new void Setup()
@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test
.With(s => s.Monitored = true)
.Build();
repo.Add(series);
//repo.Add(series);
foreach (var _seasonNumber in seasonsNumbers)
{
@ -83,8 +83,8 @@ namespace NzbDrone.Core.Test
}
repo.AddMany(episodes);
repo.AddMany(files);
//repo.AddMany(episodes);
//repo.AddMany(files);
}
@ -140,7 +140,7 @@ namespace NzbDrone.Core.Test
public void get_episode_file_count_x100()
{
var mocker = new AutoMoq.AutoMoqer();
mocker.SetConstant(repo);
//mocker.SetConstant(repo);
mocker.SetConstant(mocker.Resolve<EpisodeProvider>());
var mediaProvider = mocker.Resolve<MediaFileProvider>();
@ -168,7 +168,7 @@ namespace NzbDrone.Core.Test
public void get_season_count_x5000()
{
var mocker = new AutoMoq.AutoMoqer();
mocker.SetConstant(repo);
//mocker.SetConstant(repo);
var provider = mocker.Resolve<EpisodeProvider>();
@ -195,7 +195,7 @@ namespace NzbDrone.Core.Test
public void get_episode_file_count_x10()
{
var mocker = new AutoMoq.AutoMoqer();
mocker.SetConstant(repo);
//mocker.SetConstant(repo);
mocker.SetConstant(mocker.Resolve<EpisodeProvider>());
var provider = mocker.Resolve<MediaFileProvider>();

View File

@ -1,7 +1,7 @@
using System;
using System.Linq;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Web.Hosting;
using Ninject;
using NLog;
@ -12,7 +12,6 @@ using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Providers.Jobs;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core
{
@ -71,8 +70,6 @@ namespace NzbDrone.Core
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString)).InRequestScope();
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString)).WhenInjectedInto<SubsonicTarget>().InSingletonScope();
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString)).WhenInjectedInto<LogProvider>().InRequestScope();
_kernel.Bind<IRepository>().ToConstant(Connection.CreateSimpleRepository(Connection.MainConnectionString)).InSingletonScope();
}
}

View File

@ -1,13 +1,9 @@
using System;
using System.Data;
using System.Data.Common;
using System.Data.SQLite;
using System.IO;
using MvcMiniProfiler.Data;
using PetaPoco;
using SubSonic.DataProviders;
using SubSonic.DataProviders.SQLite;
using SubSonic.Repository;
namespace NzbDrone.Core.Datastore
{
@ -42,21 +38,7 @@ namespace NzbDrone.Core.Datastore
}
}
public static IDataProvider GetDataProvider(string connectionString)
{
return new ProfiledSQLiteProvider(connectionString, "System.Data.SQLite");
}
public static IRepository CreateSimpleRepository(IDataProvider dataProvider)
{
return new SimpleRepository(dataProvider, SimpleRepositoryOptions.RunMigrations);
}
public static IRepository CreateSimpleRepository(string connectionString)
{
return new SimpleRepository(GetDataProvider(connectionString), SimpleRepositoryOptions.RunMigrations);
}
public static IDatabase GetPetaPocoDb(string connectionString)
{
MigrationsHelper.Run(connectionString, true);
@ -73,20 +55,4 @@ namespace NzbDrone.Core.Datastore
}
}
public class ProfiledSQLiteProvider : SQLiteProvider
{
public ProfiledSQLiteProvider(string connectionString, string providerName)
: base(connectionString, providerName)
{
}
public override System.Data.Common.DbConnection CreateConnection(string connectionString)
{
return ProfiledDbConnection.Get(base.CreateConnection(connectionString));
}
}
}

View File

@ -4,33 +4,6 @@ using Migrator.Framework;
namespace NzbDrone.Core.Datastore.Migrations
{
[Migration(20110523)]
public class Migration20110523 : Migration
{
public override void Up()
{
Database.RemoveTable(RepositoryProvider.JobsSchema.Name);
}
public override void Down()
{
throw new NotImplementedException();
}
}
[Migration(20110603)]
public class Migration20110603 : Migration
{
public override void Up()
{
Database.RemoveTable("Seasons");
}
public override void Down()
{
throw new NotImplementedException();
}
}
[Migration(20110604)]
public class Migration20110616 : Migration
@ -40,13 +13,13 @@ namespace NzbDrone.Core.Datastore.Migrations
Database.AddTable("Series", new[]
{
new Column("SeriesId", DbType.Int32, ColumnProperty.PrimaryKey),
new Column("Title", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("CleanTitle", DbType.String, ColumnProperty.NotNull, String.Empty),
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, ColumnProperty.NotNull, String.Empty),
new Column("Overview", DbType.String, ColumnProperty.Null),
new Column("AirsDayOfWeek", DbType.Int16, ColumnProperty.Null),
new Column("AirTimes", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("Language", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("AirTimes", DbType.String, ColumnProperty.Null),
new Column("Language", DbType.String, ColumnProperty.Null),
new Column("Path", DbType.String, ColumnProperty.NotNull),
new Column("Monitored", DbType.Boolean, ColumnProperty.NotNull),
new Column("QualityProfileId", DbType.Int16, ColumnProperty.NotNull),
@ -62,9 +35,9 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
new Column("SeasonNumber", DbType.Int16, ColumnProperty.NotNull),
new Column("EpisodeNumber", DbType.Int16, ColumnProperty.NotNull),
new Column("Title", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("Overview", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull, false),
new Column("Title", DbType.String, ColumnProperty.Null),
new Column("Overview", DbType.String, 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)

View File

@ -1,16 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using Migrator.Framework;
using NLog;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Extensions;
using SubSonic.Repository;
using SubSonic.Schema;
namespace NzbDrone.Core.Datastore
{
@ -52,63 +42,6 @@ namespace NzbDrone.Core.Datastore
}
}
public static void ForceSubSonicMigration(IRepository repository)
{
repository.Single<QualityProfile>(1);
repository.Single<IndexerSetting>(1);
repository.Single<SceneMapping>(1);
}
public static void RemoveDeletedColumns(ITransformationProvider transformationProvider)
{
var provider = new RepositoryProvider();
var repoTypes = provider.GetRepositoryTypes();
foreach (var repoType in repoTypes)
{
var typeSchema = provider.GetSchemaFromType(repoType);
if (transformationProvider.TableExists(typeSchema.Name))
{
var dbColumns = provider.GetColumnsFromDatabase(transformationProvider, typeSchema.Name);
var deletedColumns = provider.GetDeletedColumns(typeSchema, dbColumns);
foreach (var deletedColumn in deletedColumns)
{
Logger.Info("Removing column '{0}' from '{1}'", deletedColumn.Name, repoType.Name);
transformationProvider.RemoveColumn(typeSchema.Name, deletedColumn.Name);
}
}
}
}
public static void AddNewColumns(ITransformationProvider transformationProvider)
{
var provider = new RepositoryProvider();
var repoTypes = provider.GetRepositoryTypes();
foreach (var repoType in repoTypes)
{
var typeSchema = provider.GetSchemaFromType(repoType);
if (transformationProvider.TableExists(typeSchema.Name))
{
var dbColumns = provider.GetColumnsFromDatabase(transformationProvider, typeSchema.Name);
var newColumns = provider.GetNewColumns(typeSchema, dbColumns);
foreach (var newColumn in newColumns)
{
Logger.Info("Adding column '{0}' to '{1}'", newColumn.Name, repoType.Name);
transformationProvider.AddColumn(typeSchema.Name, newColumn);
}
}
}
}
}

View File

@ -13,16 +13,17 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.Common;
using System.Data;
using System.Text.RegularExpressions;
using System.Data.Common;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
namespace PetaPoco
{
@ -485,12 +486,12 @@ namespace PetaPoco
}
// Expand collections to parameter lists
if ((arg_val as System.Collections.IEnumerable) != null &&
if ((arg_val as IEnumerable) != null &&
(arg_val as string) == null &&
(arg_val as byte[]) == null)
{
var sb = new StringBuilder();
foreach (var i in arg_val as System.Collections.IEnumerable)
foreach (var i in arg_val as IEnumerable)
{
sb.Append((sb.Length == 0 ? "@" : ",@") + args_dest.Count.ToString());
args_dest.Add(i);
@ -510,9 +511,9 @@ namespace PetaPoco
void AddParam(IDbCommand cmd, object item, string ParameterPrefix)
{
// Convert value to from poco type to db type
if (Database.Mapper != null && item != null)
if (Mapper != null && item != null)
{
var fn = Database.Mapper.GetToDbConverter(item.GetType());
var fn = Mapper.GetToDbConverter(item.GetType());
if (fn != null)
item = fn(item);
}
@ -625,8 +626,8 @@ namespace PetaPoco
// Override this to log/capture exceptions
public virtual void OnException(Exception x)
{
System.Diagnostics.Debug.WriteLine(x.ToString());
System.Diagnostics.Debug.WriteLine(LastCommand);
Debug.WriteLine(x.ToString());
Debug.WriteLine(LastCommand);
}
// Override this to log commands, or modify command before execution
@ -1120,7 +1121,7 @@ namespace PetaPoco
// Various cached stuff
static Dictionary<string, object> MultiPocoFactories = new Dictionary<string, object>();
static Dictionary<string, object> AutoMappers = new Dictionary<string, object>();
static System.Threading.ReaderWriterLockSlim RWLock = new System.Threading.ReaderWriterLockSlim();
static ReaderWriterLockSlim RWLock = new ReaderWriterLockSlim();
// Get (or create) the multi-poco factory for a query
Func<IDataReader, object, TRet> GetMultiPocoFactory<TRet>(Type[] types, string sql, IDataReader r)
@ -1954,7 +1955,7 @@ namespace PetaPoco
#endif
return ForType(t);
}
static System.Threading.ReaderWriterLockSlim RWLock = new System.Threading.ReaderWriterLockSlim();
static ReaderWriterLockSlim RWLock = new ReaderWriterLockSlim();
public static PocoData ForType(Type t)
{
#if !PETAPOCO_NO_DYNAMIC
@ -2018,8 +2019,8 @@ namespace PetaPoco
TableInfo.AutoIncrement = TableInfo.AutoIncrement ? !TableInfo.PrimaryKey.Contains(',') : TableInfo.AutoIncrement;
// Call column mapper
if (Database.Mapper != null)
Database.Mapper.GetTableInfo(t, TableInfo);
if (Mapper != null)
Mapper.GetTableInfo(t, TableInfo);
// Work out bound properties
bool ExplicitColumns = t.GetCustomAttributes(typeof(ExplicitColumnsAttribute), true).Length > 0;
@ -2055,7 +2056,7 @@ namespace PetaPoco
if (pc.ColumnName == null)
{
pc.ColumnName = pi.Name;
if (Database.Mapper != null && !Database.Mapper.MapPropertyToColumn(pi, ref pc.ColumnName, ref pc.ResultColumn))
if (Mapper != null && !Mapper.MapPropertyToColumn(pi, ref pc.ColumnName, ref pc.ResultColumn))
continue;
}
@ -2307,12 +2308,12 @@ namespace PetaPoco
Func<object, object> converter = null;
// Get converter from the mapper
if (Database.Mapper != null)
if (Mapper != null)
{
DestinationInfo destinationInfo = pc != null
? new DestinationInfo(pc.PropertyInfo)
: new DestinationInfo(dstType);
converter = Database.Mapper.GetFromDbConverter(destinationInfo, srcType);
converter = Mapper.GetFromDbConverter(destinationInfo, srcType);
}
// Standard DateTime->Utc mapper

View File

@ -1,98 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using Migrator.Providers;
using Migrator.Providers.SQLite;
using NzbDrone.Core.Repository;
using SubSonic.DataProviders;
using SubSonic.Extensions;
using SubSonic.Schema;
using Migrator.Framework;
namespace NzbDrone.Core.Datastore
{
public class RepositoryProvider
{
public static readonly ITable EpisodesSchema = new RepositoryProvider().GetSchemaFromType(typeof(Episode));
public static readonly ITable SeriesSchema = new RepositoryProvider().GetSchemaFromType(typeof(Series));
public static readonly ITable EpisodeFilesSchema = new RepositoryProvider().GetSchemaFromType(typeof(EpisodeFile));
public static readonly ITable JobsSchema = new RepositoryProvider().GetSchemaFromType(typeof(JobSetting));
public virtual IList<Type> GetRepositoryTypes()
{
var coreAssembly = Assembly.GetExecutingAssembly();
var repoTypes = coreAssembly.GetTypes().Where(t => !String.IsNullOrWhiteSpace(t.Namespace) && t.Namespace.StartsWith("NzbDrone.Core.Repository"));
repoTypes = repoTypes.Where(r => !r.IsEnum);
return repoTypes.ToList();
}
public virtual ITable GetSchemaFromType(Type type)
{
return type.ToSchemaTable(Connection.GetDataProvider(Connection.MainConnectionString));
}
public virtual Column[] GetColumnsFromDatabase(ITransformationProvider database, string tableName)
{
return database.GetColumns(tableName);
}
public virtual List<Column> GetDeletedColumns(ITable typeSchema, Column[] dbColumns)
{
var deleteColumns = new List<Column>();
foreach (var dbColumn in dbColumns)
{
if (!typeSchema.Columns.ToList().Exists(c => c.Name == dbColumn.Name.Trim('[', ']')))
{
deleteColumns.Add(dbColumn);
}
}
return deleteColumns;
}
public virtual List<Column> GetNewColumns(ITable typeSchema, Column[] dbColumns)
{
var newColumns = new List<Column>();
foreach (var typeColumn in typeSchema.Columns)
{
if (!dbColumns.ToList().Exists(c => c.Name.Trim('[', ']') == typeColumn.Name))
{
newColumns.Add(ConvertToMigratorColumn(typeColumn));
}
}
return newColumns;
}
public virtual Column ConvertToMigratorColumn(SubSonic.Schema.IColumn subsonicColumns)
{
var migColumn = new Column(subsonicColumns.Name, subsonicColumns.DataType);
if (subsonicColumns.IsPrimaryKey)
{
migColumn.ColumnProperty = ColumnProperty.PrimaryKey;
}
if (subsonicColumns.IsNullable)
{
migColumn.ColumnProperty = migColumn.ColumnProperty | ColumnProperty.Null;
}
else
{
migColumn.ColumnProperty = migColumn.ColumnProperty | ColumnProperty.NotNull;
migColumn.DefaultValue = false;
}
return migColumn;
}
}
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Migrator.Framework;
using Migrator.Providers.SQLite;

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Helpers
{

View File

@ -1,6 +1,5 @@
using System;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Instrumentation
{

View File

@ -1,7 +1,6 @@
using System.Diagnostics;
using System.IO;
using Ninject;
using Ninject.Activation;
using NLog;
using NLog.Config;

View File

@ -1,8 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Instrumentation
{

View File

@ -2,7 +2,6 @@
using NLog;
using NLog.Targets;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Instrumentation
{

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public class ConnectionInfoModel
{

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Model
{

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public enum ExternalNotificationType
{

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Model
@ -22,19 +19,19 @@ namespace NzbDrone.Core.Model
public int CompareTo(Quality other)
{
if (other.QualityType > this.QualityType)
if (other.QualityType > QualityType)
return -1;
if (other.QualityType < this.QualityType)
if (other.QualityType < QualityType)
return 1;
if (other.QualityType == this.QualityType && other.Proper == this.Proper)
if (other.QualityType == QualityType && other.Proper == Proper)
return 0;
if (this.Proper && !other.Proper)
if (Proper && !other.Proper)
return 1;
if (!this.Proper && other.Proper)
if (!Proper && other.Proper)
return -1;
return 0;

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public class SabnzbdInfoModel
{

View File

@ -1,6 +1,4 @@
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public class SeasonParseResult
{

View File

@ -141,10 +141,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\NLog.dll</HintPath>
</Reference>
<Reference Include="SubSonic.Core, Version=3.0.0.3, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\SubSonic.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
@ -172,7 +168,6 @@
<Compile Include="Datastore\MigrationsHelper.cs" />
<Compile Include="Datastore\CustomeMapper.cs" />
<Compile Include="Datastore\Migrations\Migration.cs" />
<Compile Include="Datastore\RepositoryProvider.cs" />
<Compile Include="Datastore\SqliteProvider.cs" />
<Compile Include="Helpers\EpisodeRenameHelper.cs" />
<Compile Include="Helpers\EpisodeSortingHelper.cs" />

View File

@ -4,10 +4,8 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Text.RegularExpressions;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{

View File

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Core
{

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace NzbDrone.Core.Providers.Core
{

View File

@ -3,7 +3,6 @@ using System.IO;
using System.Net;
using NLog;
namespace NzbDrone.Core.Providers.Core
{
public class HttpProvider

View File

@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

View File

@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;

View File

@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

View File

@ -5,7 +5,6 @@ using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
namespace NzbDrone.Core.Providers.Indexer
{

View File

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{

View File

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{

View File

@ -1,11 +1,7 @@
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{

View File

@ -1,11 +1,7 @@
using System;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Jobs
{

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;

View File

@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers.Jobs

View File

@ -8,7 +8,6 @@ using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Jobs
{

View File

@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers.Jobs
{

View File

@ -1,7 +1,4 @@
using System;
using System.IO;
using System.Linq;
using Ninject;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;

View File

@ -1,5 +1,5 @@
using System.Linq;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;

View File

@ -1,7 +1,4 @@
using System.Linq;
using System.Collections.Generic;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers.Jobs
{

View File

@ -5,7 +5,6 @@ using Ninject;
using NLog;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

View File

@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

View File

@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using NLog;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

View File

@ -114,7 +114,7 @@ namespace NzbDrone.Core.Providers
return GetSeries(seriesId.Value);
}
return _database.Single<Series>("WHERE CleanTitle = @0", normalizeTitle);
return _database.FirstOrDefault<Series>("WHERE CleanTitle = @0", normalizeTitle);
}
public virtual void UpdateSeries(Series series)

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
namespace NzbDrone.Core.Providers

View File

@ -1,6 +1,6 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using NLog;
using TvdbLib;

View File

@ -5,7 +5,6 @@ using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

View File

@ -4,7 +4,6 @@ using System.Linq;
using System.Xml.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers

View File

@ -1,5 +1,4 @@
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{

View File

@ -2,8 +2,6 @@
using System.Collections.Generic;
using NzbDrone.Core.Model;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
@ -11,7 +9,7 @@ namespace NzbDrone.Core.Repository
[PrimaryKey("EpisodeId", autoIncrement = true)]
public class Episode
{
[SubSonicPrimaryKey]
public virtual int EpisodeId { get; set; }
public virtual int? TvDbEpisodeId { get; set; }
@ -23,12 +21,11 @@ namespace NzbDrone.Core.Repository
public virtual string Title { get; set; }
public virtual DateTime AirDate { get; set; }
[SubSonicLongString]
public virtual string Overview { get; set; }
public virtual Boolean Ignored { get; set; }
[SubSonicIgnore]
[Ignore]
public Boolean IsDailyEpisode
{
@ -47,7 +44,7 @@ namespace NzbDrone.Core.Repository
/// </remarks>
public virtual DateTime? GrabDate { get; set; }
[SubSonicIgnore]
[Ignore]
public EpisodeStatusType Status
{
@ -72,15 +69,15 @@ namespace NzbDrone.Core.Repository
}
}
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
[Ignore]
public virtual Series Series { get; set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
[Ignore]
public virtual EpisodeFile EpisodeFile { get; set; }
[SubSonicToManyRelation]
[Ignore]
public virtual IList<History> Histories { get; protected set; }

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PetaPoco;
using PetaPoco;
namespace NzbDrone.Core.Repository
{

View File

@ -1,8 +1,6 @@
using System;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{

View File

@ -1,6 +1,5 @@
using System;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
@ -8,7 +7,6 @@ namespace NzbDrone.Core.Repository
[PrimaryKey("Id", autoIncrement = true)]
public class JobSetting
{
[SubSonicPrimaryKey(true)]
public Int32 Id { get; set; }
public Boolean Enable { get; set; }

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository.Quality
{
@ -11,7 +10,7 @@ namespace NzbDrone.Core.Repository.Quality
[PrimaryKey("QualityProfileId", autoIncrement = true)]
public class QualityProfile
{
[SubSonicPrimaryKey]
public virtual int QualityProfileId { get; set; }
[Required(ErrorMessage = "A Name is Required")]
@ -20,12 +19,10 @@ namespace NzbDrone.Core.Repository.Quality
public string Name { get; set; }
[Ignore]
[SubSonicIgnore]
[DisplayName("Allowed Qualities")]
public List<QualityTypes> Allowed { get; set; }
[Ignore]
[SubSonicIgnore]
[DisplayName("Allowed Qualities String")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string AllowedString { get; set; }
@ -60,7 +57,7 @@ namespace NzbDrone.Core.Repository.Quality
}
[Ignore]
[SubSonicToManyRelation]
public virtual List<Series> Series { get; private set; }
}
}

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PetaPoco;
using PetaPoco;
namespace NzbDrone.Core.Repository
{

View File

@ -3,35 +3,34 @@ using System.Collections.Generic;
using System.ComponentModel;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
[PrimaryKey("SeriesId", autoIncrement = false)]
public class Series
{
[SubSonicPrimaryKey(false)]
public virtual int SeriesId { get; set; }
[SubSonicNullString]
public string Title { get; set; }
[SubSonicNullString]
public string CleanTitle { get; set; }
[SubSonicNullString]
public string Status { get; set; }
[SubSonicNullString]
public string Overview { get; set; }
[DisplayName("Air on")]
public DayOfWeek? AirsDayOfWeek { get; set; }
[SubSonicNullString]
public String AirTimes { get; set; }
[SubSonicNullString]
public string Language { get; set; }
public string Path { get; set; }
@ -56,15 +55,12 @@ namespace NzbDrone.Core.Repository
public DateTime? LastDiskSync { get; set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true, JoinKeyName = "QualityProfileId")]
[Ignore]
public virtual QualityProfile QualityProfile { get; set; }
[SubSonicToManyRelation]
[Ignore]
public virtual IList<Episode> Episodes { get; set; }
[SubSonicToManyRelation]
[Ignore]
public virtual IList<EpisodeFile> EpisodeFiles { get; protected set; }
}

View File

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Caching;
using NLog;

View File

@ -71,10 +71,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\NLog.dll</HintPath>
</Reference>
<Reference Include="SubSonic.Core, Version=3.0.0.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\SubSonic.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />