removed chapters from baseitem

This commit is contained in:
Luke Pulverenti
2013-06-18 15:16:27 -04:00
parent 6de9e2491f
commit 13f6da1bf4
47 changed files with 967 additions and 599 deletions

View File

@@ -15,13 +15,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// <summary>
/// Class SQLiteDisplayPreferencesRepository
/// </summary>
public class SqliteDisplayPreferencesRepository : SqliteRepository, IDisplayPreferencesRepository
public class SqliteDisplayPreferencesRepository : IDisplayPreferencesRepository
{
/// <summary>
/// The repository name
/// </summary>
public const string RepositoryName = "SQLite";
private SQLiteConnection _connection;
private readonly ILogger _logger;
/// <summary>
/// Gets the name of the repository
/// </summary>
@@ -30,7 +29,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
get
{
return RepositoryName;
return "SQLite";
}
}
@@ -58,7 +57,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// appPaths
/// </exception>
public SqliteDisplayPreferencesRepository(IApplicationPaths appPaths, IJsonSerializer jsonSerializer, ILogManager logManager)
: base(logManager)
{
if (jsonSerializer == null)
{
@@ -71,6 +69,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
_jsonSerializer = jsonSerializer;
_appPaths = appPaths;
_logger = logManager.GetLogger(GetType().Name);
}
/// <summary>
@@ -81,7 +81,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
var dbFile = Path.Combine(_appPaths.DataPath, "displaypreferences.db");
await ConnectToDb(dbFile).ConfigureAwait(false);
_connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);
string[] queries = {
@@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
"pragma temp_store = memory"
};
RunQueries(queries);
_connection.RunQueries(queries, _logger);
}
/// <summary>
@@ -127,9 +127,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
try
{
transaction = Connection.BeginTransaction();
transaction = _connection.BeginTransaction();
using (var cmd = Connection.CreateCommand())
using (var cmd = _connection.CreateCommand())
{
cmd.CommandText = "replace into displaypreferences (id, data) values (@1, @2)";
cmd.AddParam("@1", displayPreferences.Id);
@@ -153,7 +153,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
catch (Exception e)
{
Logger.ErrorException("Failed to save display preferences:", e);
_logger.ErrorException("Failed to save display preferences:", e);
if (transaction != null)
{
@@ -179,24 +179,24 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// <param name="displayPreferencesId">The display preferences id.</param>
/// <returns>Task{DisplayPreferences}.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public async Task<DisplayPreferences> GetDisplayPreferences(Guid displayPreferencesId)
public DisplayPreferences GetDisplayPreferences(Guid displayPreferencesId)
{
if (displayPreferencesId == Guid.Empty)
{
throw new ArgumentNullException("displayPreferencesId");
}
var cmd = Connection.CreateCommand();
var cmd = _connection.CreateCommand();
cmd.CommandText = "select data from displaypreferences where id = @id";
var idParam = cmd.Parameters.Add("@id", DbType.Guid);
idParam.Value = displayPreferencesId;
using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow).ConfigureAwait(false))
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult | CommandBehavior.SingleRow))
{
if (reader.Read())
{
using (var stream = GetStream(reader, 0))
using (var stream = reader.GetMemoryStream(0))
{
return _jsonSerializer.DeserializeFromStream<DisplayPreferences>(stream);
}
@@ -205,5 +205,47 @@ namespace MediaBrowser.Server.Implementations.Persistence
return null;
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private readonly object _disposeLock = new object();
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
if (dispose)
{
try
{
lock (_disposeLock)
{
if (_connection != null)
{
if (_connection.IsOpen())
{
_connection.Close();
}
_connection.Dispose();
_connection = null;
}
}
}
catch (Exception ex)
{
_logger.ErrorException("Error disposing database", ex);
}
}
}
}
}