Beispiel #1
0
        public void Run(string fileName, string args, bool redirectIO, bool redirectErrors, bool RunWithPause, string WorkingDirectory, bool attachDebugger, bool fictive_attach)
        {
            Utils.ProcessRunner PRunner = new Utils.ProcessRunner();
            PRunner.ProcessExited += new EventHandler(PRunner_ProcessExited);
            //PRunner.OutputLineReceived += new Utils.LineReceivedEventHandler(PRunner_OutputLineReceived);
            PRunner.WorkingDirectory = WorkingDirectory;
            StartedProcesses.Add(fileName, PRunner);
            StartedFiles.Add(PRunner, fileName);
            string ReadSignalName = null;

            /*if (redirectIO)
             * {
             *  ReadSignalName = Path.GetFileNameWithoutExtension(fileName) + (new Random()).Next(10000).ToString();
             *  args = "READSIGNAL" + ReadSignalName + " " + args;
             *  ReadSignalNames.Add(ReadSignalName, fileName);
             *  ReadSignalNames.Add(fileName, ReadSignalName);
             *  ReadSignalList.Add(ReadSignalName);
             * }
             * if (redirectErrors)
             * {
             *  //args = "CATCHUNHANDLEDEXCEPTIONS" +" "+ args;
             * }*/
            if (Starting != null)
            {
                Starting(fileName);
            }
            try
            {
                PRunner.Start(fileName, args, redirectIO, redirectErrors, RunWithPause, attachDebugger, fictive_attach);
                if ((PRunner.TempBatFile != null) && !TempBatFiles.ContainsKey(fileName))
                {
                    TempBatFiles.Add(fileName, PRunner.TempBatFile);
                }
                if (redirectIO)
                {
                    EventedStreamReaderList.Add(PRunner.process.StandardOutput, OutputStreamId + fileName, InputEncoding);
                    PRunner.process.StandardInput.AutoFlush = true;
                }
                if (redirectErrors)
                {
                    EventedStreamReaderList.Add(PRunner.process.StandardError, ErrorStreamId + fileName, InputEncoding);
                }
            }
            catch (Exception)
            {
                RemoveFromTables(fileName);
                throw;
            }
        }
Beispiel #2
0
        public void Run(string fileName, string args, bool redirectIO, bool redirectErrors, bool RunWithPause, string WorkingDirectory, bool attachDebugger, bool fictive_attach)
        {
            Utils.ProcessRunner PRunner = new Utils.ProcessRunner();
            PRunner.ProcessExited += new EventHandler(PRunner_ProcessExited);
            //PRunner.OutputLineReceived += new Utils.LineReceivedEventHandler(PRunner_OutputLineReceived);
            PRunner.WorkingDirectory = WorkingDirectory;
            StartedProcesses.Add(fileName, PRunner);
            StartedFiles.Add(PRunner, fileName);
            string ReadSignalName = null;

            if (Starting != null)
            {
                Starting(fileName);
            }
            try
            {
                PRunner.Start(fileName, args, redirectIO, redirectErrors, RunWithPause, attachDebugger, fictive_attach);
                if ((PRunner.TempBatFile != null) && !TempBatFiles.ContainsKey(fileName))
                {
                    TempBatFiles.Add(fileName, PRunner.TempBatFile);
                }
                if (redirectIO)
                {
                    EventedStreamReaderList.Add(PRunner.process.StandardOutput, OutputStreamId + fileName, InputEncoding);
                    PRunner.process.StandardInput.AutoFlush = true;
                }
                if (redirectErrors)
                {
                    EventedStreamReaderList.Add(PRunner.process.StandardError, ErrorStreamId + fileName, InputEncoding);
                }
            }
            catch (Exception e)
            {
#if DEBUG
                File.AppendAllText("logRun.txt", e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine);
#endif
                RemoveFromTables(fileName);
                throw; // Это не перехватывается и приводит к вылету оболочки - SSM 22/04/19
            }
        }
Beispiel #3
0
        public void Run(string fileName, string args, bool redirectIO, bool redirectErrors, bool RunWithPause, string WorkingDirectory, bool attachDebugger, bool fictive_attach)
        {
            Utils.ProcessRunner PRunner = new Utils.ProcessRunner();
            PRunner.ProcessExited += new EventHandler(PRunner_ProcessExited);
            //PRunner.OutputLineReceived += new Utils.LineReceivedEventHandler(PRunner_OutputLineReceived);
            PRunner.WorkingDirectory = WorkingDirectory;
            StartedProcesses.Add(fileName, PRunner);
            StartedFiles.Add(PRunner, fileName);
            string ReadSignalName = null;

            if (Starting != null)
            {
                Starting(fileName);
            }
            try
            {
                PRunner.Start(fileName, args, redirectIO, redirectErrors, RunWithPause, attachDebugger, fictive_attach);
                if ((PRunner.TempBatFile != null) && !TempBatFiles.ContainsKey(fileName))
                {
                    TempBatFiles.Add(fileName, PRunner.TempBatFile);
                }
                if (redirectIO)
                {
                    EventedStreamReaderList.Add(PRunner.process.StandardOutput, OutputStreamId + fileName, InputEncoding);
                    PRunner.process.StandardInput.AutoFlush = true;
                }
                if (redirectErrors)
                {
                    EventedStreamReaderList.Add(PRunner.process.StandardError, ErrorStreamId + fileName, InputEncoding);
                }
            }
            catch (Exception)
            {
                RemoveFromTables(fileName);
                throw;
            }
        }