public SNIError(SNIProviders provider, uint nativeError, uint sniErrorCode, string errorMessage) { this.lineNumber = 0; this.function = string.Empty; this.provider = provider; this.nativeError = nativeError; this.sniError = sniErrorCode; this.errorMessage = errorMessage; this.exception = null; }
public SNIError(SNIProviders provider, uint sniErrorCode, Exception sniException) { this.lineNumber = 0; this.function = string.Empty; this.provider = provider; this.nativeError = 0; this.sniError = sniErrorCode; this.errorMessage = string.Empty; this.exception = sniException; }
public SNIError(SNIProviders provider, SNIErrorCode sniErrorCode, Exception sniException) { Debug.Assert(sniException != null); this.provider = provider; this.nativeError = 0; this.sniError = sniErrorCode; this.errorMessage = null; this.exception = sniException; }
public SNIError(SNIProviders provider, uint sniErrorCode, Exception sniException, uint nativeErrorCode = 0) { lineNumber = 0; function = string.Empty; this.provider = provider; nativeError = nativeErrorCode; sniError = sniErrorCode; errorMessage = string.Empty; exception = sniException; }
public SNIError(SNIProviders provider, uint nativeError, uint sniErrorCode, string errorMessage) { this.lineNumber = 0; this.function = ""; this.provider = provider; this.nativeError = nativeError; this.sniError = sniErrorCode; // Hardcode "TCP Provider" to keep TDS parser happy this.errorMessage = "TCP Provider: " + errorMessage + Environment.NewLine; }
public SNIError(SNIProviders provider, uint nativeError, SNIErrorCode sniErrorCode, string errorMessage) { Debug.Assert(errorMessage != null); Debug.Assert((errorMessage.Length > 0) || sniErrorCode != 0); this.provider = provider; this.nativeError = nativeError; this.sniError = sniErrorCode; this.errorMessage = errorMessage; this.exception = null; }
/// <summary> /// Write data to a stream asynchronously /// </summary> /// <param name="stream">Stream to write to</param> public void WriteToStreamAsync(Stream stream, SNIAsyncCallback callback, SNIProviders provider, bool disposeAfterWriteAsync = false) { // Treat local function as a static and pass all params otherwise as async will allocate async Task WriteToStreamAsync(SNIPacket packet, SNIAsyncCallback cb, SNIProviders providers, bool disposeAfter, Task task) { uint status = TdsEnums.SNI_SUCCESS; try { await task.ConfigureAwait(false); } catch (Exception e) { SNILoadHandle.SingletonInstance.LastError = new SNIError(providers, SNICommon.InternalExceptionError, e); status = TdsEnums.SNI_ERROR; } cb(packet, status); if (disposeAfter) { packet.Release(); } } Task t = stream.WriteAsync(_data, _headerLength, _dataLength, CancellationToken.None); if ((t.Status & TaskStatus.RanToCompletion) != 0) { // Read the result to register as complete for the Task t.GetAwaiter().GetResult(); callback(this, TdsEnums.SNI_SUCCESS); if (disposeAfterWriteAsync) { Release(); } // Completed return; } // Not complete or error call the async local function to complete _ = WriteToStreamAsync(this, callback, provider, disposeAfterWriteAsync, t); }
/// <summary> /// Write data to a stream asynchronously /// </summary> /// <param name="stream">Stream to write to</param> /// <param name="callback"></param> /// <param name="provider"></param> /// <param name="disposeAfterWriteAsync"></param> public void WriteToStreamAsync(Stream stream, SNIAsyncCallback callback, SNIProviders provider, bool disposeAfterWriteAsync = false) { // Treat local function as a static and pass all params otherwise as async will allocate async Task WriteToStreamAsync(SNIPacket packet, SNIAsyncCallback cb, SNIProviders providers, bool disposeAfter, ValueTask valueTask) { uint status = TdsEnums.SNI_SUCCESS; try { await valueTask.ConfigureAwait(false); } catch (Exception e) { SNILoadHandle.SingletonInstance.LastError = new SNIError(providers, SNICommon.InternalExceptionError, e); status = TdsEnums.SNI_ERROR; } cb(packet, status); if (disposeAfter) { packet.Dispose(); } } ValueTask vt = stream.WriteAsync(new Memory <byte>(_data, 0, _length), CancellationToken.None); if (vt.IsCompletedSuccessfully) { // Read the result to register as complete for the ValueTask vt.GetAwaiter().GetResult(); callback(this, TdsEnums.SNI_SUCCESS); if (disposeAfterWriteAsync) { Dispose(); } // Completed return; } // Not complete or error call the async local function to complete _ = WriteToStreamAsync(this, callback, provider, disposeAfterWriteAsync, vt); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="sniError">SNI error code</param> /// <param name="sniException">SNI Exception</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint sniError, Exception sniException) { SqlClientEventSource.Log.SNITraceEvent("<sc.SNI.SNICommon. ReportSNIError |SNI|ERR > Provider ={0}, SNI Error ={1}, Exception ={2}", provider, sniError, sniException.Message); return(ReportSNIError(new SNIError(provider, sniError, sniException))); }
private void ReportSNIError(SNIProviders provider) { SNILoadHandle.SingletonInstance.LastError = new SNIError(provider, 0, SNICommon.InvalidConnStringError, string.Empty); IsBadDataSource = true; }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="nativeError">Native error code</param> /// <param name="sniError">SNI error code</param> /// <param name="errorMessage">Error message</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uint sniError, string errorMessage) { SNILoadHandle.SingletonInstance.LastError = new SNIError(provider, nativeError, sniError, errorMessage); return(TdsEnums.SNI_ERROR); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="nativeError">Native error code</param> /// <param name="sniError">SNI error code</param> /// <param name="errorMessage">Error message</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uint sniError, string errorMessage) { SqlClientEventSource.Log.SNITraceEvent("<sc.SNI.SNICommon. ReportSNIError |SNI|ERR > Provider ={0}, native Error ={1}, SNI Error ={2}, Error Message ={3}", provider, nativeError, sniError, errorMessage); return(ReportSNIError(new SNIError(provider, nativeError, sniError, errorMessage))); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="nativeError">Native error code</param> /// <param name="sniError">SNI error code</param> /// <param name="errorMessage">Error message</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uint sniError, string errorMessage) { SNILoadHandle.SingletonInstance.LastError = new SNIError(provider, nativeError, sniError, errorMessage); return TdsEnums.SNI_ERROR; }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="sniError">SNI error code</param> /// <param name="sniException">SNI Exception</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint sniError, Exception sniException) { return ReportSNIError(new SNIError(provider, sniError, sniException)); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="sniError">SNI error code</param> /// <param name="sniException">SNI Exception</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint sniError, Exception sniException) { return(ReportSNIError(new SNIError(provider, sniError, sniException))); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="nativeError">Native error code</param> /// <param name="sniError">SNI error code</param> /// <param name="errorMessage">Error message</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uint sniError, string errorMessage) { return(ReportSNIError(new SNIError(provider, nativeError, sniError, errorMessage))); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="sniError">SNI error code</param> /// <param name="sniException">SNI Exception</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint sniError, Exception sniException) { SqlClientEventSource.Log.TrySNITraceEvent(s_className, EventType.ERR, "Provider = {0}, SNI Error = {1}, Exception = {2}", args0: provider, args1: sniError, args2: sniException?.Message); return(ReportSNIError(new SNIError(provider, sniError, sniException))); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="nativeError">Native error code</param> /// <param name="sniError">SNI error code</param> /// <param name="errorMessage">Error message</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uint sniError, string errorMessage) { return ReportSNIError(new SNIError(provider, nativeError, sniError, errorMessage)); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="nativeError">Native error code</param> /// <param name="sniError">SNI error code</param> /// <param name="errorMessage">Error message</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uint sniError, string errorMessage) { SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNICommon), EventType.ERR, "Provider = {0}, native Error = {1}, SNI Error = {2}, Error Message = {3}", args0: provider, args1: nativeError, args2: sniError, args3: errorMessage); return(ReportSNIError(new SNIError(provider, nativeError, sniError, errorMessage))); }
/// <summary> /// Write data to a stream asynchronously /// </summary> /// <param name="stream">Stream to write to</param> public async void WriteToStreamAsync(Stream stream, SNIAsyncCallback callback, SNIProviders provider) { uint status = TdsEnums.SNI_SUCCESS; try { await stream.WriteAsync(_data, 0, _length, CancellationToken.None).ConfigureAwait(false); } catch (Exception e) { SNILoadHandle.SingletonInstance.LastError = new SNIError(provider, SNICommon.InternalExceptionError, e); status = TdsEnums.SNI_ERROR; } callback(this, status); }
/// <summary> /// Sets last error encountered for SNI /// </summary> /// <param name="provider">SNI provider</param> /// <param name="sniError">SNI error code</param> /// <param name="sniException">SNI Exception</param> /// <param name="nativeErrorCode">Native SNI error code</param> /// <returns></returns> internal static uint ReportSNIError(SNIProviders provider, uint sniError, Exception sniException, uint nativeErrorCode = 0) { SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNICommon), EventType.ERR, "Provider = {0}, SNI Error = {1}, Exception = {2}", args0: provider, args1: sniError, args2: sniException?.Message); return(ReportSNIError(new SNIError(provider, sniError, sniException, nativeErrorCode))); }