Beispiel #1
0
        public void DetachClientAndRemoveShares(string clientSystemId)
        {
            ISQLDatabase database    = ServiceRegistration.Get <ISQLDatabase>();
            ITransaction transaction = database.BeginTransaction();

            try
            {
                using (IDbCommand command = ClientManager_SubSchema.DeleteAttachedClientCommand(transaction, clientSystemId))
                    command.ExecuteNonQuery();

                IMediaLibrary mediaLibrary = ServiceRegistration.Get <IMediaLibrary>();
                mediaLibrary.DeleteMediaItemOrPath(clientSystemId, null, true);
                mediaLibrary.RemoveSharesOfSystem(clientSystemId);

                transaction.Commit();
            }
            catch (Exception e)
            {
                ServiceRegistration.Get <ILogger>().Error("ClientManager: Error detaching client '{0}'", e, clientSystemId);
                transaction.Rollback();
                throw;
            }
            ServiceRegistration.Get <ILogger>().Info("ClientManager: Client with system ID '{0}' detached", clientSystemId);
            // Last action: Remove the client from the collection of attached clients and disconnect the client connection, if connected
            _attachedClients = ReadAttachedClientsFromDB();
            _controlPoint.RemoveAttachedClient(clientSystemId);
            ClientManagerMessaging.SendClientAttachmentChangeMessage(ClientManagerMessaging.MessageType.ClientDetached, clientSystemId);
        }