コード例 #1
0
ファイル: GdsDatabase.cs プロジェクト: dant02/NETProvider
        private async ValueTask DatabaseInfoAsync(byte[] items, byte[] buffer, int bufferLength, CancellationToken cancellationToken = default)
        {
            try
            {
                await Xdr.WriteAsync(IscCodes.op_info_database, cancellationToken).ConfigureAwait(false);

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

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

                await Xdr.WriteBufferAsync(items, items.Length, cancellationToken).ConfigureAwait(false);

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

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

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

                var responseLength = bufferLength;

                if (response.Data.Length < bufferLength)
                {
                    responseLength = response.Data.Length;
                }

                Buffer.BlockCopy(response.Data, 0, buffer, 0, responseLength);
            }
            catch (IOException ex)
            {
                throw IscException.ForIOException(ex);
            }
        }
コード例 #2
0
ファイル: GdsDatabase.cs プロジェクト: dant02/NETProvider
        protected virtual async ValueTask SendCreateToBufferAsync(DatabaseParameterBufferBase dpb, string database, CancellationToken cancellationToken = default)
        {
            await Xdr.WriteAsync(IscCodes.op_create, cancellationToken).ConfigureAwait(false);

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

            if (!string.IsNullOrEmpty(AuthBlock.Password))
            {
                dpb.Append(IscCodes.isc_dpb_password, AuthBlock.Password);
            }
            await Xdr.WriteBufferAsync(Encoding2.Default.GetBytes(database), cancellationToken).ConfigureAwait(false);

            await Xdr.WriteBufferAsync(dpb.ToArray(), cancellationToken).ConfigureAwait(false);
        }
コード例 #3
0
        protected internal async ValueTask <IResponse> ProcessCryptCallbackResponseIfNeededAsync(IResponse response, byte[] cryptKey, CancellationToken cancellationToken = default)
        {
            while (response is CryptKeyCallbackResponse)
            {
                await Xdr.WriteAsync(IscCodes.op_crypt_key_callback, cancellationToken).ConfigureAwait(false);

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

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

                response = await ReadResponseAsync(cancellationToken).ConfigureAwait(false);
            }
            return(response);
        }
コード例 #4
0
ファイル: GdsDatabase.cs プロジェクト: dant02/NETProvider
        protected override async ValueTask SendAttachToBufferAsync(DatabaseParameterBufferBase dpb, string database, CancellationToken cancellationToken = default)
        {
            await Xdr.WriteAsync(IscCodes.op_attach, cancellationToken).ConfigureAwait(false);

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

            if (!string.IsNullOrEmpty(AuthBlock.Password))
            {
                dpb.Append(IscCodes.isc_dpb_password, AuthBlock.Password);
            }
            dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
            await Xdr.WriteBufferAsync(Encoding.UTF8.GetBytes(database), cancellationToken).ConfigureAwait(false);

            await Xdr.WriteBufferAsync(dpb.ToArray(), cancellationToken).ConfigureAwait(false);
        }
コード例 #5
0
ファイル: GdsDatabase.cs プロジェクト: dant02/NETProvider
        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);
            }
        }
コード例 #6
0
        protected override async ValueTask SendCreateToBufferAsync(DatabaseParameterBufferBase dpb, string database, CancellationToken cancellationToken = default)
        {
            await Xdr.WriteAsync(IscCodes.op_create, cancellationToken).ConfigureAwait(false);

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

            if (!AuthBlock.HasClientData)
            {
                dpb.Append(IscCodes.isc_dpb_auth_plugin_name, AuthBlock.AcceptPluginName);
                dpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.PublicClientData);
            }
            else
            {
                dpb.Append(IscCodes.isc_dpb_specific_auth_data, AuthBlock.ClientData);
            }
            dpb.Append(IscCodes.isc_dpb_utf8_filename, 0);
            await Xdr.WriteBufferAsync(Encoding.UTF8.GetBytes(database), cancellationToken).ConfigureAwait(false);

            await Xdr.WriteBufferAsync(dpb.ToArray(), cancellationToken).ConfigureAwait(false);
        }