Ejemplo n.º 1
0
        protected virtual async Task <IResponse> ReadSingleResponse(int operation, AsyncWrappingCommonArgs async)
        {
            var response = await GdsConnection.ProcessOperation(operation, Xdr, async).ConfigureAwait(false);

            ProcessResponseWarnings(response);
            return(response);
        }
        public virtual void Detach()
        {
            try
            {
                _database.Xdr.Write(IscCodes.op_service_detach);
                _database.Xdr.Write(Handle);
                _database.Xdr.Write(IscCodes.op_disconnect);
                _database.Xdr.Flush();

                _handle = 0;
            }
            catch (IOException ex)
            {
                throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
            }
            finally
            {
                try
                {
                    _connection.Disconnect();
                }
                catch (IOException ex)
                {
                    throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
                }
                finally
                {
                    _database   = null;
                    _connection = null;
                }
            }
        }
        public virtual async Task <IResponse> ReadResponse(int operation, AsyncWrappingCommonArgs async)
        {
            var response = await ReadSingleResponse(operation, async).ConfigureAwait(false);

            GdsConnection.ProcessResponse(response);
            return(response);
        }
Ejemplo n.º 4
0
        public override void Detach()
        {
            try
            {
                _database.Xdr.Write(IscCodes.op_service_detach);
                _database.Xdr.Write(Handle);
                _database.Xdr.Write(IscCodes.op_disconnect);
                _database.Xdr.Flush();

                Handle = 0;
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
            finally
            {
                try
                {
                    _connection.Disconnect();
                }
                catch (IOException ex)
                {
                    throw IscException.ForIOException(ex);
                }
                finally
                {
                    _database   = null;
                    _connection = null;
                }
            }
        }
Ejemplo n.º 5
0
        public override async ValueTask DetachAsync(CancellationToken cancellationToken = default)
        {
            try
            {
                await _database.Xdr.WriteAsync(IscCodes.op_service_detach, cancellationToken).ConfigureAwait(false);

                await _database.Xdr.WriteAsync(Handle, cancellationToken).ConfigureAwait(false);

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

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

                Handle = 0;
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
            finally
            {
                try
                {
                    await _connection.DisconnectAsync(cancellationToken).ConfigureAwait(false);
                }
                catch (IOException ex)
                {
                    throw IscException.ForIOException(ex);
                }
                finally
                {
                    _database   = null;
                    _connection = null;
                }
            }
        }
        public void Detach()
        {
            lock (this)
            {
                try
                {
                    _database.Write(IscCodes.op_service_detach);
                    _database.Write(Handle);
                    _database.Write(IscCodes.op_disconnect);
                    _database.Flush();

                    _handle = 0;
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_network_error);
                }
                finally
                {
                    try
                    {
                        _connection.Disconnect();
                    }
                    catch (IOException)
                    {
                        throw new IscException(IscCodes.isc_network_error);
                    }
                    finally
                    {
                        _database   = null;
                        _connection = null;
                    }
                }
            }
        }
        protected virtual IResponse ReadSingleResponse(int operation)
        {
            var response = GdsConnection.ProcessOperation(operation, Xdr);

            ProcessResponseWarnings(response);
            return(response);
        }
        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;
                }
            }
        }
Ejemplo n.º 9
0
        public virtual async Task Detach(AsyncWrappingCommonArgs async)
        {
            try
            {
                await _database.Xdr.Write(IscCodes.op_service_detach, async).ConfigureAwait(false);

                await _database.Xdr.Write(Handle, async).ConfigureAwait(false);

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

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

                _handle = 0;
            }
            catch (IOException ex)
            {
                throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
            }
            finally
            {
                try
                {
                    await _connection.Disconnect(async).ConfigureAwait(false);
                }
                catch (IOException ex)
                {
                    throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
                }
                finally
                {
                    _database   = null;
                    _connection = null;
                }
            }
        }
Ejemplo n.º 10
0
        public async Task Open(AsyncWrappingCommonArgs async)
        {
            var connection = new GdsConnection(_ipAddress, _portNumber, _timeout);
            await connection.Connect(async).ConfigureAwait(false);

            _database = new GdsDatabase(connection);
        }
Ejemplo n.º 11
0
        public virtual IResponse ReadResponse()
        {
            var response = ReadSingleResponse();

            GdsConnection.HandleResponseException(response);
            return(response);
        }
Ejemplo n.º 12
0
        public virtual async ValueTask <IResponse> ReadResponseAsync(CancellationToken cancellationToken = default)
        {
            var response = await ReadSingleResponseAsync(cancellationToken).ConfigureAwait(false);

            GdsConnection.HandleResponseException(response);
            return(response);
        }
        private void Dispose(bool disposing)
        {
            lock (SyncObject)
            {
                if (!_disposed)
                {
                    try
                    {
                        Detach();
                    }
                    catch
                    { }
                    finally
                    {
                        if (disposing)
                        {
                            _connection       = null;
                            _charset          = null;
                            _eventManager     = null;
                            _serverVersion    = null;
                            _dialect          = 0;
                            _eventsId         = 0;
                            _handle           = 0;
                            _packetSize       = 0;
                            _warningMessage   = null;
                            _transactionCount = 0;
                        }

                        _disposed = true;
                    }
                }
            }
        }
Ejemplo n.º 14
0
        protected virtual IResponse ReadSingleResponse()
        {
            var operation = ReadOperation();
            var response  = GdsConnection.ProcessOperation(operation, XdrStream);

            ProcessResponseWarnings(response);
            return(response);
        }
Ejemplo n.º 15
0
 public GdsDatabase(GdsConnection connection)
 {
     _connection = connection;
     _charset    = Charset.DefaultCharset;
     _dialect    = 3;
     _handle     = -1;
     _packetSize = 8192;
 }
        public GdsEventManager(int handle, string ipAddress, int portNumber)
        {
            _handle = handle;
            var connection = new GdsConnection(ipAddress, portNumber);

            connection.Connect();
            _database = new GdsDatabase(connection);
        }
Ejemplo n.º 17
0
 public GdsDatabase(GdsConnection connection)
 {
     _connection = connection;
     _charset    = Charset.DefaultCharset;
     _dialect    = 3;
     _packetSize = 8192;
     _xdrStream  = _connection.CreateXdrStream();
 }
        public GdsDatabase(GdsConnection connection)
        {
            _connection   = connection;
            _charset      = Charset.DefaultCharset;
            _dialect      = 3;
            _packetSize   = 8192;
            _inputStream  = _connection.CreateXdrStream();
            _outputStream = _connection.CreateXdrStream();

            GC.SuppressFinalize(this);
        }
Ejemplo n.º 19
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);
                }
            }
        }
Ejemplo n.º 20
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;
            }
        }
Ejemplo n.º 21
0
        public GdsDatabase(GdsConnection connection)
        {
            this.connection = connection;
            this.charset = Charset.DefaultCharset;
            this.dialect = 3;
            this.packetSize = 8192;
            this.inputStream = this.connection.CreateXdrStream();
            this.outputStream = this.connection.CreateXdrStream();

            GC.SuppressFinalize(this);
        }
Ejemplo n.º 22
0
        public GdsDatabase(GdsConnection connection)
        {
            this.connection   = connection;
            this.charset      = Charset.DefaultCharset;
            this.dialect      = 3;
            this.packetSize   = 8192;
            this.inputStream  = this.connection.CreateXdrStream();
            this.outputStream = this.connection.CreateXdrStream();

            GC.SuppressFinalize(this);
        }
Ejemplo n.º 23
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;
            }
        }
Ejemplo n.º 24
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;
            }
        }
		public GdsEventManager(int handle, string ipAddress, int portNumber)
		{
			_events = new ConcurrentDictionary<int, RemoteEvent>();
			_handle = handle;

			// Initialize the connection
			if (_database == null)
			{
				GdsConnection connection = new GdsConnection(ipAddress, portNumber);

				connection.Connect();

				_database = new GdsDatabase(connection);
			}
		}
Ejemplo n.º 26
0
        public GdsEventManager(int handle, string ipAddress, int portNumber)
        {
            _events = new ConcurrentDictionary <int, RemoteEvent>();
            _handle = handle;

            // Initialize the connection
            if (_database == null)
            {
                GdsConnection connection = new GdsConnection(ipAddress, portNumber);

                connection.Connect();

                _database = new GdsDatabase(connection);
            }
        }
Ejemplo n.º 27
0
 public void Dispose()
 {
     if (!_disposed)
     {
         _disposed = true;
         Detach();
         _connection       = null;
         _charset          = null;
         _eventManager     = null;
         _serverVersion    = null;
         _dialect          = 0;
         _handle           = 0;
         _packetSize       = 0;
         _warningMessage   = null;
         _transactionCount = 0;
     }
 }
Ejemplo n.º 28
0
        public GdsEventManager(int handle, string ipAddress, int portNumber)
        {
            this.events = new Hashtable();
            this.events = Hashtable.Synchronized(this.events);
            this.handle = handle;
            this.syncContext = SynchronizationContext.Current ?? new SynchronizationContext();

            // Initialize the connection
            if (this.database == null)
            {
                GdsConnection connection = new GdsConnection(ipAddress, portNumber);

                connection.Connect();

                this.database = new GdsDatabase(connection);
            }
        }
Ejemplo n.º 29
0
        //public Hashtable EventList
        //{
        //    get { return this.events; }
        //}

        #endregion

        #region · Constructors ·

        public GdsEventManager(int handle, string ipAddress, int portNumber)
        {
            this.events = new Hashtable();
            this.events = Hashtable.Synchronized(this.events);
            this.handle = handle;
#if (NET_CF)
            this.syncControl = new System.Windows.Forms.Control();
            IntPtr h = this.syncControl.Handle; // force handle creation
#else
            this.syncContext = SynchronizationContext.Current ?? new SynchronizationContext();
#endif


            // Initialize the connection
            if (this.database == null)
            {
                GdsConnection connection = new GdsConnection(ipAddress, portNumber);

                connection.Connect();

                this.database = new GdsDatabase(connection);
            }
        }
        //public Hashtable EventList
        //{
        //    get { return this.events; }
        //}

        #endregion

        #region · Constructors ·

        public GdsEventManager(int handle, string ipAddress, int portNumber)
        {
            this.events = new Hashtable();
            this.events = Hashtable.Synchronized(this.events);
            this.handle = handle;
#if (NET_CF)
            this.syncControl = new System.Windows.Forms.Control();
            IntPtr h = this.syncControl.Handle; // force handle creation
#else
            this.syncContext = SynchronizationContext.Current ?? new SynchronizationContext();
#endif
                    

            // Initialize the connection
            if (this.database == null)
            {
                GdsConnection connection = new GdsConnection(ipAddress, portNumber);

                connection.Connect();

                this.database = new GdsDatabase(connection);
            }
        }
Ejemplo n.º 31
0
        private void Dispose(bool disposing)
        {
            lock (this.SyncObject)
            {
                if (!this.disposed)
                {
                    try
                    {
                        // release any unmanaged resources
                        this.Detach();
                    }
                    catch
                    {
                    }
                    finally
                    {
                        // release any managed resources
                        if (disposing)
                        {
                            this.connection       = null;
                            this.charset          = null;
                            this.eventManager     = null;
                            this.serverVersion    = null;
                            this.dialect          = 0;
                            this.eventsId         = 0;
                            this.handle           = 0;
                            this.packetSize       = 0;
                            this.warningMessage   = null;
                            this.transactionCount = 0;
                        }

                        this.disposed = true;
                    }
                }
            }
        }
Ejemplo n.º 32
0
        private void Dispose(bool disposing)
        {
            lock (this.SyncObject)
            {
                if (!this.disposed)
                {
                    try
                    {
                        // release any unmanaged resources
                        this.Detach();
                    }
                    catch
                    {
                    }
                    finally
                    {
                        // release any managed resources
                        if (disposing)
                        {
                            this.connection = null;
                            this.charset = null;
                            this.eventManager = null;
                            this.serverVersion = null;
                            this.dialect = 0;
                            this.eventsId = 0;
                            this.handle = 0;
                            this.packetSize = 0;
                            this.warningMessage = null;
                            this.transactionCount = 0;
                        }

                        this.disposed = true;
                    }
                }
            }
        }
		public GdsDatabase(GdsConnection connection)
		{
			_connection = connection;
			_charset = Charset.DefaultCharset;
			_dialect = 3;
			_packetSize = 8192;
			_inputStream = _connection.CreateXdrStream();
			_outputStream = _connection.CreateXdrStream();

			GC.SuppressFinalize(this);
		}
Ejemplo n.º 34
0
        public virtual void Detach()
        {
            lock (this.SyncObject)
            {
                if (this.TransactionCount > 0)
                {
                    throw new IscException(IscCodes.isc_open_trans, this.TransactionCount);
                }

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

                    // Close the Event Manager
                    this.CloseEventManager();

                    // Disconnect
                    this.CloseConnection();

                    // Close Input and Output streams
                    if (this.inputStream != null)
                    {
                        this.inputStream.Close();
                    }
                    if (this.outputStream != null)
                    {
                        this.outputStream.Close();
                    }

                    // Clear members
                    this.transactionCount = 0;
                    this.handle = 0;
                    this.dialect = 0;
                    this.packetSize = 0;
                    this.operation = 0;
                    this.outputStream = null;
                    this.inputStream = null;
                    this.charset = null;
                    this.connection = null;
                    this.serverVersion = null;
                }
                catch (IOException)
                {
                    try
                    {
                        this.CloseConnection();
                    }
                    catch (IOException)
                    {
                        throw new IscException(IscCodes.isc_network_error);
                    }

                    throw new IscException(IscCodes.isc_network_error);
                }
            }
        }
		public void Detach()
		{
			lock (this)
			{
				try
				{
					_database.XdrStream.Write(IscCodes.op_service_detach);
					_database.XdrStream.Write(Handle);
					_database.XdrStream.Write(IscCodes.op_disconnect);
					_database.XdrStream.Flush();

					_handle = 0;
				}
				catch (IOException ex)
				{
					throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
				}
				finally
				{
					try
					{
						_connection.Disconnect();
					}
					catch (IOException ex)
					{
						throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
					}
					finally
					{
						_database = null;
						_connection = null;
					}
				}
			}
		}
Ejemplo n.º 36
0
 public GdsServiceManager(GdsConnection connection)
 {
     _connection = connection;
     _database   = new GdsDatabase(_connection);
 }
        public virtual void Detach()
        {
            lock (SyncObject)
            {
                if (TransactionCount > 0)
                {
                    throw new IscException(IscCodes.isc_open_trans, TransactionCount);
                }

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

                    // Close the Event Manager
                    CloseEventManager();

                    // Disconnect
                    CloseConnection();

                    // Close Input and Output streams
                    if (_inputStream != null)
                    {
                        _inputStream.Close();
                    }
                    if (_outputStream != null)
                    {
                        _outputStream.Close();
                    }

                    // Clear members
                    _transactionCount = 0;
                    _handle           = 0;
                    _dialect          = 0;
                    _packetSize       = 0;
                    _operation        = 0;
                    _outputStream     = null;
                    _inputStream      = null;
                    _charset          = null;
                    _connection       = null;
                    _serverVersion    = null;
                }
                catch (IOException)
                {
                    try
                    {
                        CloseConnection();
                    }
                    catch (IOException)
                    {
                        throw new IscException(IscCodes.isc_network_error);
                    }

                    throw new IscException(IscCodes.isc_network_error);
                }
            }
        }
Ejemplo n.º 38
0
		public GdsServiceManager(GdsConnection connection)
		{
			this.connection = connection;
			this.database   = new GdsDatabase(this.connection);
		}
		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;
					_operation = 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);
				}
			}
		}
 public GdsServiceManager(GdsConnection connection)
 {
     this.connection = connection;
     this.database   = new GdsDatabase(this.connection);
 }
		public GdsServiceManager(GdsConnection connection)
		{
			_connection = connection;
			_database = new GdsDatabase(_connection);
		}
		public GdsDatabase(GdsConnection connection)
		{
			_connection = connection;
			_charset = Charset.DefaultCharset;
			_dialect = 3;
			_packetSize = 8192;
			_xdrStream = _connection.CreateXdrStream();
		}
		public virtual void Detach()
		{
			lock (SyncObject)
			{
				if (TransactionCount > 0)
				{
					throw new IscException(IscCodes.isc_open_trans, TransactionCount);
				}

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

					// Close the Event Manager
					CloseEventManager();

					// Disconnect
					CloseConnection();

					// Close Input and Output streams
					if (_inputStream != null)
					{
						_inputStream.Close();
					}
					if (_outputStream != null)
					{
						_outputStream.Close();
					}

					// Clear members
					_transactionCount = 0;
					_handle = 0;
					_dialect = 0;
					_packetSize = 0;
					_operation = 0;
					_outputStream = null;
					_inputStream = null;
					_charset = null;
					_connection = null;
					_serverVersion = null;
				}
				catch (IOException)
				{
					try
					{
						CloseConnection();
					}
					catch (IOException)
					{
						throw new IscException(IscCodes.isc_network_error);
					}

					throw new IscException(IscCodes.isc_network_error);
				}
			}
		}
Ejemplo n.º 44
0
		public void Detach()
		{
			lock (this)
			{
				try
				{
					this.database.Write(IscCodes.op_service_detach);
					this.database.Write(this.Handle);
					this.database.Write(IscCodes.op_disconnect);
					this.database.Flush();

					this.handle = 0;
				}
				catch (IOException)
				{
					throw new IscException(IscCodes.isc_network_error);
				}
				finally
				{
					try
					{
						this.connection.Disconnect();
					}
					catch (IOException)
					{
						throw new IscException(IscCodes.isc_network_error);
					}
					finally
					{
						this.database   = null;
						this.connection = null;
					}
				}
			}
		}
		private void Dispose(bool disposing)
		{
			lock (SyncObject)
			{
				if (!_disposed)
				{
					try
					{
						Detach();
					}
					catch
					{ }
					finally
					{
						if (disposing)
						{
							_connection = null;
							_charset = null;
							_eventManager = null;
							_serverVersion = null;
							_dialect = 0;
							_eventsId = 0;
							_handle = 0;
							_packetSize = 0;
							_warningMessage = null;
							_transactionCount = 0;
						}

						_disposed = true;
					}
				}
			}
		}