예제 #1
0
    public async ValueTask OpenAsync(CancellationToken cancellationToken = default)
    {
        var connection = new GdsConnection(_ipAddress, _portNumber, _timeout);
        await connection.ConnectAsync(cancellationToken).ConfigureAwait(false);

        _database = new GdsDatabase(connection);
    }
        private static IDatabase CreateManagedDatabase(FbConnectionString options)
        {
            var connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.PacketSize, Charset.GetCharset(options.Charset));

            connection.Connect();
            connection.Identify(options.Database);

            switch (connection.ProtocolVersion)
            {
            case IscCodes.PROTOCOL_VERSION13:
                return(new Client.Managed.Version13.GdsDatabase(connection));

            case IscCodes.PROTOCOL_VERSION12:
                return(new Client.Managed.Version12.GdsDatabase(connection));

            case IscCodes.PROTOCOL_VERSION11:
                return(new Client.Managed.Version11.GdsDatabase(connection));

            case IscCodes.PROTOCOL_VERSION10:
                return(new Client.Managed.Version10.GdsDatabase(connection));

            default:
                throw UnsupportedProtocolException();
            }
        }
    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 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;
            }
        }
    }
예제 #5
0
    public void Open()
    {
        var connection = new GdsConnection(_ipAddress, _portNumber, _timeout);

        connection.Connect();
        _database = new GdsDatabase(connection);
    }
예제 #6
0
 public GdsDatabase(GdsConnection connection)
 {
     _connection = connection;
     _handle     = -1;
     Charset     = Charset.DefaultCharset;
     Dialect     = 3;
     PacketSize  = 8192;
 }
    public AuthBlock(GdsConnection connection, string user, string password, WireCryptOption wireCrypt)
    {
        _srp256 = new Srp256Client();
        _srp    = new SrpClient();
        _sspi   = new SspiHelper();

        Connection = connection;
        User       = user;
        Password   = password;
        WireCrypt  = wireCrypt;
    }
예제 #8
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;
        }
    }
예제 #9
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;
        }
    }
        private static IServiceManager CreateManagedServiceManager(FbConnectionString options)
        {
            var connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.PacketSize, Charset.GetCharset(options.Charset));

            connection.Connect();
            connection.Identify(!string.IsNullOrEmpty(options.Database) ? options.Database : string.Empty);

            switch (connection.ProtocolVersion)
            {
            case IscCodes.PROTOCOL_VERSION13:
            case IscCodes.PROTOCOL_VERSION12:
            case IscCodes.PROTOCOL_VERSION11:
            case IscCodes.PROTOCOL_VERSION10:
                return(new Client.Managed.Version10.GdsServiceManager(connection));

            default:
                throw new NotSupportedException("Protocol not supported.");
            }
        }
예제 #11
0
        private static IServiceManager CreateManagedServiceManager(ConnectionString options)
        {
            var connection = new GdsConnection(options.UserID, options.Password, options.DataSource, options.Port, options.PacketSize, Charset.GetCharset(options.Charset), options.Compression, FbWireCryptToWireCryptOption(options.WireCrypt));

            connection.Connect();
            connection.Identify(!string.IsNullOrEmpty(options.Database) ? options.Database : string.Empty);
            switch (connection.ProtocolVersion)
            {
            case IscCodes.PROTOCOL_VERSION13:
                return(new Client.Managed.Version13.GdsServiceManager(connection));

            case IscCodes.PROTOCOL_VERSION12:
                return(new Client.Managed.Version12.GdsServiceManager(connection));

            case IscCodes.PROTOCOL_VERSION11:
                return(new Client.Managed.Version11.GdsServiceManager(connection));

            case IscCodes.PROTOCOL_VERSION10:
                return(new Client.Managed.Version10.GdsServiceManager(connection));

            default:
                throw UnsupportedProtocolException();
            }
        }
예제 #12
0
 public GdsDatabase(GdsConnection connection)
     : base(connection)
 {
     DeferredPackets = new Queue <Action <IResponse> >();
 }
 protected override Version10.GdsDatabase CreateDatabase(GdsConnection connection)
 {
     return(new GdsDatabase(connection));
 }
예제 #14
0
 public GdsDatabase(GdsConnection connection)
     : base(connection)
 {
 }
 public GdsServiceManager(GdsConnection connection)
     : base(connection)
 {
 }
 public string NormalizeLoginTest(string login)
 {
     return(GdsConnection.NormalizeLogin(login));
 }
예제 #17
0
 public GdsDatabase(GdsConnection connection)
     : base(connection)
 {
     DeferredPackets = new Queue <Func <IResponse, AsyncWrappingCommonArgs, Task> >();
 }
 protected virtual GdsDatabase CreateDatabase(GdsConnection connection)
 {
     return(new GdsDatabase(connection));
 }
 public GdsServiceManager(GdsConnection connection)
 {
     _connection = connection;
     _database   = CreateDatabase(_connection);
     RewireWarningMessage();
 }