private static void Finally(AsyncResult result, Exception currentException) { SqlWorkflowInstanceStoreAsyncResult result2 = result as SqlWorkflowInstanceStoreAsyncResult; try { if (result2.DependentTransaction != null) { using (result2.DependentTransaction) { result2.DependentTransaction.Complete(); } } } catch (TransactionException) { if (currentException == null) { throw; } } finally { result2.OnCommandCompletion(); result2.ClearMembers(); StoreUtilities.TraceSqlCommand(result2.sqlCommand, false); } }
internal IAsyncResult BeginTryCommandInternal(InstancePersistenceContext context, InstancePersistenceCommand command, TimeSpan timeout, AsyncCallback callback, object state) { SqlWorkflowInstanceStoreAsyncResult result = null; if (command is SaveWorkflowCommand) { result = new SaveWorkflowAsyncResult(context, command, this, this.storeLock, Transaction.Current, timeout, callback, state); } else if (command is TryLoadRunnableWorkflowCommand) { result = new TryLoadRunnableWorkflowAsyncResult(context, command, this, this.storeLock, Transaction.Current, timeout, callback, state); } else if (command is LoadWorkflowCommand) { result = new LoadWorkflowAsyncResult(context, command, this, this.storeLock, Transaction.Current, timeout, callback, state); } else if (command is LoadWorkflowByInstanceKeyCommand) { result = new LoadWorkflowByKeyAsyncResult(context, command, this, this.storeLock, Transaction.Current, timeout, callback, state); } else if (command is ExtendLockCommand) { result = new ExtendLockAsyncResult(null, command, this, this.storeLock, null, timeout, callback, state); } else if (command is DetectRunnableInstancesCommand) { result = new DetectRunnableInstancesAsyncResult(null, command, this, this.storeLock, null, timeout, callback, state); } else if (command is DetectActivatableWorkflowsCommand) { result = new DetectActivatableWorkflowsAsyncResult(null, command, this, this.storeLock, null, timeout, callback, state); } else if (command is RecoverInstanceLocksCommand) { result = new RecoverInstanceLocksAsyncResult(null, command, this, this.storeLock, null, timeout, callback, state); } else if (command is UnlockInstanceCommand) { result = new UnlockInstanceAsyncResult(null, command, this, this.storeLock, Transaction.Current, timeout, callback, state); } else if (command is CreateWorkflowOwnerCommand) { result = new CreateWorkflowOwnerAsyncResult(context, command, this, this.storeLock, Transaction.Current, timeout, callback, state); } else if (command is DeleteWorkflowOwnerCommand) { result = new DeleteWorkflowOwnerAsyncResult(context, command, this, this.storeLock, Transaction.Current, timeout, callback, state); } else if (command is QueryActivatableWorkflowsCommand) { result = new QueryActivatableWorkflowAsyncResult(context, command, this, this.storeLock, Transaction.Current, timeout, callback, state); } else { return(base.BeginTryCommand(context, command, timeout, callback, state)); } result.ScheduleCallback(); return(result); }
protected internal override bool EndTryCommand(IAsyncResult result) { if (result is LoadRetryAsyncResult) { return(LoadRetryAsyncResult.End(result)); } if (result is SqlWorkflowInstanceStoreAsyncResult) { return(SqlWorkflowInstanceStoreAsyncResult.End(result)); } return(base.EndTryCommand(result)); }
private static bool OnBindReclaimed(IAsyncResult result) { SqlWorkflowInstanceStoreAsyncResult asyncState = (SqlWorkflowInstanceStoreAsyncResult)result.AsyncState; asyncState.InstancePersistenceContext.EndBindReclaimedLock(result); Guid instanceId = asyncState.InstancePersistenceContext.InstanceView.InstanceId; long instanceVersion = asyncState.InstancePersistenceContext.InstanceVersion; ((InstanceLockTracking)asyncState.InstancePersistenceContext.UserContext).TrackStoreLock(instanceId, instanceVersion, null); asyncState.InstancePersistenceContext.InstanceHandle.Free(); throw FxTrace.Exception.AsError(new InstanceLockLostException(asyncState.InstancePersistenceCommand.Name, instanceId)); }
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); }
static bool OnBindReclaimed(IAsyncResult result) { SqlWorkflowInstanceStoreAsyncResult thisPtr = (SqlWorkflowInstanceStoreAsyncResult)result.AsyncState; thisPtr.InstancePersistenceContext.EndBindReclaimedLock(result); Guid instanceId = thisPtr.InstancePersistenceContext.InstanceView.InstanceId; long lockVersion = thisPtr.InstancePersistenceContext.InstanceVersion; InstanceLockTracking instanceLockTracking = (InstanceLockTracking)(thisPtr.InstancePersistenceContext.UserContext); instanceLockTracking.TrackStoreLock(instanceId, lockVersion, null); thisPtr.InstancePersistenceContext.InstanceHandle.Free(); throw FxTrace.Exception.AsError(new InstanceLockLostException(thisPtr.InstancePersistenceCommand.Name, instanceId)); }
private void CommandCompletedCallback(IAsyncResult result) { SqlWorkflowInstanceStoreAsyncResult result1 = (SqlWorkflowInstanceStoreAsyncResult)result; try { this.Store.EndTryCommand(result); if (this.automaticallyResetTimer) { this.ResetTimer(false); } } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } this.HandleError(exception); } }
static void StartOperationCallback(object state) { SqlWorkflowInstanceStoreAsyncResult sqlWorkflowInstanceStoreAsyncResult = (SqlWorkflowInstanceStoreAsyncResult)state; sqlWorkflowInstanceStoreAsyncResult.StartOperation(); }
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); }