示例#1
0
        public override void QueueEvents(RemoteEvent remoteEvent)
        {
            try
            {
                if (_eventManager == null)
                {
                    var(auxHandle, ipAddress, portNumber, timeout) = ConnectionRequest();
                    _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber, timeout);
                    _eventManager.Open();
                    var dummy = _eventManager.StartWaitingForEvents(remoteEvent);
                }

                remoteEvent.LocalId++;

                var epb     = remoteEvent.BuildEpb();
                var epbData = epb.ToArray();

                Xdr.Write(IscCodes.op_que_events);
                Xdr.Write(_handle);
                Xdr.WriteBuffer(epbData);
                Xdr.Write(AddressOfAstRoutine);
                Xdr.Write(ArgumentToAstRoutine);
                Xdr.Write(remoteEvent.LocalId);

                Xdr.Flush();

                var response = (GenericResponse)ReadResponse();

                remoteEvent.RemoteId = response.ObjectHandle;
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
        }
示例#2
0
        public void QueueEvents(RemoteEvent remoteEvent)
        {
            try
            {
                if (_eventManager == null)
                {
                    ConnectionRequest(out var auxHandle, out var ipAddress, out var portNumber);
                    _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
                    var dummy = _eventManager.WaitForEventsAsync(remoteEvent);
                }

                remoteEvent.LocalId++;

                var epb     = remoteEvent.BuildEpb();
                var epbData = epb.ToArray();

                Xdr.Write(IscCodes.op_que_events);
                Xdr.Write(_handle);
                Xdr.WriteBuffer(epbData);
                Xdr.Write(AddressOfAstRoutine);
                Xdr.Write(ArgumentToAstRoutine);
                Xdr.Write(remoteEvent.LocalId);

                Xdr.Flush();

                var response = (GenericResponse)ReadResponse();

                remoteEvent.RemoteId = response.ObjectHandle;
            }
            catch (IOException ex)
            {
                throw IscException.ForErrorCode(IscCodes.isc_network_error, ex);
            }
        }
        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;
                }
            }
        }
示例#4
0
        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;
                    }
                }
            }
        }
示例#5
0
 public void CloseEventManager()
 {
     if (_eventManager != null)
     {
         _eventManager.Dispose();
         _eventManager = null;
     }
 }
示例#6
0
 public override void CloseEventManager()
 {
     if (_eventManager != null)
     {
         _eventManager.Close();
         _eventManager = null;
     }
 }
示例#7
0
        public override async ValueTask CloseEventManagerAsync(CancellationToken cancellationToken = default)
        {
            if (_eventManager != null)
            {
                await _eventManager.CloseAsync(cancellationToken).ConfigureAwait(false);

                _eventManager = null;
            }
        }
示例#8
0
        public override async Task CloseEventManager(AsyncWrappingCommonArgs async)
        {
            if (_eventManager != null)
            {
                await _eventManager.Close(async).ConfigureAwait(false);

                _eventManager = null;
            }
        }
示例#9
0
 public void CloseEventManager()
 {
     lock (this.SyncObject)
     {
         if (this.eventManager != null)
         {
             this.eventManager.Close();
             this.eventManager = null;
         }
     }
 }
示例#10
0
 public void CloseEventManager()
 {
     lock (SyncObject)
     {
         if (_eventManager != null)
         {
             _eventManager.Close();
             _eventManager = null;
         }
     }
 }
示例#11
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;
            }
        }
示例#12
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;
            }
        }
示例#13
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;
            }
        }
示例#14
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;
     }
 }
示例#15
0
        public void QueueEvents(RemoteEvent events)
        {
            if (_eventManager == null)
            {
                string ipAddress  = string.Empty;
                int    portNumber = 0;
                int    auxHandle  = 0;

                ConnectionRequest(out auxHandle, out ipAddress, out portNumber);

                _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
            }

            lock (SyncObject)
            {
                try
                {
                    events.LocalId = Interlocked.Increment(ref _eventsId);

                    // Enqueue events in the event manager
                    _eventManager.QueueEvents(events);

                    EventParameterBuffer epb = events.ToEpb();

                    XdrStream.Write(IscCodes.op_que_events);
                    XdrStream.Write(_handle);                                     // Database object id
                    XdrStream.WriteBuffer(epb.ToArray());                         // Event description block
                    XdrStream.Write(0);                                           // Address of ast routine
                    XdrStream.Write(0);                                           // Argument to ast routine
                    XdrStream.Write(events.LocalId);                              // Client side id of remote event

                    XdrStream.Flush();

                    GenericResponse response = (GenericResponse)ReadResponse();

                    // Update event	Remote event ID
                    events.RemoteId = response.ObjectHandle;
                }
                catch (IOException ex)
                {
                    throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex);
                }
            }
        }
示例#16
0
        public void QueueEvents(RemoteEvent events)
        {
            if (this.eventManager == null)
            {
                string ipAddress  = string.Empty;
                int    portNumber = 0;
                int    auxHandle  = 0;

                this.ConnectionRequest(out auxHandle, out ipAddress, out portNumber);

                this.eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
            }

            lock (this.SyncObject)
            {
                try
                {
                    events.LocalId = ++this.eventsId;

                    EventParameterBuffer epb = events.ToEpb();

                    this.Write(IscCodes.op_que_events); // Op codes
                    this.Write(this.handle);            // Database	object id
                    this.WriteBuffer(epb.ToArray());    // Event description block
                    this.Write(0);                      // Address of ast routine
                    this.Write(0);                      // Argument	to ast routine
                    this.Write(events.LocalId);         // Client side id of remote	event

                    this.Flush();

                    GenericResponse response = (GenericResponse)this.ReadResponse();

                    // Update event	Remote event ID
                    events.RemoteId = response.ObjectHandle;

                    // Enqueue events in the event manager
                    this.eventManager.QueueEvents(events);
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
示例#17
0
        public override async ValueTask QueueEventsAsync(RemoteEvent remoteEvent, CancellationToken cancellationToken = default)
        {
            try
            {
                if (_eventManager == null)
                {
                    var(auxHandle, ipAddress, portNumber, timeout) = await ConnectionRequestAsync(cancellationToken).ConfigureAwait(false);

                    _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber, timeout);
                    await _eventManager.OpenAsync(cancellationToken).ConfigureAwait(false);

                    var dummy = _eventManager.StartWaitingForEvents(remoteEvent);
                }

                remoteEvent.LocalId++;

                var epb     = remoteEvent.BuildEpb();
                var epbData = epb.ToArray();

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

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

                await Xdr.WriteBufferAsync(epbData, cancellationToken).ConfigureAwait(false);

                await Xdr.WriteAsync(AddressOfAstRoutine, cancellationToken).ConfigureAwait(false);

                await Xdr.WriteAsync(ArgumentToAstRoutine, cancellationToken).ConfigureAwait(false);

                await Xdr.WriteAsync(remoteEvent.LocalId, cancellationToken).ConfigureAwait(false);

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

                var response = (GenericResponse) await ReadResponseAsync(cancellationToken).ConfigureAwait(false);

                remoteEvent.RemoteId = response.ObjectHandle;
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
        }
示例#18
0
        public override async Task QueueEvents(RemoteEvent remoteEvent, AsyncWrappingCommonArgs async)
        {
            try
            {
                if (_eventManager == null)
                {
                    var(auxHandle, ipAddress, portNumber) = await ConnectionRequest(async).ConfigureAwait(false);

                    _eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
                    await _eventManager.Open(async).ConfigureAwait(false);

                    var dummy = _eventManager.WaitForEvents(remoteEvent, new AsyncWrappingCommonArgs(true));
                }

                remoteEvent.LocalId++;

                var epb     = remoteEvent.BuildEpb();
                var epbData = epb.ToArray();

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

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

                await Xdr.WriteBuffer(epbData, async).ConfigureAwait(false);

                await Xdr.Write(AddressOfAstRoutine, async).ConfigureAwait(false);

                await Xdr.Write(ArgumentToAstRoutine, async).ConfigureAwait(false);

                await Xdr.Write(remoteEvent.LocalId, async).ConfigureAwait(false);

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

                var response = (GenericResponse) await ReadResponse(async).ConfigureAwait(false);

                remoteEvent.RemoteId = response.ObjectHandle;
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
        }
示例#19
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;
                    }
                }
            }
        }
		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;
					}
				}
			}
		}
		public void CloseEventManager()
		{
			lock (SyncObject)
			{
				if (_eventManager != null)
				{
					_eventManager.Close();
					_eventManager = null;
				}
			}
		}
		public void QueueEvents(RemoteEvent events)
		{
			if (_eventManager == null)
			{
				string ipAddress = string.Empty;
				int portNumber = 0;
				int auxHandle = 0;

				ConnectionRequest(out auxHandle, out ipAddress, out portNumber);

				_eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
			}

			lock (SyncObject)
			{
				try
				{
					events.LocalId = Interlocked.Increment(ref _eventsId);

					// Enqueue events in the event manager
					_eventManager.QueueEvents(events);

					EventParameterBuffer epb = events.ToEpb();

					XdrStream.Write(IscCodes.op_que_events);
					XdrStream.Write(_handle);                 // Database object id
					XdrStream.WriteBuffer(epb.ToArray());     // Event description block
					XdrStream.Write(0);                       // Address of ast routine
					XdrStream.Write(0);                       // Argument to ast routine
					XdrStream.Write(events.LocalId);          // Client side id of remote event

					XdrStream.Flush();

					GenericResponse response = (GenericResponse)ReadResponse();

					// Update event	Remote event ID
					events.RemoteId = response.ObjectHandle;
				}
				catch (IOException ex)
				{
					throw IscException.ForErrorCode(IscCodes.isc_net_read_err, ex);
				}
			}
		}
示例#23
0
 public void CloseEventManager()
 {
     lock (this.SyncObject)
     {
         if (this.eventManager != null)
         {
             this.eventManager.Close();
             this.eventManager = null;
         }
     }
 }
示例#24
0
        public void QueueEvents(RemoteEvent events)
        {
            if (this.eventManager == null)
            {
                string ipAddress = string.Empty;
                int portNumber = 0;
                int auxHandle = 0;

                this.ConnectionRequest(out auxHandle, out ipAddress, out portNumber);

                this.eventManager = new GdsEventManager(auxHandle, ipAddress, portNumber);
            }

            lock (this.SyncObject)
            {
                try
                {
                    events.LocalId = ++this.eventsId;

                    EventParameterBuffer epb = events.ToEpb();

                    this.Write(IscCodes.op_que_events); // Op codes
                    this.Write(this.handle);			// Database	object id
                    this.WriteBuffer(epb.ToArray());	// Event description block
                    this.Write(0);						// Address of ast routine
                    this.Write(0);						// Argument	to ast routine
                    this.Write(events.LocalId);		    // Client side id of remote	event

                    this.Flush();

                    GenericResponse response = (GenericResponse)this.ReadResponse();

                    // Update event	Remote event ID
                    events.RemoteId = response.ObjectHandle;

                    // Enqueue events in the event manager
                    this.eventManager.QueueEvents(events);
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
示例#25
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;
                    }
                }
            }
        }