public override Task Detach(AsyncWrappingCommonArgs async)
        {
            if (TransactionCount > 0)
            {
                throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
            }

            if (!_handle.IsInvalid)
            {
                ClearStatusVector();

                _fbClient.isc_detach_database(_statusVector, ref _handle);

                ProcessStatusVector(_statusVector);

                _handle.Dispose();
            }

            WarningMessage   = null;
            Charset          = null;
            ServerVersion    = null;
            _statusVector    = null;
            TransactionCount = 0;
            Dialect          = 0;
            PacketSize       = 0;

            return(Task.CompletedTask);
        }
        public void Detach()
        {
            if (TransactionCount > 0)
            {
                throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
            }

            if (!_handle.IsInvalid)
            {
                ClearStatusVector();

                _fbClient.isc_detach_database(_statusVector, ref _handle);

                ProcessStatusVector(_statusVector);

                _handle.Dispose();
            }

            _warningMessage   = null;
            _charset          = null;
            _serverVersion    = null;
            _statusVector     = null;
            _transactionCount = 0;
            _dialect          = 0;
            _packetSize       = 0;
        }
        public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                if (TransactionCount > 0)
                {
                    throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
                }

                try
                {
                    CloseEventManager();

                    var detach = _handle != -1;
                    if (detach)
                    {
                        XdrStream.Write(IscCodes.op_detach);
                        XdrStream.Write(_handle);
                    }
                    XdrStream.Write(IscCodes.op_disconnect);
                    XdrStream.Flush();
                    if (detach)
                    {
                        ReadResponse();
                    }

                    CloseConnection();

#warning Here
                    _xdrStream?.Dispose();
                }
                catch (IOException ex)
                {
                    try
                    {
                        CloseConnection();
                    }
                    catch (IOException ex2)
                    {
                        throw IscException.ForErrorCode(IscCodes.isc_network_error, ex2);
                    }
                    throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
                }
                finally
                {
                    _xdrStream        = null;
                    _connection       = null;
                    _charset          = null;
                    _eventManager     = null;
                    _serverVersion    = null;
                    _dialect          = 0;
                    _handle           = -1;
                    _packetSize       = 0;
                    _warningMessage   = null;
                    _transactionCount = 0;
                }
            }
        }
Exemplo n.º 4
0
        public virtual void Detach()
        {
            lock (SyncObject)
            {
                if (TransactionCount > 0)
                {
                    throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
                }

                try
                {
                    if (_handle != 0)
                    {
                        XdrStream.Write(IscCodes.op_detach);
                        XdrStream.Write(_handle);
                    }
                    XdrStream.Write(IscCodes.op_disconnect);
                    XdrStream.Flush();

                    // Close the Event Manager
                    CloseEventManager();

                    // Disconnect
                    CloseConnection();

#warning Here
                    // Close Input and Output streams
                    _xdrStream?.Close();

                    // Clear members
                    _transactionCount = 0;
                    _handle           = 0;
                    _dialect          = 0;
                    _packetSize       = 0;
                    _xdrStream        = null;
                    _charset          = null;
                    _connection       = null;
                    _serverVersion    = null;
                }
                catch (IOException ex)
                {
                    try
                    {
                        CloseConnection();
                    }
                    catch (IOException ex2)
                    {
                        throw IscException.ForErrorCode(IscCodes.isc_network_error, ex2);
                    }

                    throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
                }
            }
        }
Exemplo n.º 5
0
        public virtual async Task Detach(AsyncWrappingCommonArgs async)
        {
            if (TransactionCount > 0)
            {
                throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
            }

            try
            {
                await CloseEventManager(async).ConfigureAwait(false);

                var detach = _handle != -1;
                if (detach)
                {
                    await Xdr.Write(IscCodes.op_detach, async).ConfigureAwait(false);

                    await Xdr.Write(_handle, async).ConfigureAwait(false);
                }
                await Xdr.Write(IscCodes.op_disconnect, async).ConfigureAwait(false);

                await Xdr.Flush(async).ConfigureAwait(false);

                if (detach)
                {
                    await ReadResponse(async).ConfigureAwait(false);
                }

                await CloseConnection(async).ConfigureAwait(false);
            }
            catch (IOException ex)
            {
                try
                {
                    await CloseConnection(async).ConfigureAwait(false);
                }
                catch (IOException ex2)
                {
                    throw IscException.ForErrorCode(IscCodes.isc_network_error, ex2);
                }
                throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
            }
            finally
            {
                _connection       = null;
                _charset          = null;
                _eventManager     = null;
                _serverVersion    = null;
                _dialect          = 0;
                _handle           = -1;
                _packetSize       = 0;
                _warningMessage   = null;
                _transactionCount = 0;
            }
        }
Exemplo n.º 6
0
        public override async ValueTask DetachAsync(CancellationToken cancellationToken = default)
        {
            if (TransactionCount > 0)
            {
                throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
            }

            try
            {
                await CloseEventManagerAsync(cancellationToken).ConfigureAwait(false);

                var detach = _handle != -1;
                if (detach)
                {
                    await Xdr.WriteAsync(IscCodes.op_detach, cancellationToken).ConfigureAwait(false);

                    await Xdr.WriteAsync(_handle, cancellationToken).ConfigureAwait(false);
                }
                await Xdr.WriteAsync(IscCodes.op_disconnect, cancellationToken).ConfigureAwait(false);

                await Xdr.FlushAsync(cancellationToken).ConfigureAwait(false);

                if (detach)
                {
                    await ReadResponseAsync(cancellationToken).ConfigureAwait(false);
                }

                await CloseConnectionAsync(cancellationToken).ConfigureAwait(false);
            }
            catch (IOException ex)
            {
                try
                {
                    await CloseConnectionAsync(cancellationToken).ConfigureAwait(false);
                }
                catch (IOException)
                { }
                throw IscException.ForIOException(ex);
            }
            finally
            {
                _connection      = null;
                Charset          = null;
                _eventManager    = null;
                ServerVersion    = null;
                Dialect          = 0;
                _handle          = -1;
                PacketSize       = 0;
                WarningMessage   = null;
                TransactionCount = 0;
            }
        }
Exemplo n.º 7
0
        public void Detach()
        {
            if (TransactionCount > 0)
            {
                throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
            }

            ClearStatusVector();

            _fbClient.isc_detach_database(_statusVector, ref _handle);

            ProcessStatusVector(_statusVector);
        }
Exemplo n.º 8
0
        public override void Detach()
        {
            if (TransactionCount > 0)
            {
                throw IscException.ForErrorCodeIntParam(IscCodes.isc_open_trans, TransactionCount);
            }

            try
            {
                CloseEventManager();

                var detach = _handle != -1;
                if (detach)
                {
                    Xdr.Write(IscCodes.op_detach);
                    Xdr.Write(_handle);
                }
                Xdr.Write(IscCodes.op_disconnect);
                Xdr.Flush();
                if (detach)
                {
                    ReadResponse();
                }

                CloseConnection();
            }
            catch (IOException ex)
            {
                try
                {
                    CloseConnection();
                }
                catch (IOException)
                { }
                throw IscException.ForIOException(ex);
            }
            finally
            {
                _connection      = null;
                Charset          = null;
                _eventManager    = null;
                ServerVersion    = null;
                Dialect          = 0;
                _handle          = -1;
                PacketSize       = 0;
                WarningMessage   = null;
                TransactionCount = 0;
            }
        }