public void Rollback() { if (Stage == Stage.Completed || Stage == STEM.Surge.Stage.Stopped) { try { _Rollback(); } catch (Exception ex) { Exceptions.Add(ex); } Stage = Stage.RolledBack; ExecutionStageHistory.Add(Stage.RolledBack); } }
/// <summary> /// Manages the execution of the implementation of _Run() /// </summary> public void Run() { if (Stop) { return; } bool success = true; try { if (Stage != STEM.Surge.Stage.Ready) { return; } InstructionSet.InstructionSetContainer["_Run Called"] = DateTime.UtcNow; success = _Run(); if (Stop) { Stage = Stage.Stopped; ExecutionStageHistory.Add(Stage.Stopped); } else { Stage = Stage.Completed; ExecutionStageHistory.Add(Stage.Completed); } } catch (Exception ex) { Stage = STEM.Surge.Stage.Completed; ExecutionStageHistory.Add(Stage.Completed); success = false; Exceptions.Add(ex); } finally { try { if (InstructionSet != null) { if (!success) { switch (FailureAction) { case STEM.Surge.FailureAction.Continue: break; case STEM.Surge.FailureAction.Rollback: for (int i = OrdinalPosition; i >= 0; i--) { try { InstructionSet.Instructions[i].Rollback(); } catch (Exception ex) { Exceptions.Add(ex); } } SkipRemaining(); break; case STEM.Surge.FailureAction.SkipRemaining: SkipRemaining(); break; case Surge.FailureAction.SkipNext: SkipNext(); break; case Surge.FailureAction.SkipToLabel: SkipForwardToFlowControlLabel(FailureActionLabel); break; } } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry(InstructionSet.ProcessName, ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); } } return; }