コード例 #1
0
        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);
        }
コード例 #2
0
        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;
            }
        }