mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-05 21:37:10 -04:00
mono progress - able to start app
This commit is contained in:
parent
2d0cc66e6b
commit
2d8152f36a
@ -980,7 +980,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
var initialCount = _children.Count;
|
var initialCount = _children.Count;
|
||||||
var list = new List<BaseItem>(initialCount);
|
var list = new List<BaseItem>(initialCount);
|
||||||
|
|
||||||
AddChildrenToList(user, includeLinkedChildren, list, false);
|
AddChildrenToList(user, includeLinkedChildren, list, false, null);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -992,7 +992,9 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// <param name="includeLinkedChildren">if set to <c>true</c> [include linked children].</param>
|
/// <param name="includeLinkedChildren">if set to <c>true</c> [include linked children].</param>
|
||||||
/// <param name="list">The list.</param>
|
/// <param name="list">The list.</param>
|
||||||
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
|
/// <param name="recursive">if set to <c>true</c> [recursive].</param>
|
||||||
private bool AddChildrenToList(User user, bool includeLinkedChildren, List<BaseItem> list, bool recursive)
|
/// <param name="filter">The filter.</param>
|
||||||
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||||
|
private bool AddChildrenToList(User user, bool includeLinkedChildren, List<BaseItem> list, bool recursive, Func<BaseItem,bool> filter)
|
||||||
{
|
{
|
||||||
var hasLinkedChildren = false;
|
var hasLinkedChildren = false;
|
||||||
|
|
||||||
@ -1000,7 +1002,10 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
if (child.IsVisible(user))
|
if (child.IsVisible(user))
|
||||||
{
|
{
|
||||||
list.Add(child);
|
if (filter == null || filter(child))
|
||||||
|
{
|
||||||
|
list.Add(child);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recursive)
|
if (recursive)
|
||||||
@ -1009,7 +1014,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
if (folder != null)
|
if (folder != null)
|
||||||
{
|
{
|
||||||
if (folder.AddChildrenToList(user, includeLinkedChildren, list, true))
|
if (folder.AddChildrenToList(user, includeLinkedChildren, list, true, filter))
|
||||||
{
|
{
|
||||||
hasLinkedChildren = true;
|
hasLinkedChildren = true;
|
||||||
}
|
}
|
||||||
@ -1021,6 +1026,11 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
foreach (var child in GetLinkedChildren())
|
foreach (var child in GetLinkedChildren())
|
||||||
{
|
{
|
||||||
|
if (filter != null && !filter(child))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
hasLinkedChildren = true;
|
hasLinkedChildren = true;
|
||||||
|
|
||||||
if (child.IsVisible(user))
|
if (child.IsVisible(user))
|
||||||
@ -1042,6 +1052,11 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException"></exception>
|
/// <exception cref="System.ArgumentNullException"></exception>
|
||||||
public IEnumerable<BaseItem> GetRecursiveChildren(User user, bool includeLinkedChildren = true)
|
public IEnumerable<BaseItem> GetRecursiveChildren(User user, bool includeLinkedChildren = true)
|
||||||
|
{
|
||||||
|
return GetRecursiveChildren(user, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<BaseItem> GetRecursiveChildren(User user, Func<BaseItem,bool> filter, bool includeLinkedChildren = true)
|
||||||
{
|
{
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
@ -1051,10 +1066,10 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
var initialCount = _lastRecursiveCount == 0 ? _children.Count : _lastRecursiveCount;
|
var initialCount = _lastRecursiveCount == 0 ? _children.Count : _lastRecursiveCount;
|
||||||
var list = new List<BaseItem>(initialCount);
|
var list = new List<BaseItem>(initialCount);
|
||||||
|
|
||||||
var hasLinkedChildren = AddChildrenToList(user, includeLinkedChildren, list, true);
|
var hasLinkedChildren = AddChildrenToList(user, includeLinkedChildren, list, true, null);
|
||||||
|
|
||||||
_lastRecursiveCount = list.Count;
|
_lastRecursiveCount = list.Count;
|
||||||
|
|
||||||
if (includeLinkedChildren && hasLinkedChildren)
|
if (includeLinkedChildren && hasLinkedChildren)
|
||||||
{
|
{
|
||||||
list = list.Distinct().ToList();
|
list = list.Distinct().ToList();
|
||||||
@ -1062,7 +1077,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the linked children.
|
/// Gets the linked children.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -25,6 +25,12 @@ namespace MediaBrowser.Controller.Notifications
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
event EventHandler<NotificationReadEventArgs> NotificationsMarkedRead;
|
event EventHandler<NotificationReadEventArgs> NotificationsMarkedRead;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens the connection to the repository
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
Task Initialize();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the notifications.
|
/// Gets the notifications.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Persistence
|
|||||||
/// Opens the connection to the repository
|
/// Opens the connection to the repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
void Initialize();
|
Task Initialize();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the user.
|
/// Deletes the user.
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
<Properties>
|
<Properties>
|
||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|x86" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="d:\Development\MediaBrowser\MediaBrowser.Server.Mono\Native\Sqlite.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="d:\Development\MediaBrowser\MediaBrowser.ServerApplication\ApplicationHost.cs">
|
||||||
<Files>
|
<Files>
|
||||||
|
<File FileName="d:\Development\MediaBrowser\MediaBrowser.ServerApplication\ApplicationHost.cs" Line="442" Column="10" />
|
||||||
|
<File FileName="MediaBrowser.Server.Mono\Native\ServerAuthorization.cs" Line="1" Column="1" />
|
||||||
|
<File FileName="MediaBrowser.Server.Mono\Native\Autorun.cs" Line="1" Column="1" />
|
||||||
|
<File FileName="MediaBrowser.Server.Mono\Native\Assemblies.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\Program.cs" Line="1" Column="1" />
|
<File FileName="MediaBrowser.Server.Mono\Program.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\MainWindow.cs" Line="8" Column="12" />
|
|
||||||
<File FileName="MediaBrowser.Server.Mono\Native\Autorun.cs" Line="17" Column="4" />
|
|
||||||
<File FileName="MediaBrowser.Server.Mono\Native\ServerAuthorization.cs" Line="23" Column="1" />
|
|
||||||
<File FileName="MediaBrowser.Server.Mono\FFMpeg\FFMpegDownloader.cs" Line="7" Column="14" />
|
|
||||||
<File FileName="MediaBrowser.ServerApplication\ApplicationHost.cs" Line="548" Column="61" />
|
|
||||||
<File FileName="MediaBrowser.Server.Mono\Native\NativeApp.cs" Line="22" Column="13" />
|
|
||||||
<File FileName="d:\Development\MediaBrowser\MediaBrowser.Server.Mono\Native\Sqlite.cs" Line="21" Column="14" />
|
|
||||||
</Files>
|
</Files>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
@ -1074,7 +1074,7 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||||||
double totalPercentPlayed = 0;
|
double totalPercentPlayed = 0;
|
||||||
|
|
||||||
// Loop through each recursive child
|
// Loop through each recursive child
|
||||||
foreach (var child in folder.GetRecursiveChildren(user, true).Where(i => !i.IsFolder).ToList())
|
foreach (var child in folder.GetRecursiveChildren(user, i => !i.IsFolder))
|
||||||
{
|
{
|
||||||
var userdata = _userDataRepository.GetUserData(user.Id, child.GetUserDataKey());
|
var userdata = _userDataRepository.GetUserData(user.Id, child.GetUserDataKey());
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using MediaBrowser.Controller.Notifications;
|
using System.IO;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Notifications;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Notifications;
|
using MediaBrowser.Model.Notifications;
|
||||||
using System;
|
using System;
|
||||||
@ -12,15 +14,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
public class SqliteNotificationsRepository : INotificationsRepository
|
public class SqliteNotificationsRepository : INotificationsRepository
|
||||||
{
|
{
|
||||||
private readonly IDbConnection _connection;
|
private IDbConnection _connection;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private readonly IServerApplicationPaths _appPaths;
|
||||||
|
|
||||||
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
public SqliteNotificationsRepository(IDbConnection connection, ILogManager logManager)
|
public SqliteNotificationsRepository(ILogManager logManager, IServerApplicationPaths appPaths)
|
||||||
{
|
{
|
||||||
_connection = connection;
|
_appPaths = appPaths;
|
||||||
|
|
||||||
_logger = logManager.GetLogger(GetType().Name);
|
_logger = logManager.GetLogger(GetType().Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,8 +33,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
private IDbCommand _replaceNotificationCommand;
|
private IDbCommand _replaceNotificationCommand;
|
||||||
private IDbCommand _markReadCommand;
|
private IDbCommand _markReadCommand;
|
||||||
|
|
||||||
public void Initialize()
|
public async Task Initialize()
|
||||||
{
|
{
|
||||||
|
var dbFile = Path.Combine(_appPaths.DataPath, "notifications.db");
|
||||||
|
|
||||||
|
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
"create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT, Url TEXT, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT, PRIMARY KEY (Id, UserId))",
|
"create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT, Url TEXT, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT, PRIMARY KEY (Id, UserId))",
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -20,6 +22,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);
|
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
private IDbConnection _connection;
|
private IDbConnection _connection;
|
||||||
|
private readonly IServerApplicationPaths _appPaths;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the repository
|
/// Gets the name of the repository
|
||||||
@ -42,19 +45,19 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SqliteUserRepository" /> class.
|
/// Initializes a new instance of the <see cref="SqliteUserRepository" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="connection">The connection.</param>
|
|
||||||
/// <param name="jsonSerializer">The json serializer.</param>
|
/// <param name="jsonSerializer">The json serializer.</param>
|
||||||
/// <param name="logManager">The log manager.</param>
|
/// <param name="logManager">The log manager.</param>
|
||||||
|
/// <param name="appPaths">The app paths.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">appPaths</exception>
|
/// <exception cref="System.ArgumentNullException">appPaths</exception>
|
||||||
public SqliteUserRepository(IDbConnection connection, IJsonSerializer jsonSerializer, ILogManager logManager)
|
public SqliteUserRepository(IJsonSerializer jsonSerializer, ILogManager logManager, IServerApplicationPaths appPaths)
|
||||||
{
|
{
|
||||||
if (jsonSerializer == null)
|
if (jsonSerializer == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("jsonSerializer");
|
throw new ArgumentNullException("jsonSerializer");
|
||||||
}
|
}
|
||||||
|
|
||||||
_connection = connection;
|
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
|
_appPaths = appPaths;
|
||||||
|
|
||||||
_logger = logManager.GetLogger(GetType().Name);
|
_logger = logManager.GetLogger(GetType().Name);
|
||||||
}
|
}
|
||||||
@ -63,8 +66,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
/// Opens the connection to the database
|
/// Opens the connection to the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public void Initialize()
|
public async Task Initialize()
|
||||||
{
|
{
|
||||||
|
var dbFile = Path.Combine(_appPaths.DataPath, "users.db");
|
||||||
|
|
||||||
|
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
"create table if not exists users (guid GUID primary key, data BLOB)",
|
"create table if not exists users (guid GUID primary key, data BLOB)",
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
<RootNamespace>MediaBrowser.Server.Mono</RootNamespace>
|
<RootNamespace>MediaBrowser.Server.Mono</RootNamespace>
|
||||||
<AssemblyName>MediaBrowser.Server.Mono</AssemblyName>
|
<AssemblyName>MediaBrowser.Server.Mono</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||||
|
<StartupObject>MediaBrowser.Server.Mono.MainClass</StartupObject>
|
||||||
|
<ApplicationIcon>..\MediaBrowser.ServerApplication\Resources\Images\Icon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@ -43,6 +45,12 @@
|
|||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="ServiceStack.Common">
|
||||||
|
<HintPath>..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ServiceStack.Interfaces">
|
||||||
|
<HintPath>..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="gtk-gui\gui.stetic">
|
<EmbeddedResource Include="gtk-gui\gui.stetic">
|
||||||
@ -50,6 +58,9 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="..\SharedVersion.cs">
|
||||||
|
<Link>Properties\SharedVersion.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="gtk-gui\generated.cs" />
|
<Compile Include="gtk-gui\generated.cs" />
|
||||||
<Compile Include="MainWindow.cs" />
|
<Compile Include="MainWindow.cs" />
|
||||||
<Compile Include="gtk-gui\MainWindow.cs" />
|
<Compile Include="gtk-gui\MainWindow.cs" />
|
||||||
@ -72,7 +83,6 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Native\HttpMessageHandlerFactory.cs" />
|
<Compile Include="Native\HttpMessageHandlerFactory.cs" />
|
||||||
<Compile Include="Native\Assemblies.cs" />
|
<Compile Include="Native\Assemblies.cs" />
|
||||||
<Compile Include="Native\Sqlite.cs" />
|
|
||||||
<Compile Include="Native\NativeApp.cs" />
|
<Compile Include="Native\NativeApp.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
@ -112,8 +122,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="EntryPoints\" />
|
<Folder Include="EntryPoints\" />
|
||||||
<Folder Include="Implementations\" />
|
|
||||||
<Folder Include="Native\" />
|
<Folder Include="Native\" />
|
||||||
<Folder Include="FFMpeg\" />
|
<Folder Include="FFMpeg\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,4 +1,5 @@
|
|||||||
|
using MediaBrowser.Server.Mono;
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication.Native
|
namespace MediaBrowser.ServerApplication.Native
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -11,7 +12,7 @@ namespace MediaBrowser.ServerApplication.Native
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Shutdown()
|
public static void Shutdown()
|
||||||
{
|
{
|
||||||
|
MainClass.Shutdown ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -19,7 +20,7 @@ namespace MediaBrowser.ServerApplication.Native
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Restart()
|
public static void Restart()
|
||||||
{
|
{
|
||||||
|
MainClass.Restart ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +1,188 @@
|
|||||||
|
using MediaBrowser.Common.Constants;
|
||||||
|
using MediaBrowser.Common.Implementations.Logging;
|
||||||
|
using MediaBrowser.Common.Implementations.Updates;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
using MediaBrowser.Server.Implementations;
|
||||||
|
using MediaBrowser.ServerApplication;
|
||||||
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows;
|
||||||
using Gtk;
|
using Gtk;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Mono
|
namespace MediaBrowser.Server.Mono
|
||||||
{
|
{
|
||||||
class MainClass
|
public class MainClass
|
||||||
{
|
{
|
||||||
|
private static ApplicationHost _appHost;
|
||||||
|
|
||||||
|
private static Mutex _singleInstanceMutex;
|
||||||
|
|
||||||
|
private static ILogger _logger;
|
||||||
|
|
||||||
public static void Main (string[] args)
|
public static void Main (string[] args)
|
||||||
{
|
{
|
||||||
Application.Init ();
|
Application.Init ();
|
||||||
|
|
||||||
|
var appPaths = CreateApplicationPaths();
|
||||||
|
|
||||||
|
var logManager = new NlogManager(appPaths.LogDirectoryPath, "server");
|
||||||
|
logManager.ReloadLogger(LogSeverity.Info);
|
||||||
|
|
||||||
|
var logger = _logger = logManager.GetLogger("Main");
|
||||||
|
|
||||||
|
BeginLog(logger);
|
||||||
|
|
||||||
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||||
|
|
||||||
|
bool createdNew;
|
||||||
|
|
||||||
|
var runningPath = Process.GetCurrentProcess().MainModule.FileName.Replace(Path.DirectorySeparatorChar.ToString(), string.Empty);
|
||||||
|
|
||||||
|
_singleInstanceMutex = new Mutex(true, @"Local\" + runningPath, out createdNew);
|
||||||
|
|
||||||
|
if (!createdNew)
|
||||||
|
{
|
||||||
|
_singleInstanceMutex = null;
|
||||||
|
logger.Info("Shutting down because another instance of Media Browser Server is already running.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PerformUpdateIfNeeded(appPaths, logger))
|
||||||
|
{
|
||||||
|
logger.Info("Exiting to perform application update.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RunApplication(appPaths, logManager);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
logger.Info("Shutting down");
|
||||||
|
|
||||||
|
ReleaseMutex(logger);
|
||||||
|
|
||||||
|
_appHost.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ServerApplicationPaths CreateApplicationPaths()
|
||||||
|
{
|
||||||
|
return new ServerApplicationPaths("D:\\MonoTest");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager)
|
||||||
|
{
|
||||||
|
// TODO: Show splash here
|
||||||
|
|
||||||
|
SystemEvents.SessionEnding += SystemEvents_SessionEnding;
|
||||||
|
|
||||||
|
_appHost = new ApplicationHost(appPaths, logManager);
|
||||||
|
|
||||||
|
var task = _appHost.Init();
|
||||||
|
Task.WaitAll (task);
|
||||||
|
|
||||||
|
task = _appHost.RunStartupTasks();
|
||||||
|
Task.WaitAll (task);
|
||||||
|
|
||||||
|
// TODO: Hide splash here
|
||||||
MainWindow win = new MainWindow ();
|
MainWindow win = new MainWindow ();
|
||||||
|
|
||||||
win.Show ();
|
win.Show ();
|
||||||
|
|
||||||
Application.Run ();
|
Application.Run ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the SessionEnding event of the SystemEvents control.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the event.</param>
|
||||||
|
/// <param name="e">The <see cref="SessionEndingEventArgs"/> instance containing the event data.</param>
|
||||||
|
static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Reason == SessionEndReasons.SystemShutdown)
|
||||||
|
{
|
||||||
|
Shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Begins the log.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="logger">The logger.</param>
|
||||||
|
private static void BeginLog(ILogger logger)
|
||||||
|
{
|
||||||
|
logger.Info("Media Browser Server started");
|
||||||
|
logger.Info("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs()));
|
||||||
|
|
||||||
|
logger.Info("Server: {0}", Environment.MachineName);
|
||||||
|
logger.Info("Operating system: {0}", Environment.OSVersion.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the UnhandledException event of the CurrentDomain control.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the event.</param>
|
||||||
|
/// <param name="e">The <see cref="UnhandledExceptionEventArgs"/> instance containing the event data.</param>
|
||||||
|
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
var exception = (Exception)e.ExceptionObject;
|
||||||
|
|
||||||
|
_logger.ErrorException("UnhandledException", exception);
|
||||||
|
|
||||||
|
if (!Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
Environment.Exit(System.Runtime.InteropServices.Marshal.GetHRForException(exception));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Releases the mutex.
|
||||||
|
/// </summary>
|
||||||
|
internal static void ReleaseMutex(ILogger logger)
|
||||||
|
{
|
||||||
|
if (_singleInstanceMutex == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Debug("Releasing mutex");
|
||||||
|
|
||||||
|
_singleInstanceMutex.ReleaseMutex();
|
||||||
|
_singleInstanceMutex.Close();
|
||||||
|
_singleInstanceMutex.Dispose();
|
||||||
|
_singleInstanceMutex = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs the update if needed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="appPaths">The app paths.</param>
|
||||||
|
/// <param name="logger">The logger.</param>
|
||||||
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||||
|
private static bool PerformUpdateIfNeeded(ServerApplicationPaths appPaths, ILogger logger)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Shutdown()
|
||||||
|
{
|
||||||
|
Application.Quit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Restart()
|
||||||
|
{
|
||||||
|
// Second instance will start first, so release the mutex and dispose the http server ahead of time
|
||||||
|
ReleaseMutex (_logger);
|
||||||
|
|
||||||
|
_appHost.Dispose();
|
||||||
|
|
||||||
|
Application.Quit ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,4 @@ using System.Runtime.CompilerServices;
|
|||||||
[assembly: AssemblyProduct ("")]
|
[assembly: AssemblyProduct ("")]
|
||||||
[assembly: AssemblyCopyright ("Luke")]
|
[assembly: AssemblyCopyright ("Luke")]
|
||||||
[assembly: AssemblyTrademark ("")]
|
[assembly: AssemblyTrademark ("")]
|
||||||
[assembly: AssemblyCulture ("")]
|
[assembly: AssemblyCulture ("")]
|
||||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
|
||||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
|
||||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
|
||||||
[assembly: AssemblyVersion ("1.0.*")]
|
|
||||||
// The following attributes are used to specify the signing key for the assembly,
|
|
||||||
// if desired. See the Mono documentation for more information about signing.
|
|
||||||
//[assembly: AssemblyDelaySign(false)]
|
|
||||||
//[assembly: AssemblyKeyFile("")]
|
|
||||||
|
|
14
MediaBrowser.Server.Mono/app.config
Normal file
14
MediaBrowser.Server.Mono/app.config
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
|
||||||
|
</configSections>
|
||||||
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<targets async="true"></targets>
|
||||||
|
</nlog>
|
||||||
|
<appSettings>
|
||||||
|
<add key="DebugProgramDataPath" value="..\..\..\..\ProgramData-Server" />
|
||||||
|
<add key="ReleaseProgramDataPath" value="%ApplicationData%" />
|
||||||
|
<add key="ProgramDataFolderName" value="MediaBrowser-Server" />
|
||||||
|
</appSettings>
|
||||||
|
</configuration>
|
@ -55,8 +55,6 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
public void OnUnhandledException(Exception ex)
|
public void OnUnhandledException(Exception ex)
|
||||||
{
|
{
|
||||||
_logger.ErrorException("UnhandledException", ex);
|
|
||||||
|
|
||||||
MessageBox.Show("Unhandled exception: " + ex.Message);
|
MessageBox.Show("Unhandled exception: " + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ using MediaBrowser.ServerApplication.Native;
|
|||||||
using MediaBrowser.WebDashboard.Api;
|
using MediaBrowser.WebDashboard.Api;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@ -157,7 +156,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
private ISessionManager SessionManager { get; set; }
|
private ISessionManager SessionManager { get; set; }
|
||||||
|
|
||||||
private ILiveTvManager LiveTvManager { get; set; }
|
private ILiveTvManager LiveTvManager { get; set; }
|
||||||
|
|
||||||
private ILocalizationManager LocalizationManager { get; set; }
|
private ILocalizationManager LocalizationManager { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -329,13 +328,9 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
private async Task<IUserRepository> GetUserRepository()
|
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);
|
await repo.Initialize().ConfigureAwait(false);
|
||||||
|
|
||||||
var repo = new SqliteUserRepository(connection, JsonSerializer, LogManager);
|
|
||||||
|
|
||||||
repo.Initialize();
|
|
||||||
|
|
||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
@ -346,13 +341,9 @@ namespace MediaBrowser.ServerApplication
|
|||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
private async Task ConfigureNotificationsRepository()
|
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);
|
await repo.Initialize().ConfigureAwait(false);
|
||||||
|
|
||||||
var repo = new SqliteNotificationsRepository(connection, LogManager);
|
|
||||||
|
|
||||||
repo.Initialize();
|
|
||||||
|
|
||||||
NotificationsRepository = repo;
|
NotificationsRepository = repo;
|
||||||
|
|
||||||
@ -388,22 +379,6 @@ namespace MediaBrowser.ServerApplication
|
|||||||
return UserDataRepository.Initialize();
|
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>
|
/// <summary>
|
||||||
/// Dirty hacks
|
/// Dirty hacks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -550,7 +525,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
.Select(LoadAssembly)
|
.Select(LoadAssembly)
|
||||||
.Where(a => a != null)
|
.Where(a => a != null)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
|
// 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
|
// This will prevent the .dll file from getting locked, and allow us to replace it when needed
|
||||||
|
|
||||||
|
@ -314,6 +314,8 @@ namespace MediaBrowser.ServerApplication
|
|||||||
{
|
{
|
||||||
var exception = (Exception)e.ExceptionObject;
|
var exception = (Exception)e.ExceptionObject;
|
||||||
|
|
||||||
|
_logger.ErrorException("UnhandledException", ex);
|
||||||
|
|
||||||
if (_backgroundService == null)
|
if (_backgroundService == null)
|
||||||
{
|
{
|
||||||
_app.OnUnhandledException(exception);
|
_app.OnUnhandledException(exception);
|
||||||
|
@ -167,14 +167,6 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration.Install" />
|
<Reference Include="System.Configuration.Install" />
|
||||||
<Reference Include="System.Data" />
|
<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.Drawing" />
|
||||||
<Reference Include="System.Net" />
|
<Reference Include="System.Net" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
@ -212,7 +204,6 @@
|
|||||||
<Compile Include="BackgroundServiceInstaller.cs">
|
<Compile Include="BackgroundServiceInstaller.cs">
|
||||||
<SubType>Component</SubType>
|
<SubType>Component</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Native\Sqlite.cs" />
|
|
||||||
<Compile Include="Splash\SplashWindow.xaml.cs">
|
<Compile Include="Splash\SplashWindow.xaml.cs">
|
||||||
<DependentUpon>SplashWindow.xaml</DependentUpon>
|
<DependentUpon>SplashWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,5 +10,4 @@
|
|||||||
<package id="ServiceStack.Redis" version="3.9.44" targetFramework="net45" />
|
<package id="ServiceStack.Redis" version="3.9.44" targetFramework="net45" />
|
||||||
<package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" />
|
<package id="ServiceStack.Text" version="3.9.62" targetFramework="net45" />
|
||||||
<package id="SimpleInjector" version="2.3.5" 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>
|
</packages>
|
Loading…
Reference in New Issue
Block a user