protected override void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { TraceHelper.Trace(); Transaction transactionToUse; if (Transaction.Current == null) { transactionToUse = new CommittableTransaction(); WfLogHelper.WriteLog("CommitWorkBatch提交TransactionScope事务Transaction.Current==null"); } else { transactionToUse = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete); WfLogHelper.WriteLog("CommitWorkBatch提交TransactionScope事务Transaction.Current!=null"); } TransactionCreated(transactionToUse); try { using (TransactionScope txScope = new TransactionScope(transactionToUse)) { commitWorkBatchCallback(); txScope.Complete(); WfLogHelper.WriteLog("CommitWorkBatch提交TransactionScope事务Complete完成......"); } CommittableTransaction committableTransaction = transactionToUse as CommittableTransaction; if (committableTransaction != null) { committableTransaction.Commit(); WfLogHelper.WriteLog("CommitWorkBatch提交committableTransaction事务Complete完成......"); } DependentTransaction dependentTransaction = transactionToUse as DependentTransaction; if (dependentTransaction != null) { dependentTransaction.Complete(); WfLogHelper.WriteLog("CommitWorkBatch提交dependentTransaction事务Complete完成......"); } WorkBatchCommitted(transactionToUse); } catch (Exception e) { transactionToUse.Rollback(e); WorkBatchRolledback(transactionToUse); throw; } finally { if (transactionToUse != null) { transactionToUse.Dispose(); } } }
protected override void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { TraceHelper.Trace(); Transaction transactionToUse; if (Transaction.Current == null) { transactionToUse = new CommittableTransaction(); Tracer.Debug("CommitWorkBatch�ύTransactionScope����Transaction.Current==null"); } else { transactionToUse = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete); Tracer.Debug("CommitWorkBatch�ύTransactionScope����Transaction.Current!=null" ); } TransactionCreated(transactionToUse); try { using (TransactionScope txScope = new TransactionScope(transactionToUse)) { commitWorkBatchCallback(); txScope.Complete(); Tracer.Debug("CommitWorkBatch�ύTransactionScope����Complete���......"); } CommittableTransaction committableTransaction = transactionToUse as CommittableTransaction; if (committableTransaction != null) { committableTransaction.Commit(); Tracer.Debug("CommitWorkBatch�ύcommittableTransaction����Complete���......"); } DependentTransaction dependentTransaction = transactionToUse as DependentTransaction; if (dependentTransaction != null) { dependentTransaction.Complete(); Tracer.Debug("CommitWorkBatch�ύdependentTransaction����Complete���......"); } WorkBatchCommitted(transactionToUse); } catch (Exception e) { transactionToUse.Rollback(e); WorkBatchRolledback(transactionToUse); throw; } finally { if (transactionToUse != null) transactionToUse.Dispose(); } }
virtual internal protected void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { Transaction tx = null; if (null == Transaction.Current) { tx = new CommittableTransaction(); } else { tx = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete); } try { using (TransactionScope ts = new TransactionScope(tx)) { commitWorkBatchCallback(); ts.Complete(); } CommittableTransaction committableTransaction = tx as CommittableTransaction; if (committableTransaction != null) { committableTransaction.Commit(); } DependentTransaction dependentTransaction = tx as DependentTransaction; if (dependentTransaction != null) { dependentTransaction.Complete(); } } catch (Exception e) { tx.Rollback(e); throw; } finally { if (tx != null) { tx.Dispose(); } } }
protected internal virtual void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { Transaction transactionToUse = null; if (null == Transaction.Current) { transactionToUse = new CommittableTransaction(); } else { transactionToUse = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete); } try { using (TransactionScope scope = new TransactionScope(transactionToUse)) { commitWorkBatchCallback(); scope.Complete(); } CommittableTransaction transaction2 = transactionToUse as CommittableTransaction; if (transaction2 != null) { transaction2.Commit(); } DependentTransaction transaction3 = transactionToUse as DependentTransaction; if (transaction3 != null) { transaction3.Complete(); } } catch (Exception exception) { transactionToUse.Rollback(exception); throw; } finally { if (transactionToUse != null) { transactionToUse.Dispose(); } } }
virtual internal protected void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { Transaction tx = null; if (null == Transaction.Current) tx = new CommittableTransaction(); else tx = Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete); try { using (TransactionScope ts = new TransactionScope(tx)) { commitWorkBatchCallback(); ts.Complete(); } CommittableTransaction committableTransaction = tx as CommittableTransaction; if (committableTransaction != null) committableTransaction.Commit(); DependentTransaction dependentTransaction = tx as DependentTransaction; if (dependentTransaction != null) dependentTransaction.Complete(); } catch (Exception e) { tx.Rollback(e); throw; } finally { if (tx != null) { tx.Dispose(); } } }
internal protected override void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { DbRetry dbRetry = new DbRetry(_enableRetries); short retryCounter = 0; while (true) { if (null != Transaction.Current) { // // Can't retry as we don't own the tx // Set the counter to only allow one iteration retryCounter = dbRetry.MaxRetries; } try { base.CommitWorkBatch(commitWorkBatchCallback); break; } catch (Exception e) { WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "DefaultWorkflowCommitWorkBatchService caught exception from commitWorkBatchCallback: " + e.ToString()); if (dbRetry.TryDoRetry(ref retryCounter)) { WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "DefaultWorkflowCommitWorkBatchService retrying commitWorkBatchCallback (retry attempt " + retryCounter.ToString(System.Globalization.CultureInfo.InvariantCulture) + ")"); continue; } else { throw; } } } }
internal protected override void CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback) { DbRetry dbRetry = new DbRetry(_enableRetries); short retryCounter = 0; while (true) { if (null != Transaction.Current) { // // Can't retry as we don't own the tx // Set the counter to only allow one iteration retryCounter = dbRetry.MaxRetries; } try { base.CommitWorkBatch(commitWorkBatchCallback); break; } catch (Exception e) { WorkflowTrace.Host.TraceEvent(TraceEventType.Error, 0, "DefaultWorkflowCommitWorkBatchService caught exception from commitWorkBatchCallback: " + e.ToString()); if (dbRetry.TryDoRetry(ref retryCounter)) { WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "DefaultWorkflowCommitWorkBatchService retrying commitWorkBatchCallback (retry attempt " + retryCounter.ToString(System.Globalization.CultureInfo.InvariantCulture) + ")"); continue; } else throw; } } }