public bool ExecuteNext() { if (IsCompleted) { throw new InvalidOperationException(); } CommandScriptStep currentItem = _nextTask.Dequeue(); var command = (Command)Activator.CreateInstance(currentItem.ActivityType); try { CommandScriptStepAudit audit = command.Execute(currentItem); if (audit != null) { _completedTasks.Push(audit); return(true); } } catch (Exception ex) { _log.Error("CommandScript Exception", ex); _exceptions.Add(ex); } return(false); }
public bool UndoLast() { if (!IsInProgress) { throw new InvalidOperationException(); } CommandScriptStepAudit currentItem = _completedTasks.Pop(); var activity = (Command)Activator.CreateInstance(currentItem.CommandType); try { return(activity.Compensate(currentItem, this)); } catch (Exception ex) { _log.Error("CommandScript Compensation Exception", ex); throw; } }