public void WhenBlackBoxProgramIsExecuted()
        {
            var dropZone   = DirectorySetup.GetPath(ConfigurationManager.AppSettings[InputData.DropZone]);
            var outputZone = DirectorySetup.GetPath(ConfigurationManager.AppSettings[InputData.OutputZone]);
            var program    = DirectorySetup.GetPath(ConfigurationManager.AppSettings[InputData.BlackBoxProgram]);
            var command    = $"\" java -jar  \"{program}\"   \"{dropZone}\"  \"{outputZone}\"\"";
            var execution  = new CommandExecution();

            ScenarioContext.Current[ContextKey.Log] = execution.Execute(command, true);
        }
Example #2
0
 private static void PrintCommandExecutionDetails(CommandExecution commandExecution)
 {
     Console.WriteLine("************************************");
     Console.WriteLine("Command Execution Id: {0}", commandExecution.Id);
     Console.WriteLine("Command Execution Result: {0}", commandExecution.Result);
     Console.WriteLine("Command Execution Type: {0}", commandExecution.Type);
     Console.WriteLine("Command Duration: {0}", commandExecution.FinishExecution.Value.Subtract(commandExecution.StartExecution.Value));
     Console.WriteLine("Command Name: {0}", commandExecution.Command.Name);
     Console.WriteLine("Command Category: {0}", commandExecution.Command.Category);
     Console.WriteLine("************************************");
 }
Example #3
0
 public void ProcessAction(ConsoleAction action)
 {
     InputHistory.OnAction(action);
     Autocompletion.OnAction(action);
     CopyPasting.OnAction(action);
     Movement.OnAction(action);
     Tabbing.OnAction(action);
     Deletion.OnAction(action);
     CommandExecution.OnAction(action);
     CaseSenitivity.OnAction(action);
 }
Example #4
0
        public void AfterScenario()
        {
            if (ScenarioContext.Current.ContainsKey(ContextKey.Driver))
            {
                var driver = (ChromeDriver)ScenarioContext.Current[ContextKey.Driver];
                driver.Close();
            }

            CommandExecution execution = new CommandExecution();
            var command = "taskkill /im node.exe /F";
            var processExecutionResult = execution.Execute(command, false);
        }
        public void WhenNodeServerIsStarted()
        {
            var nodeServer  = ConfigurationManager.AppSettings[InputData.UIServer];
            var command     = $"cd {DirectorySetup.GetPath(ConfigurationManager.AppSettings[InputData.UIServerFolder])} & node {nodeServer}";
            var execution   = new CommandExecution();
            var portCorrect = int.TryParse(ConfigurationManager.AppSettings[InputData.Port], out int port);
            var host        = ConfigurationManager.AppSettings[InputData.Host];

            if (!ServiceCheck.IsListening(host, port))
            {
                ScenarioContext.Current[ContextKey.Log] = execution.Execute(command, false);
            }
            else
            {
                Assert.Fail("The server is already running");
            }
        }
Example #6
0
        public async Task <CommandExecution> ExecuteCommandAsync(CommandExecution commandExecution)
        {
            commandExecution.StartExecution = DateTime.UtcNow;

            var rnd = new Random();

            commandExecution.Result = (ExecutionResult)rnd.Next(0, 2);
            // Virtual command execution time
            await Task.Delay(rnd.Next(1000, 5000));

            if (ShouldSimulateException())
            {
                throw new InvalidOperationException("An exception raised during the command execution");
            }

            commandExecution.FinishExecution = DateTime.UtcNow;
            return(commandExecution);
        }
Example #7
0
        public async Task ReportCommandResult(CommandExecution commandExecution)
        {
            // Update the data for the supplied execution
            using (var context = new SchedulerContext())
            {
                var executionToUpdate = context.CommandsExecutuions.First(ce => ce.Id == commandExecution.Id);
                executionToUpdate.Result         = commandExecution.Result;
                executionToUpdate.StartExecution = commandExecution.StartExecution.HasValue
                    ? commandExecution.StartExecution.Value
                    : default(DateTime);
                executionToUpdate.FinishExecution = commandExecution.FinishExecution.HasValue
                    ? commandExecution.FinishExecution.Value
                    : default(DateTime);
                await context.SaveChangesAsync().ConfigureAwait(false);

                Clients.Group(Resources.WepAppClientsGroupName).commandExecutionInfo("finished", commandExecution);
            }
        }
Example #8
0
        /// <summary>
        /// Helper method that simulates a command execution on a client machine and produces random success or error results
        /// In general async void methods is not a good idea but here is used like event handler
        /// </summary>
        private static async void SimulateCommandExecution(CommandExecution commandExecution)
        {
            Log(LogLevel.Verbose, commandExecution.Id,
                string.Format("Start Executing Command {0} on client with name: {1} at {2}",
                              commandExecution.Command.Name, Environment.MachineName, DateTime.UtcNow));

            try
            {
                commandExecution = await _commandExecutor.ExecuteCommandAsync(commandExecution);

                await _clientsHub.Invoke <CommandExecution>("ReportCommandResult", commandExecution).ContinueWith(task =>
                {
                    if (task.IsFaulted)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Failed to update server for command execution:");
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine("Successfully update server for command execution:");
                    }
                    PrintCommandExecutionDetails(commandExecution);
                    Console.ResetColor();
                });

                Log(LogLevel.Information, commandExecution.Id,
                    string.Format("Finished Executing Command {0} on client with name: {1} at {2}",
                                  commandExecution.Command.Name, Environment.MachineName, DateTime.UtcNow));
            }
            catch (InvalidOperationException ex)
            {
                Log(LogLevel.Error, commandExecution.Id,
                    string.Format("Exception with message {0} raised during executing command with name: {1}",
                                  ex.Message, commandExecution.Command.Name));
            }
        }
Example #9
0
 internal Commander()
 {
     _matcher   = new CommandMatcher <TContext>();
     _execution = new CommandExecution <TContext>();
 }
Example #10
0
        private void TextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != System.Windows.Input.Key.Enter)
            {
                return;
            }

            e.Handled = true;

            Batch b = new Batch();
            //string textValue = this.MainText.Text;

            string textCommand = MainText.Text;

            if (!string.IsNullOrWhiteSpace(textCommand))
            {
                if (!textCommand.Contains(" "))
                {
                    TextToSpeech.Speak("Please enter the full command");
                }
                else
                {
                    string[] commands = textCommand.Split(' ');
                    if (commands.Count() < 2)
                    {
                        TextToSpeech.Speak("Please enter the full command");
                    }
                    else
                    {
                        CommandExecution cmdExecution = new CommandExecution();
                        int RowID;
                        var db = new Models();
                        if (commands[0].Equals("B", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (db.WebDB.Any(w => w.TextCommand.Equals(commands[1], StringComparison.InvariantCultureIgnoreCase)))
                            {
                                RowID = db.WebDB.Where(w => w.TextCommand.Equals(commands[1], StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().WebID;
                                cmdExecution.Run(RowID);
                            }
                        }
                        else if (commands[0].Equals("C", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (db.HotKeyDB.Any(w => w.TextCommand.Equals(commands[1], StringComparison.InvariantCultureIgnoreCase)))
                            {
                                RowID = db.HotKeyDB.Where(w => w.TextCommand.Equals(commands[1], StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().HotKeyID;
                                cmdExecution.CopyToClipBoard(RowID);
                            }
                        }
                        else if (commands[0].Equals("A", StringComparison.InvariantCultureIgnoreCase))
                        {
                            b.findexe(commands[1]);
                        }
                        else if (commands[0].Equals("J", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (db.JIRADB.Any(w => w.TextCommand.Equals(commands[1], StringComparison.InvariantCultureIgnoreCase)))
                            {
                                RowID = db.JIRADB.Where(w => w.TextCommand.Equals(commands[1], StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().JIRAID;
                                cmdExecution.ExecuteResult(RowID);
                            }
                        }
                        else if (commands[0].Equals("O", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (db.OutlookDB.Any(w => w.TextCommand.Equals(commands[1], StringComparison.InvariantCultureIgnoreCase)))
                            {
                                RowID = db.OutlookDB.Where(w => w.TextCommand.Equals(commands[1], StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault().OutlookID;
                                new OutlookUtils().HandleOutlookOperations(RowID);
                            }
                        }
                    }
                }
            }
        }
		public void BeginTransaction(IsolationLevel isoLevel, CommandExecution execution)
		{
			_isInTransaction = true;
			_isolationLevel = isoLevel;
			_execution = execution;
		}
Example #12
0
        private static void Main()
        {
            Console.WriteLine("Choose the operation:");
            Console.WriteLine("------------------------");
            Console.WriteLine("Creational Patterns");
            Console.WriteLine("------------------------");
            Console.WriteLine("1 - Abstract Factory");
            Console.WriteLine("2 - Factory Method");
            Console.WriteLine("3 - Singleton");
            Console.WriteLine("------------------------");
            Console.WriteLine("Structural Patterns");
            Console.WriteLine("------------------------");
            Console.WriteLine("4 - Adapter");
            Console.WriteLine("5 - Facade");
            Console.WriteLine("6 - Composite");
            Console.WriteLine("------------------------");
            Console.WriteLine("7 - Command");
            Console.WriteLine("8 - Strategy");
            Console.WriteLine("9 - Observer");
            Console.WriteLine("------------------------");

            var option = Console.ReadKey();

            Console.WriteLine("");
            Console.WriteLine("------------------------");
            Console.WriteLine("");

            switch (option.KeyChar)
            {
            case '1':
                AbstractFactoryExecution.Execute();
                break;

            case '2':
                FactoryMethodExecution.Execute();
                break;

            case '3':
                SingletonExecution.Execute();
                break;

            case '4':
                AdapterExecution.Execute();
                break;

            case '5':
                FacadeExecution.Execute();
                break;

            case '6':
                CompositeExecution.Execute();
                break;

            case '7':
                CommandExecution.Execute();
                break;

            case '8':
                StrategyExecution.Execute();
                break;

            case '9':
                ObserverExecution.Execute();
                break;
            }

            Console.ReadKey();
            Console.Clear();
            Main();
        }
Example #13
0
 public static void AfterTestRun()
 {
     CommandExecution execution = new CommandExecution();
     var command = "taskkill /im node.exe /F";
     var processExecutionResult = execution.Execute(command, false);
 }
 public void Add(CommandExecution commandExecution)
 {
     _context.CommandExecutions.Add(commandExecution);
     _context.SaveChanges();
 }
Example #15
0
 public ControlMenuItem(object content, string resourceToolTip = null, Type typeElement = null, AddControlMenuItem parent = null, CommandExecution active = null, CommandExecution canActive = null)
 {
     this._content         = content;
     this._element         = null;
     this._typeElement     = typeElement;
     this._active          = active;
     this._canActive       = canActive;
     this._parent          = parent;
     this._resourceToolTip = resourceToolTip;
 }
		public void BeginTransaction(CommandExecution execution) 
		{
			BeginTransaction(IsolationLevel.ReadCommitted, execution);
		}
Example #17
0
 public Command(string key, CommandExecution ce)
 {
     Key      = key;
     Execute += ce;
 }
Example #18
0
 public Command(string name, CommandExecution execution, Parameter[] parameters)
 {
     Name       = name;
     Execution  = execution;
     Parameters = parameters;
 }