Beispiel #1
0
        public override void Execute(IExecutionEntity execution)
        {
            ReadFields(execution);

            IList <string> argList = new List <string>
            {
                commandStr
            };

            if (!(arg1Str is null))
            {
                argList.Add(arg1Str);
            }
            if (!(arg2Str is null))
            {
                argList.Add(arg2Str);
            }
            if (!(arg3Str is null))
            {
                argList.Add(arg3Str);
            }
            if (!(arg4Str is null))
            {
                argList.Add(arg4Str);
            }
            if (!(arg5Str is null))
            {
                argList.Add(arg5Str);
            }

            ShellExecutorContext    executorContext             = new ShellExecutorContext(waitFlag, cleanEnvBoolean, redirectErrorFlag, directoryStr, resultVariableStr, errorCodeVariableStr, argList);
            ICommandExecutorFactory shellCommandExecutorFactory = CommandExecutorContext.ShellCommandExecutorFactory;


            ICommandExecutor commandExecutor;

            if (shellCommandExecutorFactory != null)
            {
                // if there is a ShellExecutorFactoryProvided
                // then it will be used to create a desired shell command executor.
                commandExecutor = shellCommandExecutorFactory.CreateExecutor(executorContext);
            }
            else
            {
                // default Shell executor (if the shell security is OFF)
                commandExecutor = new ShellCommandExecutor(executorContext);
            }

            try
            {
                commandExecutor.ExecuteCommand(execution);
            }
            catch (Exception e)
            {
                throw new ActivitiException("Could not execute shell command ", e);
            }

            Leave(execution);
        }
Beispiel #2
0
 public Configuration CommandExecutorFactoryOf(ICommandExecutorFactory commandExecutorFactory)
 {
     CommandExecutorFactory = commandExecutorFactory;
     return this;
 }
Beispiel #3
0
 /// <summary>
 /// 创建命令总线的一个实例
 /// </summary>
 /// <param name="executorFactory">命令执行器工厂</param>
 public CommandBus(ICommandExecutorFactory executorFactory)
 {
     this.executorFactory = executorFactory;
 }
Beispiel #4
0
 /// <summary>
 /// 创建命令总线的一个实例
 /// </summary>
 /// <param name="executorFactory">命令执行器工厂</param>
 public CommandBus(IServiceProvider serviceProvider, ICommandExecutorFactory executorFactory)
 {
     _serviceProvider = serviceProvider;
     _executorFactory = executorFactory;
 }