public Task <bool> SetUserMediaItemDataAsync(Guid profileId, Guid mediaItemId, string key, string data) { ISQLDatabase database = ServiceRegistration.Get <ISQLDatabase>(); ITransaction transaction = database.BeginTransaction(); try { bool result; using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserMediaItemDataCommand(transaction, profileId, mediaItemId, key)) command.ExecuteNonQuery(); // Allow "delete only", if new data is null. This is used to delete no longer required data. if (!string.IsNullOrEmpty(data)) { using (IDbCommand command = UserProfileDataManagement_SubSchema.CreateUserMediaItemDataCommand(transaction, profileId, mediaItemId, key, data)) result = command.ExecuteNonQuery() > 0; } else { result = true; } transaction.Commit(); return(Task.FromResult(result)); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error setting media item data '{0}' for media item '{1}' in profile '{2}'", e, key, mediaItemId, profileId); transaction.Rollback(); throw; } }
public Task <bool> ClearUserMediaItemDataKeyAsync(Guid profileId, string key) { ISQLDatabase database = ServiceRegistration.Get <ISQLDatabase>(); ITransaction transaction = database.BeginTransaction(); try { using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserMediaItemDataCommand(transaction, profileId, null, key)) command.ExecuteNonQuery(); transaction.Commit(); return(Task.FromResult(true)); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error clearing user media item data for profile '{0}'", e, profileId); transaction.Rollback(); throw; } }
public bool SetUserMediaItemData(Guid profileId, Guid mediaItemId, string key, string data) { ISQLDatabase database = ServiceRegistration.Get <ISQLDatabase>(); ITransaction transaction = database.BeginTransaction(); try { bool result; using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserMediaItemDataCommand(transaction, profileId, mediaItemId, key)) command.ExecuteNonQuery(); using (IDbCommand command = UserProfileDataManagement_SubSchema.CreateUserMediaItemDataCommand(transaction, profileId, mediaItemId, key, data)) result = command.ExecuteNonQuery() > 0; transaction.Commit(); return(result); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error setting media item data '{0}' for media item '{1}' in profile '{2}'", e, key, mediaItemId, profileId); transaction.Rollback(); throw; } }
public bool ClearAllUserData(Guid profileId) { ISQLDatabase database = ServiceRegistration.Get <ISQLDatabase>(); ITransaction transaction = database.BeginTransaction(); try { using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserPlaylistDataCommand(transaction, profileId, null, null)) command.ExecuteNonQuery(); using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserMediaItemDataCommand(transaction, profileId, null, null)) command.ExecuteNonQuery(); using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserAdditionalDataCommand(transaction, profileId, null)) command.ExecuteNonQuery(); transaction.Commit(); return(true); } catch (Exception e) { ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error clearing user data for profile '{0}'", e, profileId); transaction.Rollback(); throw; } }