当前位置: 首页>>代码示例>>C#>>正文


C# TdsParserStateObject.WritePacket方法代码示例

本文整理汇总了C#中System.Data.SqlClient.TdsParserStateObject.WritePacket方法的典型用法代码示例。如果您正苦于以下问题:C# TdsParserStateObject.WritePacket方法的具体用法?C# TdsParserStateObject.WritePacket怎么用?C# TdsParserStateObject.WritePacket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.TdsParserStateObject的用法示例。


在下文中一共展示了TdsParserStateObject.WritePacket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteBulkCopyDone

        internal Task WriteBulkCopyDone(TdsParserStateObject stateObj)
        {
            // Write DONE packet
            //
            if (!(State == TdsParserState.OpenNotLoggedIn || State == TdsParserState.OpenLoggedIn))
            {
                throw ADP.ClosedConnectionError();
            }
            stateObj.WriteByte(TdsEnums.SQLDONE);
            WriteShort(0, stateObj);
            WriteShort(0, stateObj);
            WriteInt(0, stateObj);

            stateObj._pendingData = true;
            stateObj._messageStatus = 0;
            return stateObj.WritePacket(TdsEnums.HARDFLUSH);
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:17,代码来源:TdsParser.cs

示例2: TdsExecuteTransactionManagerRequest


//.........这里部分代码省略.........
                        // #1 will occur on standard BeginTransactionAPI call.  #2 should only occur if
                        // t-sql transaction started followed by a call to SqlConnection.BeginTransaction.
                        // Any other state is unknown.
                        if (_currentTransaction != transaction)
                        {
                            Debug.Assert(_currentTransaction == null || true == _fResetConnection, "We should not have a current Tx at this point");
                            PendingTransaction = transaction;
                        }

                        stateObj.WriteByte((byte)isoLevel);

                        stateObj.WriteByte((byte)(transactionName.Length * 2)); // Write number of bytes (unicode string).
                        WriteString(transactionName, stateObj);
                        break;
                    case TdsEnums.TransactionManagerRequestType.Commit:

                        Debug.Assert(transactionName.Length == 0, "Should not have a transaction name on Commit");
                        stateObj.WriteByte((byte)0); // No xact name

                        stateObj.WriteByte(0);  // No flags

                        Debug.Assert(isoLevel == TdsEnums.TransactionManagerIsolationLevel.Unspecified, "Should not have isolation level other than unspecified on Commit!");
                        // WriteByte((byte) 0, stateObj); // IsolationLevel
                        // WriteByte((byte) 0, stateObj); // No begin xact name
                        break;
                    case TdsEnums.TransactionManagerRequestType.Rollback:

                        stateObj.WriteByte((byte)(transactionName.Length * 2)); // Write number of bytes (unicode string).
                        WriteString(transactionName, stateObj);

                        stateObj.WriteByte(0);  // No flags

                        Debug.Assert(isoLevel == TdsEnums.TransactionManagerIsolationLevel.Unspecified, "Should not have isolation level other than unspecified on Commit!");
                        // WriteByte((byte) 0, stateObj); // IsolationLevel
                        // WriteByte((byte) 0, stateObj); // No begin xact name
                        break;
                    case TdsEnums.TransactionManagerRequestType.Save:

                        stateObj.WriteByte((byte)(transactionName.Length * 2)); // Write number of bytes (unicode string).
                        WriteString(transactionName, stateObj);
                        break;
                    default:
                        Debug.Assert(false, "Unexpected TransactionManagerRequest");
                        break;
                }

                Task writeTask = stateObj.WritePacket(TdsEnums.HARDFLUSH);
                Debug.Assert(writeTask == null, "Writes should not pend when writing sync");
                stateObj._pendingData = true;
                stateObj._messageStatus = 0;

                SqlDataReader dtcReader = null;
                stateObj.SniContext = SniContext.Snix_Read;
                if (returnReader)
                {
                    dtcReader = new SqlDataReader(null, CommandBehavior.Default);
                    Debug.Assert(this == stateObj.Parser, "different parser");
#if DEBUG
                    // Remove the current owner of stateObj - otherwise we will hit asserts
                    stateObj.Owner = null;
#endif
                    dtcReader.Bind(stateObj);

                    // force consumption of metadata
                    _SqlMetaDataSet metaData = dtcReader.MetaData;
                }
                else
                {
                    Run(RunBehavior.UntilDone, null, null, null, stateObj);
                }


                return dtcReader;
            }
            catch (Exception e)
            {
                if (!ADP.IsCatchableExceptionType(e))
                {
                    throw;
                }

                FailureCleanup(stateObj, e);

                throw;
            }
            finally
            {
                // SQLHotfix 50000518
                // make sure we don't leave temporary fields set when leaving this function
                _pendingTransaction = null;

                _asyncWrite = hadAsyncWrites;

                if (!callerHasConnectionLock)
                {
                    _connHandler.ThreadHasParserLockForClose = false;
                    _connHandler._parserLock.Release();
                }
            }
        }
开发者ID:nnyamhon,项目名称:corefx,代码行数:101,代码来源:TdsParser.cs

示例3: WriteByteArray

 internal void WriteByteArray(byte[] b, int len, int offsetBuffer, TdsParserStateObject stateObj)
 {
     int srcOffset = offsetBuffer;
     while (len > 0)
     {
         if ((stateObj._outBytesUsed + len) > stateObj._outBuff.Length)
         {
             int count = stateObj._outBuff.Length - stateObj._outBytesUsed;
             Buffer.BlockCopy(b, srcOffset, stateObj._outBuff, stateObj._outBytesUsed, count);
             srcOffset += count;
             stateObj._outBytesUsed += count;
             if (stateObj._outBytesUsed == stateObj._outBuff.Length)
             {
                 stateObj.WritePacket(0);
             }
             len -= count;
         }
         else
         {
             Buffer.BlockCopy(b, srcOffset, stateObj._outBuff, stateObj._outBytesUsed, len);
             stateObj._outBytesUsed += len;
             return;
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:TdsParser.cs

示例4: WriteByte

 internal void WriteByte(byte b, TdsParserStateObject stateObj)
 {
     if (stateObj._outBytesUsed == stateObj._outBuff.Length)
     {
         stateObj.WritePacket(0);
     }
     stateObj._outBuff[stateObj._outBytesUsed++] = b;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:TdsParser.cs

示例5: WriteBulkCopyDone

 internal void WriteBulkCopyDone(TdsParserStateObject stateObj)
 {
     this.WriteByte(0xfd, stateObj);
     this.WriteShort(0, stateObj);
     this.WriteShort(0, stateObj);
     this.WriteInt(0, stateObj);
     stateObj.WritePacket(1);
     stateObj._pendingData = true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:TdsParser.cs

示例6: TdsExecuteTransactionManagerRequest

        internal SqlDataReader TdsExecuteTransactionManagerRequest(byte[] buffer, TdsEnums.TransactionManagerRequestType request, string transactionName, TdsEnums.TransactionManagerIsolationLevel isoLevel, int timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, bool isDelegateControlRequest)
        {
            SqlDataReader reader2;
            if ((TdsParserState.Broken == this.State) || (this.State == TdsParserState.Closed))
            {
                return null;
            }
            bool lockTaken = false;
            lock (this._connHandler)
            {
                try
                {
                    try
                    {
                        if (this._isYukon && !this.MARSOn)
                        {
                            Monitor.Enter(this._physicalStateObj, ref lockTaken);
                        }
                        if (!isDelegateControlRequest)
                        {
                            this._connHandler.CheckEnlistedTransactionBinding();
                        }
                        stateObj._outputMessageType = 14;
                        stateObj.SetTimeoutSeconds(timeout);
                        stateObj.SniContext = SniContext.Snix_Execute;
                        if (this._isYukon)
                        {
                            this.WriteMarsHeader(stateObj, this._currentTransaction);
                        }
                        this.WriteShort((short) request, stateObj);
                        bool flag = false;
                        switch (request)
                        {
                            case TdsEnums.TransactionManagerRequestType.GetDTCAddress:
                                this.WriteShort(0, stateObj);
                                flag = true;
                                goto Label_0193;

                            case TdsEnums.TransactionManagerRequestType.Propagate:
                                if (buffer == null)
                                {
                                    break;
                                }
                                this.WriteShort(buffer.Length, stateObj);
                                this.WriteByteArray(buffer, buffer.Length, 0, stateObj);
                                goto Label_0193;

                            case TdsEnums.TransactionManagerRequestType.Begin:
                                if (this._currentTransaction != transaction)
                                {
                                    this.PendingTransaction = transaction;
                                }
                                this.WriteByte((byte) isoLevel, stateObj);
                                this.WriteByte((byte) (transactionName.Length * 2), stateObj);
                                this.WriteString(transactionName, stateObj);
                                goto Label_0193;

                            case TdsEnums.TransactionManagerRequestType.Commit:
                                this.WriteByte(0, stateObj);
                                this.WriteByte(0, stateObj);
                                goto Label_0193;

                            case TdsEnums.TransactionManagerRequestType.Rollback:
                                this.WriteByte((byte) (transactionName.Length * 2), stateObj);
                                this.WriteString(transactionName, stateObj);
                                this.WriteByte(0, stateObj);
                                goto Label_0193;

                            case TdsEnums.TransactionManagerRequestType.Save:
                                this.WriteByte((byte) (transactionName.Length * 2), stateObj);
                                this.WriteString(transactionName, stateObj);
                                goto Label_0193;

                            default:
                                goto Label_0193;
                        }
                        this.WriteShort(0, stateObj);
                    Label_0193:
                        stateObj.WritePacket(1);
                        stateObj._pendingData = true;
                        SqlDataReader reader = null;
                        stateObj.SniContext = SniContext.Snix_Read;
                        if (flag)
                        {
                            reader = new SqlDataReader(null, CommandBehavior.Default);
                            reader.Bind(stateObj);
                            _SqlMetaDataSet metaData = reader.MetaData;
                        }
                        else
                        {
                            this.Run(RunBehavior.UntilDone, null, null, null, stateObj);
                        }
                        if ((request == TdsEnums.TransactionManagerRequestType.Begin) || (request == TdsEnums.TransactionManagerRequestType.Propagate))
                        {
                            if ((transaction != null) && (transaction.TransactionId == this._retainedTransactionId))
                            {
                                return reader;
                            }
                            this._retainedTransactionId = 0L;
                        }
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:TdsParser.cs


注:本文中的System.Data.SqlClient.TdsParserStateObject.WritePacket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。