mirror of https://github.com/Radarr/Radarr
wtf git extentions?
This commit is contained in:
parent
885688f4c2
commit
83186ba87b
|
@ -36,6 +36,11 @@ namespace NzbDrone.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsMono
|
||||||
|
{
|
||||||
|
get { return Type.GetType("Mono.Runtime") != null; }
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsDebug
|
public static bool IsDebug
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -5,6 +5,7 @@ using Autofac;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NCrunch.Framework;
|
using NCrunch.Framework;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Jobs;
|
using NzbDrone.Core.Jobs;
|
||||||
using NzbDrone.Core.Providers;
|
using NzbDrone.Core.Providers;
|
||||||
using NzbDrone.Core.Providers.ExternalNotification;
|
using NzbDrone.Core.Providers.ExternalNotification;
|
||||||
|
@ -28,9 +29,10 @@ namespace NzbDrone.Core.Test
|
||||||
|
|
||||||
public CentralDispatchFixture()
|
public CentralDispatchFixture()
|
||||||
{
|
{
|
||||||
#if __MonoCS__
|
if (EnvironmentProvider.IsMono)
|
||||||
throw new IgnoreException("SqlCe is not supported");
|
{
|
||||||
#endif
|
throw new IgnoreException("SqlCe is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
InitLogging();
|
InitLogging();
|
||||||
var dispatch = new CentralDispatch();
|
var dispatch = new CentralDispatch();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Model.Notification;
|
using NzbDrone.Core.Model.Notification;
|
||||||
using NzbDrone.Core.Providers.Core;
|
using NzbDrone.Core.Providers.Core;
|
||||||
|
@ -16,10 +17,10 @@ namespace NzbDrone.Core.Test.Framework
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void CoreTestSetup()
|
public void CoreTestSetup()
|
||||||
{
|
{
|
||||||
|
if (EnvironmentProvider.IsMono)
|
||||||
#if __MonoCS__
|
{
|
||||||
throw new IgnoreException("SqlCe is not supported in mono.");
|
throw new IgnoreException("SqlCe is not supported in mono.");
|
||||||
#endif
|
}
|
||||||
|
|
||||||
if (NCrunch.Framework.NCrunchEnvironment.NCrunchIsResident())
|
if (NCrunch.Framework.NCrunchEnvironment.NCrunchIsResident())
|
||||||
{
|
{
|
||||||
|
|
|
@ -440,8 +440,9 @@
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PreBuildEvent>
|
<PreBuildEvent>if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
|
||||||
</PreBuildEvent>
|
|
||||||
|
xcopy /s /y "$(SolutionDir)\SqlCe\*.*" "$(TargetDir)"</PreBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
|
<PostBuildEvent>if not exist "$(TargetDir)x86" md "$(TargetDir)x86"
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Data.OleDb;
|
|
||||||
using System.Data.SqlClient;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
|
@ -21,22 +19,16 @@ namespace NzbDrone.Core.Datastore
|
||||||
{
|
{
|
||||||
Database.Mapper = new CustomeMapper();
|
Database.Mapper = new CustomeMapper();
|
||||||
|
|
||||||
|
if (EnvironmentProvider.IsMono) return;
|
||||||
#if __MonoCS__
|
|
||||||
#else
|
|
||||||
|
|
||||||
var dataSet = (System.Data.DataSet)ConfigurationManager.GetSection("system.data");
|
var dataSet = (System.Data.DataSet)ConfigurationManager.GetSection("system.data");
|
||||||
dataSet.Tables[0].Rows.Add("Microsoft SQL Server Compact Data Provider 4.0"
|
dataSet.Tables[0].Rows.Add("Microsoft SQL Server Compact Data Provider 4.0"
|
||||||
, "System.Data.SqlServerCe.4.0"
|
, "System.Data.SqlServerCe.4.0"
|
||||||
, ".NET Framework Data Provider for Microsoft SQL Server Compact"
|
, ".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");
|
,
|
||||||
|
"System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
|
||||||
var proxyType = Assembly.Load("NzbDrone.SqlCe").GetExportedTypes()[0];
|
|
||||||
var instance = Activator.CreateInstance(proxyType);
|
|
||||||
var factoryMethod = proxyType.GetMethod("GetSqlCeProviderFactory");
|
|
||||||
_factory = (DbProviderFactory)factoryMethod.Invoke(instance, null);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
_factory = SqlCeProxy.GetSqlCeProviderFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,9 +75,10 @@ namespace NzbDrone.Core.Datastore
|
||||||
|
|
||||||
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
|
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
|
||||||
{
|
{
|
||||||
#if __MonoCS__
|
if (EnvironmentProvider.IsMono)
|
||||||
throw new NotSupportedException("SqlCe is not supported in mono");
|
{
|
||||||
#endif
|
throw new NotSupportedException("SqlCe is not supported in mono");
|
||||||
|
}
|
||||||
|
|
||||||
lock (initilized)
|
lock (initilized)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Data.Common;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using Migrator.Framework;
|
using Migrator.Framework;
|
||||||
using NzbDrone.Common;
|
using NzbDrone.Common;
|
||||||
|
|
||||||
|
@ -35,8 +37,8 @@ namespace NzbDrone.Core.Datastore.Migrations
|
||||||
|
|
||||||
protected EloqueraDb GetObjectDb()
|
protected EloqueraDb GetObjectDb()
|
||||||
{
|
{
|
||||||
var sqlCeConnection = new SqlConnection(Database.ConnectionString);
|
var sqlCeConnection = SqlCeProxy.EnsureDatabase(Database.ConnectionString);
|
||||||
|
|
||||||
var eqPath = sqlCeConnection.Database.Replace(".sdf", ".eq");
|
var eqPath = sqlCeConnection.Database.Replace(".sdf", ".eq");
|
||||||
return new EloqueraDbFactory(new EnvironmentProvider()).Create(eqPath);
|
return new EloqueraDbFactory(new EnvironmentProvider()).Create(eqPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
|
@ -13,7 +12,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
|
|
||||||
public static void Run(string connectionString, bool trace)
|
public static void Run(string connectionString, bool trace)
|
||||||
{
|
{
|
||||||
EnsureDatabase(connectionString);
|
SqlCeProxy.EnsureDatabase(connectionString);
|
||||||
|
|
||||||
logger.Trace("Preparing to run database migration");
|
logger.Trace("Preparing to run database migration");
|
||||||
|
|
||||||
|
@ -29,8 +28,6 @@ namespace NzbDrone.Core.Datastore
|
||||||
migrator = new Migrator.Migrator("sqlserverce", connectionString, Assembly.GetAssembly(typeof(MigrationsHelper)));
|
migrator = new Migrator.Migrator("sqlserverce", connectionString, Assembly.GetAssembly(typeof(MigrationsHelper)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
migrator.MigrateToLastVersion();
|
migrator.MigrateToLastVersion();
|
||||||
logger.Info("Database migration completed");
|
logger.Info("Database migration completed");
|
||||||
|
|
||||||
|
@ -43,10 +40,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EnsureDatabase(string constr)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetIndexName(string tableName, params string[] columns)
|
public static string GetIndexName(string tableName, params string[] columns)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -297,6 +297,7 @@
|
||||||
<Compile Include="Datastore\Migrations\SchemaInfo.cs" />
|
<Compile Include="Datastore\Migrations\SchemaInfo.cs" />
|
||||||
<Compile Include="Datastore\PetaPoco\EpisodeSeasonRelator.cs" />
|
<Compile Include="Datastore\PetaPoco\EpisodeSeasonRelator.cs" />
|
||||||
<Compile Include="Datastore\PetaPoco\PetaPoco.cs" />
|
<Compile Include="Datastore\PetaPoco\PetaPoco.cs" />
|
||||||
|
<Compile Include="Datastore\SqlCeProxy.cs" />
|
||||||
<Compile Include="Fluent.cs" />
|
<Compile Include="Fluent.cs" />
|
||||||
<Compile Include="Helpers\Converters\EpochDateTimeConverter.cs" />
|
<Compile Include="Helpers\Converters\EpochDateTimeConverter.cs" />
|
||||||
<Compile Include="Helpers\SabnzbdQueueTimeConverter.cs" />
|
<Compile Include="Helpers\SabnzbdQueueTimeConverter.cs" />
|
||||||
|
|
|
@ -6,15 +6,17 @@ namespace NzbDrone.SqlCe
|
||||||
{
|
{
|
||||||
public class SqlCeProxy
|
public class SqlCeProxy
|
||||||
{
|
{
|
||||||
public void EnsureDatabase(string constr)
|
public SqlCeConnection EnsureDatabase(string connectionString)
|
||||||
{
|
{
|
||||||
var connection = new SqlCeConnection(constr);
|
var connection = new SqlCeConnection(connectionString);
|
||||||
|
|
||||||
if (!File.Exists(connection.Database))
|
if (!File.Exists(connection.Database))
|
||||||
{
|
{
|
||||||
var engine = new SqlCeEngine(constr);
|
var engine = new SqlCeEngine(connectionString);
|
||||||
engine.CreateDatabase();
|
engine.CreateDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DbProviderFactory GetSqlCeProviderFactory()
|
public DbProviderFactory GetSqlCeProviderFactory()
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue