Exemple #1
0
        /// <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));
        }
Exemple #2
0
        /// <see cref="WirelessDisplay.Common.IRemoteScriptRunner.RunAndWaitForScript"></see>
        async Task <Tuple <int, List <string>, List <string> > > IRemoteScriptRunner.RunAndWaitForScript(
            string scriptName, string scriptArgs, string stdin)
        {
            var postData = new StartOrRunScriptRequestData()
            {
                ScriptName = scriptName,
                ScriptArgs = scriptArgs,
                StdIn      = stdin
            };

            // If an exception occurs, let it handle the caller
            RunOrStopScriptResponseData rd = await
                                             performPost <StartOrRunScriptRequestData, RunOrStopScriptResponseData>(postData, MagicStrings.RESTAPI_RUNSCRIPT);

            if (!rd.Success)
            {
                string msg = $"Could not run remote script '{scriptName} {scriptArgs}'. Error-Message from server: '{rd.ErrorMessage}'";
                _logger?.LogWarning(msg);
                throw new WDException(msg);
            }

            return(Tuple.Create(rd.ScriptExitCode, rd.StdoutLines, rd.StderrLines));
        }