public RunOrStopScriptResponseData Post_StopScript([FromBody] QueryOrStopScriptRequestData requestData) { int exitCode; List <string> outputLines; List <string> errorLines; try { (exitCode, outputLines, errorLines) = _scriptRunner.StopScript(requestData.ProcessId); } catch (WDException e) { return(new RunOrStopScriptResponseData() { Success = false, ErrorMessage = e.Message, ScriptExitCode = -1, StdoutLines = new List <string>(), StderrLines = new List <string>() }); } return(new RunOrStopScriptResponseData() { Success = true, ErrorMessage = "", ScriptExitCode = exitCode, StdoutLines = outputLines, StderrLines = errorLines }); }
public QueryScriptResponseData Post_IsScriptRunning([FromBody] QueryOrStopScriptRequestData requestData) { bool isRunning; try { isRunning = _scriptRunner.IsScriptRunning(requestData.ProcessId); } catch (WDException e) { return(new QueryScriptResponseData() { Success = false, ErrorMessage = e.Message, IsRunning = false }); } return(new QueryScriptResponseData() { Success = true, ErrorMessage = "", IsRunning = isRunning }); }
/// <see cref="WirelessDisplay.Common.IRemoteScriptRunner.IsScriptRunning"></see> async Task <bool> IRemoteScriptRunner.IsScriptRunning(int processId) { var postData = new QueryOrStopScriptRequestData() { ProcessId = processId }; QueryScriptResponseData rd = await performPost <QueryOrStopScriptRequestData, QueryScriptResponseData>(postData, MagicStrings.RESTAPI_IS_SCRIPT_RUNNING); if (!rd.Success) { string msg = $"Could query state of script with process-ID {processId}. Error-Message from server: '{rd.ErrorMessage}'"; _logger?.LogWarning(msg); throw new WDException(msg); } return(rd.IsRunning); }
/// <see cref="WirelessDisplay.Common.IRemoteScriptRunner.StopScript"></see> async Task <Tuple <int, List <string>, List <string> > > IRemoteScriptRunner.StopScript( int processId) { var postData = new QueryOrStopScriptRequestData() { ProcessId = processId }; // If an exception occurs, let it handle the caller RunOrStopScriptResponseData rd = await performPost <QueryOrStopScriptRequestData, RunOrStopScriptResponseData>( postData, MagicStrings.RESTAPI_STOPSCRIPT); if (!rd.Success) { string msg = $"Could not stop remote script with process-ID {processId}. Error-Message from server: '{rd.ErrorMessage}'"; _logger?.LogWarning(msg); throw new WDException(msg); } return(Tuple.Create(rd.ScriptExitCode, rd.StdoutLines, rd.StderrLines)); }