static void Main(string[] args) { var engine = new RoomieEngine(); setOutput(engine); //engine.TerminalMessageSent += new TerminalOutputEventHandler(controller_TerminalMessageSent); engine.Start(); var line = ""; var input = ""; var xmlInput = new XmlDocument(); //TODO: improve this. Make the while loop directly depend on the engine's internal state. while (!input.Contains("Core.ShutDown")) { //TODO: pull reading from a text stream into Roomie.Desktop.Engine.RoomieEngine line = Console.ReadLine().Trim(); if (!String.IsNullOrEmpty(line)) { if (input.Length > 0) { input += "\n"; } input += line.TrimEnd('_'); //TODO: read multiple lines if (!line.EndsWith("_")) { try { var script = ScriptCommandList.FromText(input); engine.Threads.AddCommands(script); Console.WriteLine("Command accepted."); input = ""; } catch (Exception exception) { Console.WriteLine("Error. " + exception.Message); } } } else { if (input != "") { input = ""; Console.WriteLine("Input cleared."); } } } }
private void Run() { running = true; print("Webhook reading tasks..."); foreach (RoomieCommand command in roomieController.CommandLibrary) { if (command.Name.Equals("WebHookConnectTasks")) { AddCommand(command.BlankCommandCall()); } } while (true) { try { var response = Send <Task[]>("task", new Request { Action = "GetForComputer", Parameters = new Dictionary <string, object> { { "computerName", computerName } }, }); if (response.Data.Length == 0) { print("no tasks"); } else { foreach (var task in response.Data) { var commands = ScriptCommandList.FromText(task.Script.Text); AddCommands(commands); } } } catch (RoomieRuntimeException exception) { print(exception.Message); print("sleeping for 10 seconds because of error..."); System.Threading.Thread.Sleep(new TimeSpan(0, 0, 10)); } } }
private void RunInput(bool clearInput = true) { ScriptCommandList script; try { script = ScriptCommandList.FromText(Input.Text); } catch (RoomieScriptSyntaxErrorException exception) { MessageBox.Show(exception.Message); return; } if (clearInput) { Input.Clear(); } _engine.Threads.AddCommands(script); }