private static bool OnRetryCommand(IAsyncResult childPtr) { SqlCommandAsyncResult asyncState = (SqlCommandAsyncResult)childPtr.AsyncState; asyncState.sqlDataReader = End(childPtr); return(true); }
static bool OnRetryCommand(IAsyncResult childPtr) { SqlCommandAsyncResult parentPtr = (SqlCommandAsyncResult)(childPtr.AsyncState); parentPtr.sqlDataReader = SqlCommandAsyncResult.End(childPtr); return(true); }
private static bool SqlCommandAsyncResultCallback(IAsyncResult result) { SqlWorkflowInstanceStoreAsyncResult asyncState = (SqlWorkflowInstanceStoreAsyncResult)result.AsyncState; Exception exception = null; bool flag = true; try { using (asyncState.sqlCommand) { using (SqlDataReader reader = SqlCommandAsyncResult.End(result)) { exception = asyncState.ProcessSqlResult(reader); } } } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } Guid instanceId = (asyncState.InstancePersistenceContext != null) ? asyncState.InstancePersistenceContext.InstanceView.InstanceId : Guid.Empty; exception = new InstancePersistenceCommandException(asyncState.InstancePersistenceCommand.Name, instanceId, exception2); } if (exception is InstanceAlreadyLockedToOwnerException) { InstanceAlreadyLockedToOwnerException exception3 = (InstanceAlreadyLockedToOwnerException)exception; long instanceVersion = exception3.InstanceVersion; if (!asyncState.InstancePersistenceContext.InstanceView.IsBoundToInstance) { asyncState.InstancePersistenceContext.BindInstance(exception3.InstanceId); } IAsyncResult result3 = asyncState.InstancePersistenceContext.BeginBindReclaimedLock(instanceVersion, asyncState.TimeoutHelper.RemainingTime(), asyncState.PrepareAsyncCompletion(onBindReclaimed), asyncState); if (!asyncState.SyncContinue(result3)) { flag = false; } return(flag); } if (exception == null) { return(flag); } if (asyncState.sqlCommand.Connection != null) { asyncState.sqlCommand.Connection.Close(); } asyncState.TraceException(exception); throw FxTrace.Exception.AsError(exception); }
void StartOperation() { Guid instanceId = (this.InstancePersistenceContext != null) ? this.InstancePersistenceContext.InstanceView.InstanceId : Guid.Empty; Exception delayedException = null; try { this.sqlCommand = new SqlCommand(); this.GenerateSqlCommand(this.sqlCommand); this.sqlCommand.CommandText = this.GetSqlCommandText(); this.sqlCommand.CommandType = this.GetSqlCommandType(); StoreUtilities.TraceSqlCommand(this.sqlCommand, true); SqlCommandAsyncResult sqlCommandResult = new SqlCommandAsyncResult(this.sqlCommand, this.ConnectionString, (this.InstancePersistenceContext != null) ? this.InstancePersistenceContext.EventTraceActivity : null, this.DependentTransaction, this.TimeoutHelper.RemainingTime(), 0, this.maximumRetries, PrepareAsyncCompletion(onSqlCommandAsyncResultCallback), this); sqlCommandResult.StartCommand(); if (!SyncContinue(sqlCommandResult)) { return; } } catch (InstancePersistenceException instancePersistenceException) { delayedException = instancePersistenceException; } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } delayedException = new InstancePersistenceCommandException(this.InstancePersistenceCommand.Name, instanceId, exception); } if (delayedException != null) { if (this.sqlCommand.Connection != null) { this.sqlCommand.Connection.Close(); } this.sqlCommand.Dispose(); this.TraceException(delayedException); } this.Complete(false, delayedException); }
private void StartOperation() { Guid instanceId = (this.InstancePersistenceContext != null) ? this.InstancePersistenceContext.InstanceView.InstanceId : Guid.Empty; Exception exception = null; try { this.sqlCommand = new SqlCommand(); this.GenerateSqlCommand(this.sqlCommand); this.sqlCommand.CommandText = this.GetSqlCommandText(); this.sqlCommand.CommandType = this.GetSqlCommandType(); StoreUtilities.TraceSqlCommand(this.sqlCommand, true); SqlCommandAsyncResult result = new SqlCommandAsyncResult(this.sqlCommand, this.ConnectionString, this.DependentTransaction, this.TimeoutHelper.RemainingTime(), 0, this.Store.MaxConnectionRetries, base.PrepareAsyncCompletion(onSqlCommandAsyncResultCallback), this); result.StartCommand(); if (!base.SyncContinue(result)) { return; } } catch (InstancePersistenceException exception2) { exception = exception2; } catch (Exception exception3) { if (Fx.IsFatal(exception3)) { throw; } exception = new InstancePersistenceCommandException(this.InstancePersistenceCommand.Name, instanceId, exception3); } if (exception != null) { if (this.sqlCommand.Connection != null) { this.sqlCommand.Connection.Close(); } this.sqlCommand.Dispose(); this.TraceException(exception); } base.Complete(false, exception); }
private static void StartCommandCallback(object state) { SqlCommandAsyncResult result = (SqlCommandAsyncResult)state; try { result.StartCommandInternal(false); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } if (result.sqlCommand.Connection != null) { result.sqlCommand.Connection.Close(); } result.Complete(false, exception); } }
static void StartCommandCallback(object state) { SqlCommandAsyncResult thisPtr = (SqlCommandAsyncResult)state; try { // this can throw on the [....] path - we need to signal the callback thisPtr.StartCommandInternal(false); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } if (thisPtr.sqlCommand.Connection != null) { thisPtr.sqlCommand.Connection.Close(); } thisPtr.Complete(false, e); } }
static bool OnExecuteReader(IAsyncResult result) { SqlCommandAsyncResult thisPtr = (SqlCommandAsyncResult)(result.AsyncState); return(thisPtr.CompleteExecuteReader(result)); }
public static SqlDataReader End(IAsyncResult result) { SqlCommandAsyncResult SqlCommandAsyncResult = AsyncResult.End <SqlCommandAsyncResult>(result); return(SqlCommandAsyncResult.sqlDataReader); }
private static bool OnExecuteReader(IAsyncResult result) { SqlCommandAsyncResult asyncState = (SqlCommandAsyncResult)result.AsyncState; return(asyncState.CompleteExecuteReader(result)); }
static bool SqlCommandAsyncResultCallback(IAsyncResult result) { SqlWorkflowInstanceStoreAsyncResult thisPtr = (SqlWorkflowInstanceStoreAsyncResult)result.AsyncState; Exception delayedException = null; bool completeFlag = true; try { using (thisPtr.sqlCommand) { using (SqlDataReader reader = SqlCommandAsyncResult.End(result)) { delayedException = thisPtr.ProcessSqlResult(reader); } } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } Guid instanceId = (thisPtr.InstancePersistenceContext != null) ? thisPtr.InstancePersistenceContext.InstanceView.InstanceId : Guid.Empty; delayedException = new InstancePersistenceCommandException(thisPtr.InstancePersistenceCommand.Name, instanceId, exception); } if (delayedException is InstanceAlreadyLockedToOwnerException) { InstanceAlreadyLockedToOwnerException alreadyLockedException = (InstanceAlreadyLockedToOwnerException)delayedException; long reclaimLockAtVersion = alreadyLockedException.InstanceVersion; if (!thisPtr.InstancePersistenceContext.InstanceView.IsBoundToInstance) { thisPtr.InstancePersistenceContext.BindInstance(alreadyLockedException.InstanceId); } IAsyncResult bindReclaimedAsyncResult = thisPtr.InstancePersistenceContext.BeginBindReclaimedLock(reclaimLockAtVersion, thisPtr.TimeoutHelper.RemainingTime(), thisPtr.PrepareAsyncCompletion(SqlWorkflowInstanceStoreAsyncResult.onBindReclaimed), thisPtr); if (!thisPtr.SyncContinue(bindReclaimedAsyncResult)) { completeFlag = false; } } else if (delayedException != null) { if (thisPtr.sqlCommand.Connection != null) { thisPtr.sqlCommand.Connection.Close(); } bool handled = false; thisPtr.OnSqlException(delayedException, out handled); if (!handled) { thisPtr.TraceException(delayedException); throw FxTrace.Exception.AsError(delayedException); } } if (completeFlag) { completeFlag = thisPtr.OnSqlProcessingComplete(); } return(completeFlag); }