/// <summary> /// Commits the transaction. /// </summary> public static void Commit() { if (_notSupported) { return; } ITransactionProvider tran = ContextHandler.GetTransaction(); if (tran == null) // !IsActive { throw new InvalidOperationException(); // Transaction is not Active. } try { tran.Commit(); var queue = ContextHandler.GetTransactionQueue(); if (queue != null) { queue.Commit(); } OnCommitTransaction(tran, EventArgs.Empty); } finally { Logger.WriteVerbose("Transaction: " + tran.Id + " COMMIT. Running time: " + (DateTime.UtcNow - tran.Started)); ContextHandler.SetTransaction(null); ContextHandler.SetTransactionQueue(null); tran.Dispose(); } }
/// <summary> /// Commits the transaction. /// </summary> public static void Commit() { if (_notSupported) { return; } ITransactionProvider tran = ContextHandler.GetTransaction(); if (tran == null) // !IsActive { throw new InvalidOperationException(); // Transaction is not Active. } try { tran.Commit(); var queue = ContextHandler.GetTransactionQueue(); if (queue != null) { queue.Commit(); } OnCommitTransaction(tran, EventArgs.Empty); } finally { ContextHandler.SetTransaction(null); ContextHandler.SetTransactionQueue(null); tran.Dispose(); } }
public void Run() { var currentState = _metadataProvider.GetCurrentState(); _transactionProvider.Start(); try { foreach (var script in _scriptProvider.GetAllScripts()) { if (ScriptShouldBeRun(script, currentState)) { if (_scriptApplicator.ApplyScript(script)) { WriteUpdateEntry(script, currentState); } } } _transactionProvider.Commit(); } catch (Exception e) { _transactionProvider.Rollback(); Console.WriteLine(e); throw; } }
public override void OnActionExecuted(ActionExecutedContext filterContext) { try { if (filterContext.Exception == null) { _transactionProvider.Commit(); } else { _transactionProvider.RollBack(); } } catch (Exception ex) { _transactionProvider.RollBack(); throw ex; } }