From f98b611debd757dcf2b2862fa04f28d514a7fa3d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 3 Jul 2013 20:11:11 -0400 Subject: [PATCH] moved dependencies for mono --- .../EntryPoints/LibraryChangedNotifier.cs | 5 +- .../EntryPoints/LoadRegistrations.cs | 2 +- .../EntryPoints/RefreshUsersMetadata.cs | 2 +- .../EntryPoints/WebSocketEvents.cs | 2 +- ...MediaBrowser.Server.Implementations.csproj | 10 ++-- .../Persistence/SqliteChapterRepository.cs | 59 +++++++++---------- .../Persistence/SqliteExtensions.cs | 31 +++++++++- .../packages.config | 1 - .../MediaBrowser.ServerApplication.csproj | 4 -- 9 files changed, 67 insertions(+), 49 deletions(-) rename {MediaBrowser.ServerApplication => MediaBrowser.Server.Implementations}/EntryPoints/LibraryChangedNotifier.cs (99%) rename {MediaBrowser.ServerApplication => MediaBrowser.Server.Implementations}/EntryPoints/LoadRegistrations.cs (96%) rename {MediaBrowser.ServerApplication => MediaBrowser.Server.Implementations}/EntryPoints/RefreshUsersMetadata.cs (95%) rename {MediaBrowser.ServerApplication => MediaBrowser.Server.Implementations}/EntryPoints/WebSocketEvents.cs (99%) diff --git a/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs similarity index 99% rename from MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs rename to MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs index 43224c6a9..71d014468 100644 --- a/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; -namespace MediaBrowser.ServerApplication.EntryPoints +namespace MediaBrowser.Server.Implementations.EntryPoints { public class LibraryChangedNotifier : IServerEntryPoint { @@ -48,12 +48,13 @@ namespace MediaBrowser.ServerApplication.EntryPoints /// private const int LibraryUpdateDuration = 60000; - public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IServerManager serverManager, IUserManager userManager) + public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IServerManager serverManager, IUserManager userManager, ILogger logger) { _libraryManager = libraryManager; _sessionManager = sessionManager; _serverManager = serverManager; _userManager = userManager; + _logger = logger; } public void Run() diff --git a/MediaBrowser.ServerApplication/EntryPoints/LoadRegistrations.cs b/MediaBrowser.Server.Implementations/EntryPoints/LoadRegistrations.cs similarity index 96% rename from MediaBrowser.ServerApplication/EntryPoints/LoadRegistrations.cs rename to MediaBrowser.Server.Implementations/EntryPoints/LoadRegistrations.cs index d6cd1ae82..c2c4056f5 100644 --- a/MediaBrowser.ServerApplication/EntryPoints/LoadRegistrations.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/LoadRegistrations.cs @@ -3,7 +3,7 @@ using MediaBrowser.Controller.Plugins; using MediaBrowser.Model.Logging; using System; -namespace MediaBrowser.ServerApplication.EntryPoints +namespace MediaBrowser.Server.Implementations.EntryPoints { /// /// Class LoadRegistrations diff --git a/MediaBrowser.ServerApplication/EntryPoints/RefreshUsersMetadata.cs b/MediaBrowser.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs similarity index 95% rename from MediaBrowser.ServerApplication/EntryPoints/RefreshUsersMetadata.cs rename to MediaBrowser.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs index 735a1f655..a0b7ff515 100644 --- a/MediaBrowser.ServerApplication/EntryPoints/RefreshUsersMetadata.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/RefreshUsersMetadata.cs @@ -2,7 +2,7 @@ using MediaBrowser.Controller.Plugins; using System.Threading; -namespace MediaBrowser.ServerApplication.EntryPoints +namespace MediaBrowser.Server.Implementations.EntryPoints { /// /// Class RefreshUsersMetadata diff --git a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs b/MediaBrowser.Server.Implementations/EntryPoints/WebSocketEvents.cs similarity index 99% rename from MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs rename to MediaBrowser.Server.Implementations/EntryPoints/WebSocketEvents.cs index 90605b2ee..b4bffc077 100644 --- a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/WebSocketEvents.cs @@ -13,7 +13,7 @@ using MediaBrowser.Model.Tasks; using MediaBrowser.Model.Updates; using System; -namespace MediaBrowser.ServerApplication.EntryPoints +namespace MediaBrowser.Server.Implementations.EntryPoints { /// /// Class WebSocketEvents diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index b2e60a401..34dc8ff52 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -64,12 +64,6 @@ False ..\packages\ServiceStack.Common.3.9.54\lib\net35\ServiceStack.Interfaces.dll - - ..\packages\ServiceStack.OrmLite.Sqlite32.3.9.54\lib\net40\ServiceStack.OrmLite.dll - - - ..\packages\ServiceStack.OrmLite.Sqlite32.3.9.54\lib\net40\ServiceStack.OrmLite.SqliteNET.dll - False ..\packages\ServiceStack.OrmLite.SqlServer.3.9.43\lib\ServiceStack.OrmLite.SqlServer.dll @@ -115,6 +109,10 @@ + + + + diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteChapterRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteChapterRepository.cs index cac612fc8..c472241e3 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteChapterRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteChapterRepository.cs @@ -1,11 +1,9 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; -using MediaBrowser.Model.Serialization; using System; using System.Collections.Generic; using System.Data; -using System.Data.SQLite; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -14,7 +12,7 @@ namespace MediaBrowser.Server.Implementations.Persistence { public class SqliteChapterRepository { - private SQLiteConnection _connection; + private IDbConnection _connection; private readonly ILogger _logger; @@ -23,8 +21,8 @@ namespace MediaBrowser.Server.Implementations.Persistence /// private readonly IApplicationPaths _appPaths; - private SQLiteCommand _deleteChaptersCommand; - private SQLiteCommand _saveChapterCommand; + private IDbCommand _deleteChaptersCommand; + private IDbCommand _saveChapterCommand; /// /// Initializes a new instance of the class. @@ -80,23 +78,18 @@ namespace MediaBrowser.Server.Implementations.Persistence /// private void PrepareStatements() { - _deleteChaptersCommand = new SQLiteCommand - { - CommandText = "delete from chapters where ItemId=@ItemId" - }; + _deleteChaptersCommand = _connection.CreateCommand(); + _deleteChaptersCommand.CommandText = "delete from chapters where ItemId=@ItemId"; + _deleteChaptersCommand.Parameters.Add(_deleteChaptersCommand, "@ItemId"); - _deleteChaptersCommand.Parameters.Add(new SQLiteParameter("@ItemId")); + _saveChapterCommand = _connection.CreateCommand(); + _saveChapterCommand.CommandText = "replace into chapters (ItemId, ChapterIndex, StartPositionTicks, Name, ImagePath) values (@ItemId, @ChapterIndex, @StartPositionTicks, @Name, @ImagePath)"; - _saveChapterCommand = new SQLiteCommand - { - CommandText = "replace into chapters (ItemId, ChapterIndex, StartPositionTicks, Name, ImagePath) values (@ItemId, @ChapterIndex, @StartPositionTicks, @Name, @ImagePath)" - }; - - _saveChapterCommand.Parameters.Add(new SQLiteParameter("@ItemId")); - _saveChapterCommand.Parameters.Add(new SQLiteParameter("@ChapterIndex")); - _saveChapterCommand.Parameters.Add(new SQLiteParameter("@StartPositionTicks")); - _saveChapterCommand.Parameters.Add(new SQLiteParameter("@Name")); - _saveChapterCommand.Parameters.Add(new SQLiteParameter("@ImagePath")); + _saveChapterCommand.Parameters.Add(_saveChapterCommand, "@ItemId"); + _saveChapterCommand.Parameters.Add(_saveChapterCommand, "@ChapterIndex"); + _saveChapterCommand.Parameters.Add(_saveChapterCommand, "@StartPositionTicks"); + _saveChapterCommand.Parameters.Add(_saveChapterCommand, "@Name"); + _saveChapterCommand.Parameters.Add(_saveChapterCommand, "@ImagePath"); } /// @@ -116,7 +109,7 @@ namespace MediaBrowser.Server.Implementations.Persistence { cmd.CommandText = "select StartPositionTicks,Name,ImagePath from Chapters where ItemId = @ItemId order by ChapterIndex asc"; - cmd.Parameters.Add("@ItemId", DbType.Guid).Value = id; + cmd.Parameters.Add(cmd, "@ItemId", DbType.Guid).Value = id; using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)) { @@ -161,8 +154,8 @@ namespace MediaBrowser.Server.Implementations.Persistence { cmd.CommandText = "select StartPositionTicks,Name,ImagePath from Chapters where ItemId = @ItemId and ChapterIndex=@ChapterIndex"; - cmd.Parameters.Add("@ItemId", DbType.Guid).Value = id; - cmd.Parameters.Add("@ChapterIndex", DbType.Int32).Value = index; + cmd.Parameters.Add(cmd, "@ItemId", DbType.Guid).Value = id; + cmd.Parameters.Add(cmd, "@ChapterIndex", DbType.Int32).Value = index; using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow)) { @@ -215,16 +208,18 @@ namespace MediaBrowser.Server.Implementations.Persistence await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false); - SQLiteTransaction transaction = null; + IDbTransaction transaction = null; try { transaction = _connection.BeginTransaction(); // First delete chapters - _deleteChaptersCommand.Parameters[0].Value = id; + _deleteChaptersCommand.GetParameter(0).Value = id; + _deleteChaptersCommand.Transaction = transaction; - await _deleteChaptersCommand.ExecuteNonQueryAsync(cancellationToken); + + _deleteChaptersCommand.ExecuteNonQuery(); var index = 0; @@ -232,15 +227,15 @@ namespace MediaBrowser.Server.Implementations.Persistence { cancellationToken.ThrowIfCancellationRequested(); - _saveChapterCommand.Parameters[0].Value = id; - _saveChapterCommand.Parameters[1].Value = index; - _saveChapterCommand.Parameters[2].Value = chapter.StartPositionTicks; - _saveChapterCommand.Parameters[3].Value = chapter.Name; - _saveChapterCommand.Parameters[4].Value = chapter.ImagePath; + _saveChapterCommand.GetParameter(0).Value = id; + _saveChapterCommand.GetParameter(1).Value = index; + _saveChapterCommand.GetParameter(2).Value = chapter.StartPositionTicks; + _saveChapterCommand.GetParameter(3).Value = chapter.Name; + _saveChapterCommand.GetParameter(4).Value = chapter.ImagePath; _saveChapterCommand.Transaction = transaction; - await _saveChapterCommand.ExecuteNonQueryAsync(cancellationToken); + _saveChapterCommand.ExecuteNonQuery(); index++; } diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs index 2b14e9b24..ead409598 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs @@ -56,11 +56,40 @@ namespace MediaBrowser.Server.Implementations.Persistence /// /// The conn. /// true if the specified conn is open; otherwise, false. - public static bool IsOpen(this SQLiteConnection conn) + public static bool IsOpen(this IDbConnection conn) { return conn.State == ConnectionState.Open; } + public static IDataParameter GetParameter(this IDbCommand cmd, int index) + { + return (IDataParameter)cmd.Parameters[index]; + } + + public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name, DbType type) + { + var param = cmd.CreateParameter(); + + param.ParameterName = name; + param.DbType = type; + + paramCollection.Add(param); + + return param; + } + + public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name) + { + var param = cmd.CreateParameter(); + + param.ParameterName = name; + + paramCollection.Add(param); + + return param; + } + + /// /// Gets a stream from a DataReader at a given ordinal /// diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index e13d18747..b3294492f 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -10,7 +10,6 @@ - diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index aa7d45b5b..e9169c28e 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -191,12 +191,8 @@ - - - - SplashWindow.xaml