/// <summary> /// 构造工具箱 /// </summary> /// <param name="args"></param> /// <param name="executer"></param> public ToolKit(TArgs args, CommandExecuter executer = null) { Args = args; Executer = executer ?? new CommandExecuter(); Ae = (command) => { return(Executer.Execute(Command.MakeForAdb(Args.DevBasicInfo.Serial, command))); }; Fe = (command) => { return(Executer.Execute(Command.MakeForFastboot(Args.DevBasicInfo.Serial, command))); }; }
public void Process(WorkflowPipelineArgs args) { Item item = args.DataItem; string stateId = item.State.GetWorkflowState().StateID; ProcessorItem workflowItem = args.ProcessorItem; string langs = workflowItem.InnerItem.Fields["LanguagesToWaitFor"].Value; string commandID = workflowItem.InnerItem.Fields["CommandToExecute"].Value; if (commandID == "") { Log.Error("WaitForLanguage action failed. The field 'CommandToExecute' value is not set.", this); return; } Item command = item.Database.Items[commandID]; if (command["Next state"] == "") { Log.Error("WaitForLanguage action failed. The field 'Next State' value of the command is not set.", this); return; } bool result = true; foreach (Language lang in item.Languages) { if (langs != "") { if (langs.IndexOf(lang.GetItem(item.Database).ID.ToString()) == -1) { continue; } } if (lang.Name == item.Language.Name) { continue; } Item langItem = item.Database.Items[item.Paths.FullPath, lang, item.Version]; WorkflowState workflowState = langItem.State.GetWorkflowState(); result = result && (workflowState.StateID == stateId || workflowState.FinalState); } if (result) { foreach (Language lang in item.Languages) { Item langItem = item.Database.Items[item.Paths.FullPath, lang, item.Version]; WorkflowState state = langItem.State.GetWorkflowState(); if (workflowItem.InnerItem.Parent.ID.ToString() == state.StateID) { WorkflowResult execute = CommandExecuter.Execute(commandID, langItem, "", true); if (!execute.Succeeded) { Log.Error("WaitForLanguage action failed: " + execute.Message, this); } } } } }
public void Process(WorkflowPipelineArgs args) { Item item = args.DataItem; ProcessorItem workflowItem = args.ProcessorItem; string commandToExecute = workflowItem.InnerItem["CommandToExecute"]; if (commandToExecute == "" || item.Database.Items[commandToExecute] == null || item.Database.Items[commandToExecute]["Next state"] == "") { Log.Error("Action SetStateByLanguage is failed: 'CommandToExecute' field is not set properly", this); return; } foreach (Language language in item.Languages) { if (language.Name == item.Language.Name) { continue; } Item langItem = item.Database.Items[item.Paths.FullPath, language, item.Version]; if (GetIsAllowToChangeState(langItem, workflowItem)) { using (new EditContext(langItem)) { CommandExecuter.Execute(commandToExecute, langItem, "", true); } } } }
/// <summary> /// 获取已连接的设备 /// </summary> /// <returns></returns> public DevicesList GetDevices() { lock (executer) { DevicesList devList = new DevicesList(); var adbDevicesOutput = executer.Execute(adbDevicesCmd); if (!adbDevicesOutput.IsSuccessful) { AdbHelper.RisesAdbServerStartsFailedEvent(); return(devList); } var fastbootDevicesOutput = executer.Execute(fbDevicesCmd); AdbParse(adbDevicesOutput, ref devList); FastbootParse(fastbootDevicesOutput, ref devList); return(devList); } }
public void PositionalCommandExecuted() { _context.CommandContext.RegisterCommand <AddNumberCommand>(); var parseResult = PowerParser.ParseInput("Add-Number 2 5.0"); var result = CommandExecuter.Execute(parseResult.Value as pstudio.PowerConsole.Parser.Command, _context, _host); Assert.AreEqual(7.0, result); }
public void NamedCommandExecuted() { _context.CommandContext.RegisterCommand <TestCommand>(); var parseResult = PowerParser.ParseInput("Test-Command \"Hello World\" -SubstringIndex 6"); var result = CommandExecuter.Execute(parseResult.Value as pstudio.PowerConsole.Parser.Command, _context, _host); Assert.AreEqual("World", result); }
static void Main(string[] args) { globalConfig = ConfigFile.Create("config.ini"); sharedConfig = ConfigFile.Create("shared.ini"); string systemLockKey = globalConfig.GetString("System", "MutexKey"); Mutex systemLock = new Mutex(false, systemLockKey); if (!systemLock.WaitOne(TimeSpan.Zero, true)) { return; } Log.ShowDate = true; //show the date of when logs happen Log.ShowThreadID = true; //show the thread id that this message is from RPCManager.Create("."); CommandExecuter commandExecuter = new CommandExecuter(); commandExecuter.Execute(args); Thread keyboardInterceptorThread = new Thread(SetupKeyboardInterceptor); keyboardInterceptorThread.Start(); scheduler = new Core.Tasks.TaskScheduler(); //Start the installation task. InstallationTask inst = new InstallationTask(); inst.Run(); //Schedule the frontend to launch in 30 seconds. scheduler.Schedule(DateTime.Now.AddSeconds(3), new FrontendLauncherTask()); Thread readInThread = new Thread(ReadIn); readInThread.Start(); while (bRunning) { Thread.Sleep(10000); } readInSafeAccess.WaitOne(Timeout.InfiniteTimeSpan, true); readInThread.Abort(); readInSafeAccess.ReleaseMutex(); scheduler.Shutdown(); scheduler.WaitForShutdownComplete(); globalConfig.Save(); systemLock.ReleaseMutex(); }
public void MandatoryCommandExecuted() { _context.CommandContext.RegisterCommand <MandatoryNamedCommand>(); var parseResult = PowerParser.ParseInput("Mandatory-Named -Message 'Goodbye'"); var result = CommandExecuter.Execute(parseResult.Value as pstudio.PowerConsole.Parser.Command, _context, _host); Assert.AreEqual("Hello World", result); parseResult = PowerParser.ParseInput("Mandatory-Named -Message 'Goodbye' -Flag"); result = CommandExecuter.Execute(parseResult.Value as pstudio.PowerConsole.Parser.Command, _context, _host); Assert.AreEqual("Goodbye", result); }
private void HandleEnter(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { string input = Inputfield.Text.Trim(); CurrentCommand = CommExec.Execute(input); if (CurrentCommand == null) { Done(); } HistoryManager.AddToHistory(input); } }
public void PositionalCommandIncorrectPositionalArgumentTypeExecuted() { _context.CommandContext.RegisterCommand <AddNumberCommand>(); var parseResult = PowerParser.ParseInput("Add-Number 2 '2'"); try { var result = CommandExecuter.Execute(parseResult.Value as pstudio.PowerConsole.Parser.Command, _context, _host); Assert.Fail(); } catch (InvalidArgumentTypeException) { } }
public void PositionalCommandMissingArgumentExecuted() { _context.CommandContext.RegisterCommand <AddNumberCommand>(); var parseResult = PowerParser.ParseInput("Add-Number 2 "); try { var result = CommandExecuter.Execute(parseResult.Value as pstudio.PowerConsole.Parser.Command, _context, _host); Assert.Fail(); } catch (MissingMandatoryParameterException) { } }
/// <summary> /// 获取Product信息 /// </summary> /// <returns></returns> public string GetProduct() { var text = executer.Execute(Command.MakeForFastboot(serial, "getvar product")).All.ToString(); var match = Regex.Match(text, resultPattern); if (match.Success) { return(match.Result("${result}")); } else { return(null); } }
static void ReadIn() { CommandExecuter commandExecuter = new CommandExecuter(); while (true) { string commandString = Console.ReadLine(); readInSafeAccess.WaitOne(Timeout.InfiniteTimeSpan, true); string[] commands = commandExecuter.BreakCommandString(commandString); commandExecuter.Execute(commands); readInSafeAccess.ReleaseMutex(); } }
/// <summary> /// 重启手机 /// </summary> /// <param name="dev"></param> /// <param name="option"></param> public static void Reboot(DeviceBasicInfo dev, RebootOptions option) { if (dev.State != DeviceState.Fastboot && (int)dev.State >= 1) { switch (option) { case RebootOptions.System: executer.Execute(Command.MakeForAdb(dev.Serial, "reboot")); break; case RebootOptions.Recovery: executer.Execute(Command.MakeForAdb(dev.Serial, "reboot recovery")); break; case RebootOptions.Fastboot: executer.Execute(Command.MakeForAdb(dev.Serial, "reboot-bootloader")); break; case RebootOptions.Snapdragon9008: executer.Execute(Command.MakeForAdb(dev.Serial, "reboot edl")); break; case RebootOptions.Sideload: executer.Execute(Command.MakeForAdb(dev.Serial, "reboot sideload")); break; } } else if (dev.State == DeviceState.Fastboot) { switch (option) { case RebootOptions.System: executer.Execute(Command.MakeForFastboot(dev.Serial, "reboot")); break; case RebootOptions.Fastboot: executer.Execute(Command.MakeForFastboot(dev.Serial, "reboot-bootloader")); break; case RebootOptions.Snapdragon9008: executer.Execute(Command.MakeForFastboot(dev.Serial, "reboot-edl")); break; } } }
void ExecuteIfCommand(string text) { CommandExecuter executer = commandsManager.GetCommandExecuter(text); if (executer.isValidCommand) { try { object result = executer.Execute(); if (executer.hasReturnValue) { string resultString = ConvertCommandResultToString(result); Log(resultString); } } catch (CommandSystemException exception) { Debug.LogException(exception); } } }
public void Run() { int totalLaps = int.Parse(Console.ReadLine()); int trackLength = int.Parse(Console.ReadLine()); raceTower.SetTrackInfo(totalLaps, trackLength); while (true) { if (raceTower.IsFinished) { Console.WriteLine(raceTower.PrintWinner()); return; } var input = Console.ReadLine().Split(); commandExecuter.Execute(input); } }
private void _tcpConnection_OnDataReceived(object sender, ReceiveDataEventArgs e) { var bytes = e.Data.ToList(); Logger.Log("Data received: {0}", bytes); var command = _commandParser.Parse(bytes); if (command != null) { var response = _commandExecuter.Execute(command); if (response != null) { var data = _commandEncoder.Encode(response); _tcpConnection.Send(data); Logger.Log("Data sent: {0}", BitConverter.ToString(data)); } } }
private object HandleCommand(Parser.Command command) { return(CommandExecuter.Execute(command, _context, _host)); }
/// <summary> /// 移除所有的转发 /// </summary> public static void RemoveAllForward() { executer.Execute(forwardRemoveCommand); }
public void IfExecuteExecutesCommandWithParameter() { var executer = new CommandExecuter(); Assert.Throws <System.NotImplementedException>(() => executer.Execute <TestCommandWithParameter, String>("test")); }