Example #1
0
        private CommandExecutionResult ExecuteCommand(Command command)
        {
            List <string> result = new List <string>();

            if (command.Instructions[0].StartsWith("{"))
            {
                return(this.ExecuteBat(command));
            }

            foreach (string Instruction in command.Instructions)
            {
                if (!Instruction.StartsWith(@"'") && !Instruction.StartsWith(@"{"))
                {
                    result.Add(ProcessRunner.ExecuteCMDCommand(Instruction));
                }
                else if (Instruction.StartsWith(@"'curl"))
                {
                    try
                    {
                        result.Add(ProcessRunner.ExecuteCommand("curl.exe", @Instruction.Replace(@"'curl", "")));
                    }
                    catch (Exception error) { result.Add(error.Message); }
                }
                else if (Instruction.ToLower().StartsWith(@"'setrequestsinterval"))
                {
                    string IntervalString = Instruction.Split(' ')[1].Trim();
                    try
                    {
                        int Interval = Convert.ToInt32(IntervalString);
                        if (Interval < 100)
                        {
                            Interval = 100;
                        }
                        if (Interval > 3600000)
                        {
                            Interval = 3600000;
                        }
                        this.RequestsIntervalInMilliseconds = Interval;
                        result.Add("Requests interval set to " + Interval.ToString());
                    }
                    catch { result.Add("Wrong input for requests interval"); }
                }
                else if (Instruction.ToLower().StartsWith(@"'setnickname"))
                {
                    if (Instruction.Split(' ').Length > 1)
                    {
                        this.NickName = Instruction.Split(' ')[1].Trim();
                        result.Add("Nickname of the executive changed to " + this.NickName);
                        Communicator.ReportStatus(ConstantValues.ManagerStatuses.Active);
                    }
                }
            }
            return(new CommandExecutionResult()
            {
                GivenCommandID = command.ID,
                Output = string.Join("\n", result)
            });
        }
Example #2
0
        public string ReadILCodeFromAssembly(string relativePath)
        {
            if (!File.Exists(relativePath))
            {
                throw new FileNotFoundException();
            }

            string executingPath = GetExecutingAssemblyPath();
            string ilspycmdPath  = Path.Combine(executingPath, "ilspycmd", "ilspycmd.dll");
            string fullPath      = Path.Combine(executingPath, relativePath);

            string command = BuildCommandFromPath(ilspycmdPath, fullPath);
            string output  = processRunner.ExecuteCommand(command);

            return(output);
        }
Example #3
0
        public void Return_Result_Printed_In_Standard_Output(string command, string expected)
        {
            string result = processRunner.ExecuteCommand(command);

            Check.That(result).IsEqualTo(expected);
        }