public Task <bool> ClearUserAdditionalDataKeyAsync(Guid profileId, string key)
        {
            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();

            try
            {
                using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserAdditionalDataCommand(transaction, profileId, null, key))
                    command.ExecuteNonQuery();
                transaction.Commit();

                return(Task.FromResult(true));
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error clearing user additional data for profile '{0}'", e, profileId);
                transaction.Rollback();
                throw;
            }
        }
Ejemplo n.º 2
0
        public bool SetUserAdditionalData(Guid profileId, string key, string data)
        {
            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();

            try
            {
                bool result;
                using (IDbCommand command = UserProfileDataManagement_SubSchema.DeleteUserAdditionalDataCommand(transaction, profileId, key))
                    command.ExecuteNonQuery();
                using (IDbCommand command = UserProfileDataManagement_SubSchema.CreateUserAdditionalDataCommand(transaction, profileId, key, data))
                    result = command.ExecuteNonQuery() > 0;
                transaction.Commit();
                return(result);
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("UserProfileDataManagement: Error setting additional data '{0}' in profile '{1}'", e, key, profileId);
                transaction.Rollback();
                throw;
            }
        }
Ejemplo n.º 3
0
        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;
            }
        }