コード例 #1
0
ファイル: NpgsqlCopyOutState.cs プロジェクト: dstimac/revenj
		/// <summary>
		/// Called from NpgsqlState.ProcessBackendResponses upon CopyOutResponse.
		/// If CopyStream is already set, it is used to write data received from server, after which the copy ends.
		/// Otherwise CopyStream is set to a readable NpgsqlCopyOutStream that receives data from server.
		/// </summary>
		protected override void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
		{
			_copyFormat = copyFormat;
			Stream userFeed = context.Mediator.CopyStream;
			if (userFeed == null)
			{
				context.Mediator.CopyStream = new NpgsqlCopyOutStream(context);
			}
			else
			{
				byte[] buf;
				while ((buf = GetCopyData(context)) != null)
				{
					userFeed.Write(buf, 0, buf.Length);
				}
				userFeed.Close();
			}
		}
コード例 #2
0
ファイル: NpgsqlCopyOutState.cs プロジェクト: zhxjdwh/revenj
        /// <summary>
        /// Called from NpgsqlState.ProcessBackendResponses upon CopyOutResponse.
        /// If CopyStream is already set, it is used to write data received from server, after which the copy ends.
        /// Otherwise CopyStream is set to a readable NpgsqlCopyOutStream that receives data from server.
        /// </summary>
        protected override void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
        {
            _copyFormat = copyFormat;
            Stream userFeed = context.Mediator.CopyStream;

            if (userFeed == null)
            {
                context.Mediator.CopyStream = new NpgsqlCopyOutStream(context);
            }
            else
            {
                byte[] buf;
                while ((buf = GetCopyData(context)) != null)
                {
                    userFeed.Write(buf, 0, buf.Length);
                }
                userFeed.Close();
            }
        }
コード例 #3
0
ファイル: NpgsqlCopyInState.cs プロジェクト: dstimac/revenj
		/// <summary>
		/// Called from NpgsqlState.ProcessBackendResponses upon CopyInResponse.
		/// If CopyStream is already set, it is used to read data to push to server, after which the copy is completed.
		/// Otherwise CopyStream is set to a writable NpgsqlCopyInStream that calls SendCopyData each time it is written to.
		/// </summary>
		protected override void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
		{
			_copyFormat = copyFormat;
			Stream userFeed = context.Mediator.CopyStream;
			if (userFeed == null)
			{
				context.Mediator.CopyStream = new NpgsqlCopyInStream(context);
			}
			else
			{
				// copy all of user feed to server at once
				int bufsiz = context.Mediator.CopyBufferSize;
				byte[] buf = new byte[bufsiz];
				int len;
				while ((len = userFeed.Read(buf, 0, bufsiz)) > 0)
				{
					SendCopyData(context, buf, 0, len);
				}
				SendCopyDone(context);
			}
		}
コード例 #4
0
ファイル: NpgsqlCopyInState.cs プロジェクト: zhxjdwh/revenj
        /// <summary>
        /// Called from NpgsqlState.ProcessBackendResponses upon CopyInResponse.
        /// If CopyStream is already set, it is used to read data to push to server, after which the copy is completed.
        /// Otherwise CopyStream is set to a writable NpgsqlCopyInStream that calls SendCopyData each time it is written to.
        /// </summary>
        protected override void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
        {
            _copyFormat = copyFormat;
            Stream userFeed = context.Mediator.CopyStream;

            if (userFeed == null)
            {
                context.Mediator.CopyStream = new NpgsqlCopyInStream(context);
            }
            else
            {
                // copy all of user feed to server at once
                int    bufsiz = context.Mediator.CopyBufferSize;
                byte[] buf    = new byte[bufsiz];
                int    len;
                while ((len = userFeed.Read(buf, 0, bufsiz)) > 0)
                {
                    SendCopyData(context, buf, 0, len);
                }
                SendCopyDone(context);
            }
        }
コード例 #5
0
        // COPY methods

        protected virtual void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
        {
            throw new InvalidOperationException("Internal Error! " + this);
        }
コード例 #6
0
ファイル: NpgsqlState.cs プロジェクト: instant-hrvoje/revenj
 // COPY methods
 protected virtual void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
 {
     throw new InvalidOperationException("Internal Error! " + this);
 }