Exemplo n.º 1
0
 public HttpStatusCode StartMonitorCrash()
 {
     UtilCmd.Clear();
     UtilCmd.WriteLine("Crash Monitor is running!");
     //UtilCmd.WriteLine("*********************************************");
     UtilProcess.StartProcess(_portal.SwLnkPath);
     UtilTime.WaitTime(1);
     MonitorCrashThread = new Thread(() =>
     {
         while (true)
         {
             if (UtilProcess.IsProcessExistedByName(_portal.SwProcessName))
             {
                 UtilTime.WaitTime(0.5);
             }
             else
             {
                 UtilCmd.WriteLine("Crash occurred!");
                 var t = RequestApi.Get("http://10.10.51.59:9100/Crashed");
                 AbortMonitorCrash();
                 return;
             }
         }
     });
     MonitorCrashThread.Start();
     return(HttpStatusCode.OK);
 }
Exemplo n.º 2
0
        public void LaunchAndCheckCrash(long testTimes)
        {
            var crashTimes = 0;

            UtilCmd.Clear();
            for (var i = 1; i < testTimes; i++)
            {
                var titleTotal = $"Reopen Times: {i} - Crash Times: {crashTimes}";
                var logLines   = UtilFile.ReadFileByLine(LogPathLaunch);
                logLines.ForEach(UtilCmd.WriteLine);
                //logLines.ForEach(line => UtilCmd.WriteLine(line));
                var launchLogTime  = GetRestartLogTime();
                var screenshotPath = Path.Combine(ScreenshotsPath, crashTimes.ToString());
                UtilProcess.StartProcess(SwLnkPath);
                Timeout = 1;
                UtilCmd.WriteTitle($"{titleTotal} - Searching MP+ UI.");
                var startTime     = DateTime.Now;
                var dialogWarning = UtilWait.ForAnyResultCatch(() =>
                {
                    UtilCmd.WriteTitle($"{titleTotal} - Searching Warning dialog of the MP+ in 60s. Time elapsed: {(DateTime.Now - startTime).Seconds}s.");
                    SwMainWindow = new AT().GetElement(MPObj.MainWindow, Timeout);  // The MP+ will change after a while.
                    return(SwMainWindow.GetElement(MPObj.DialogWarning, Timeout));
                }, 60, 2);
                if (SwMainWindow == null)
                {
                    UtilCapturer.Capture(i.ToString());
                    UtilFile.WriteFile(LogPathLaunch, $"{launchLogTime}: Reopen Times: {i} - Could not open MasterPlus.");
                    crashTimes++;
                }
                UtilTime.WaitTime(1);
                UtilProcess.KillProcessByName(SwProcessName);
                UtilTime.WaitTime(1);
            }
        }