示例#1
0
        public Dictionary <string, object> ExecuteAction(ProjectState projectState, ActionBase action, List <ActionParameter> actionParameters, List <string> consoleInputs = null)
        {
            var outputParameters = new Dictionary <string, object>();

            try
            {
                action.OnLog += Action_OnLog;
                if (action.CanExecute(projectState, actionParameters))
                {
                    var timer = new Stopwatch(); timer.Start();
                    action.ConsoleService = new ConsoleService(consoleInputs);
                    outputParameters      = action.PrepareExecution(projectState, actionParameters);
                    var time = StringFormats.MillisecondsToHumanTime(timer.ElapsedMilliseconds);
                }
                else
                {
                    action.ExecuteHelp();
                }
            }
            catch (Exception ex)
            {
                OnErrorExecution?.Invoke(this, new ErrorExecutionActionEventArgs(action, ex));
                throw;
            }
            finally
            {
                action.OnLog -= Action_OnLog;
            }
            return(outputParameters);
        }
示例#2
0
 private void QueueAction(ProjectState projectState, ActionBase action, List <ActionParameter> actionParameters, List <string> consoleInputs = null)
 {
     try
     {
         action.OnLog += Action_OnLog;
         if (action.CanExecute(projectState, actionParameters))
         {
             OnQueueAction?.Invoke(this, new ActionEventArgs(action, actionParameters));
         }
         else
         {
             action.ExecuteHelp();
         }
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         action.OnLog -= Action_OnLog;
     }
 }