コード例 #1
0
        private void RunScript(List <ScriptDto> listScript)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(appArgs.ScriptId) || !listScript.Any(r => r.Id.Equals(appArgs.ScriptId)))
                {
                    log.Error("Identifiant du script absent ou non reconnu ('{0}' : {1})", appArgs.ScriptId,
                              String.Join(", ", listScript.Select(r => r.Id)));
                    appExitCode = EnumExitCode.NoScriptOrNotKnown;

                    return;
                }

                ScriptDto scriptDto = listScript.FirstOrDefault(r => r.Id.Equals(appArgs.ScriptId));
                log.Info("Script à lancer (id: {0}, script: {1})", scriptDto.Id, scriptDto.Path);

                ScriptRunner sRun = new ScriptRunner(scriptDto);
                _handler += new EventHandler(sRun.HandleUnusalExit);
                SetConsoleCtrlHandler(_handler, true);
                sRun.Run(appArgs.ScriptArgsInput);
            }
            catch (Exception e)
            {
                log.Error("Erreur inattendue : {0}", e.Message);
                ExceptionHandlingUtils.LogAndHideException(e, isWarnMsgAndDebugStack: true);
                appExitCode = EnumExitCode.ErrorScriptRunner;

                return;
            }
        }
コード例 #2
0
 private void ShowSyntax(AppArgParser parser)
 {
     appExitCode = EnumExitCode.ShowSyntax;
     Console.WriteLine("-------------------------------------------------------------------------------");
     Console.WriteLine("   POWERSHELL SCRIPT LAUNCHER   ::  Lanceur de scripts PowerShell");
     Console.WriteLine("-------------------------------------------------------------------------------");
     Console.WriteLine();
     parser.ShowSyntax();
     Console.WriteLine();
 }