mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -04:00
added conditional compile for mono
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.IO;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using PetaPoco;
|
||||
@@ -14,6 +13,7 @@ namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
private readonly EnvironmentProvider _environmentProvider;
|
||||
private static readonly Logger logger = LogManager.GetLogger("ConnectionFactory");
|
||||
private static readonly DbProviderFactory _factory;
|
||||
|
||||
static ConnectionFactory()
|
||||
{
|
||||
@@ -24,8 +24,15 @@ namespace NzbDrone.Core.Datastore
|
||||
, "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");
|
||||
|
||||
var proxyType = Assembly.Load("NzbDrone.SqlCe").GetExportedTypes()[0];
|
||||
var instance = Activator.CreateInstance(proxyType);
|
||||
var factoryMethod = proxyType.GetMethod("GetSqlCeProviderFactory");
|
||||
_factory = (DbProviderFactory)factoryMethod.Invoke(instance, null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public ConnectionFactory(EnvironmentProvider environmentProvider)
|
||||
{
|
||||
_environmentProvider = environmentProvider;
|
||||
@@ -66,24 +73,22 @@ namespace NzbDrone.Core.Datastore
|
||||
static readonly HashSet<String> initilized = new HashSet<string>();
|
||||
|
||||
|
||||
|
||||
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
|
||||
{
|
||||
lock (initilized)
|
||||
{
|
||||
if (!initilized.Contains(connectionString))
|
||||
{
|
||||
VerifyDatabase(connectionString);
|
||||
//VerifyDatabase(connectionString);
|
||||
MigrationsHelper.Run(connectionString, true);
|
||||
initilized.Add(connectionString);
|
||||
}
|
||||
}
|
||||
|
||||
var factory = new DbProviderFactory
|
||||
{
|
||||
IsProfiled = profiled
|
||||
};
|
||||
|
||||
var db = new Database(connectionString, factory, Database.DBType.SqlServerCE)
|
||||
|
||||
var db = new Database(connectionString, _factory, Database.DBType.SqlServerCE)
|
||||
{
|
||||
KeepConnectionAlive = true,
|
||||
ForceDateTimesToUtc = false,
|
||||
@@ -92,7 +97,7 @@ namespace NzbDrone.Core.Datastore
|
||||
return db;
|
||||
}
|
||||
|
||||
private static void VerifyDatabase(string connectionString)
|
||||
/*private static void VerifyDatabase(string connectionString)
|
||||
{
|
||||
logger.Debug("Verifying database {0}", connectionString);
|
||||
|
||||
@@ -145,6 +150,6 @@ namespace NzbDrone.Core.Datastore
|
||||
//TODO: do db cleanup to avoid broken relationships.
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Data.SqlServerCe;
|
||||
using StackExchange.Profiling;
|
||||
using StackExchange.Profiling.Data;
|
||||
|
||||
namespace NzbDrone.Core.Datastore
|
||||
{
|
||||
class DbProviderFactory : System.Data.Common.DbProviderFactory
|
||||
{
|
||||
public Boolean IsProfiled { get; set; }
|
||||
|
||||
public override DbConnection CreateConnection()
|
||||
{
|
||||
var sqliteConnection = new SqlCeConnection();
|
||||
DbConnection connection = sqliteConnection;
|
||||
|
||||
if (IsProfiled)
|
||||
{
|
||||
connection = new ProfiledDbConnection(sqliteConnection, MiniProfiler.Current);
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using System.Data.SqlServerCe;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using Migrator.Framework;
|
||||
using NzbDrone.Common;
|
||||
@@ -35,8 +35,7 @@ namespace NzbDrone.Core.Datastore.Migrations
|
||||
|
||||
protected EloqueraDb GetObjectDb()
|
||||
{
|
||||
|
||||
var sqlCeConnection = new SqlCeConnection(Database.ConnectionString);
|
||||
var sqlCeConnection = new SqlConnection(Database.ConnectionString);
|
||||
|
||||
var eqPath = sqlCeConnection.Database.Replace(".sdf", ".eq");
|
||||
return new EloqueraDbFactory(new EnvironmentProvider()).Create(eqPath);
|
||||
|
||||
@@ -9,7 +9,6 @@ using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Providers.DecisionEngine;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
using StackExchange.Profiling;
|
||||
|
||||
namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user