mono progress - able to start app

This commit is contained in:
Luke Pulverenti
2013-09-26 17:20:26 -04:00
parent 2d0cc66e6b
commit 2d8152f36a
20 changed files with 273 additions and 160 deletions

View File

@@ -55,8 +55,6 @@ namespace MediaBrowser.ServerApplication
public void OnUnhandledException(Exception ex)
{
_logger.ErrorException("UnhandledException", ex);
MessageBox.Show("Unhandled exception: " + ex.Message);
}

View File

@@ -53,7 +53,6 @@ using MediaBrowser.ServerApplication.Native;
using MediaBrowser.WebDashboard.Api;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Net.Http;
@@ -157,7 +156,7 @@ namespace MediaBrowser.ServerApplication
private ISessionManager SessionManager { get; set; }
private ILiveTvManager LiveTvManager { get; set; }
private ILocalizationManager LocalizationManager { get; set; }
/// <summary>
@@ -329,13 +328,9 @@ namespace MediaBrowser.ServerApplication
private async Task<IUserRepository> GetUserRepository()
{
var dbFile = Path.Combine(ApplicationPaths.DataPath, "users.db");
var repo = new SqliteUserRepository(JsonSerializer, LogManager, ApplicationPaths);
var connection = await ConnectToDb(dbFile).ConfigureAwait(false);
var repo = new SqliteUserRepository(connection, JsonSerializer, LogManager);
repo.Initialize();
await repo.Initialize().ConfigureAwait(false);
return repo;
}
@@ -346,13 +341,9 @@ namespace MediaBrowser.ServerApplication
/// <returns>Task.</returns>
private async Task ConfigureNotificationsRepository()
{
var dbFile = Path.Combine(ApplicationPaths.DataPath, "notifications.db");
var repo = new SqliteNotificationsRepository(LogManager, ApplicationPaths);
var connection = await ConnectToDb(dbFile).ConfigureAwait(false);
var repo = new SqliteNotificationsRepository(connection, LogManager);
repo.Initialize();
await repo.Initialize().ConfigureAwait(false);
NotificationsRepository = repo;
@@ -388,22 +379,6 @@ namespace MediaBrowser.ServerApplication
return UserDataRepository.Initialize();
}
/// <summary>
/// Connects to db.
/// </summary>
/// <param name="dbPath">The db path.</param>
/// <returns>Task{IDbConnection}.</returns>
/// <exception cref="System.ArgumentNullException">dbPath</exception>
private static Task<IDbConnection> ConnectToDb(string dbPath)
{
if (string.IsNullOrEmpty(dbPath))
{
throw new ArgumentNullException("dbPath");
}
return Sqlite.OpenDatabase(dbPath);
}
/// <summary>
/// Dirty hacks
/// </summary>
@@ -550,7 +525,7 @@ namespace MediaBrowser.ServerApplication
.Select(LoadAssembly)
.Where(a => a != null)
.ToList();
// Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
// This will prevent the .dll file from getting locked, and allow us to replace it when needed

View File

@@ -314,6 +314,8 @@ namespace MediaBrowser.ServerApplication
{
var exception = (Exception)e.ExceptionObject;
_logger.ErrorException("UnhandledException", ex);
if (_backgroundService == null)
{
_app.OnUnhandledException(exception);

View File

@@ -167,14 +167,6 @@
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.88.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.x86.1.0.88.0\lib\net45\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.88.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Data.SQLite.x86.1.0.88.0\lib\net45\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
@@ -212,7 +204,6 @@
<Compile Include="BackgroundServiceInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Native\Sqlite.cs" />
<Compile Include="Splash\SplashWindow.xaml.cs">
<DependentUpon>SplashWindow.xaml</DependentUpon>
</Compile>

View File

@@ -1,36 +0,0 @@
using System.Data;
using System.Data.SQLite;
using System.Threading.Tasks;
namespace MediaBrowser.ServerApplication.Native
{
/// <summary>
/// Class Sqlite
/// </summary>
public static class Sqlite
{
/// <summary>
/// Connects to db.
/// </summary>
/// <param name="dbPath">The db path.</param>
/// <returns>Task{IDbConnection}.</returns>
/// <exception cref="System.ArgumentNullException">dbPath</exception>
public static async Task<IDbConnection> OpenDatabase(string dbPath)
{
var connectionstr = new SQLiteConnectionStringBuilder
{
PageSize = 4096,
CacheSize = 4096,
SyncMode = SynchronizationModes.Normal,
DataSource = dbPath,
JournalMode = SQLiteJournalModeEnum.Wal
};
var connection = new SQLiteConnection(connectionstr.ConnectionString);
await connection.OpenAsync().ConfigureAwait(false);
return connection;
}
}
}

View File

@@ -10,5 +10,4 @@
<package id="ServiceStack.Redis" version="3.9.44" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" />
<package id="SimpleInjector" version="2.3.5" targetFramework="net45" />
<package id="System.Data.SQLite.x86" version="1.0.88.0" targetFramework="net45" />
</packages>