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);
            }
        }
示例#2
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);
 }
示例#3
0
 public HttpStatusCode CrashOccurred()
 {
     if (MonitorCrashThread != null && MonitorCrashThread.IsAlive)
     {
         MonitorCrashThread.Abort();
     }
     UtilCmd.WriteLine("Crash occurred!");
     return(HttpStatusCode.OK);
 }
示例#4
0
 public HttpStatusCode AbortMonitorCrash()
 {
     if (MonitorCrashThread != null && MonitorCrashThread.IsAlive)
     {
         MonitorCrashThread.Abort();
     }
     UtilCmd.WriteLine("Crash Monitor aborted!");
     return(HttpStatusCode.OK);
 }
示例#5
0
 private static async Task OpenListener()
 {
     await Task.Run(() =>
     {
         ListenerManager.SetListener(ListenerManager.ListenerChooser.Nancy);
         var listener = ListenerManager.GetListener();
         listener.Start();
         UtilCmd.WriteTitle($"Local OS Address: [{listener.GetAddress()}]");
     });
 }
        public void RestartSystemAndCheckDeviceRecognitionFlow(XmlOps xmlOps)
        {
            UtilFolder.CreateDirectory(Path.Combine(ScreenshotsPath, "Restart"));
            var restartLogTime = GetRestartLogTime();
            var screenshotPath = Path.Combine(RestartScreenshotPath, restartLogTime);
            var logLines       = UtilFile.ReadFileByLine(LogPathRestart);

            logLines.ForEach(line => UtilCmd.WriteLine(line));
            var titleLaunchTimes = xmlOps.GetRestartTimes();
            var titleTotal       = $"Restart Times: {titleLaunchTimes} - Error Times: {logLines.Count}";
            var t = UtilWait.WaitTimeElapseThread($"{titleTotal} - Waiting 35s.", 35);

            t.Start();
            t.Join();
            if (!File.Exists(SwLnkPath))
            {
                UtilCmd.WriteTitle($"{titleTotal} - Could not find {SwLnkPath}.");
                UtilCmd.PressAnyContinue();
            }
            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, 3);

            if (SwMainWindow == null)
            {
                //UtilCmd.WriteTitle($"Restart Times: {titleLaunchTimes} - Could not open MasterPlus.");
                UtilCapturer.Capture(screenshotPath);
                UtilFile.WriteFile(LogPathRestart, $"{restartLogTime}: Restart Times: {titleLaunchTimes} - Could not open MasterPlus.");
            }
            else if (dialogWarning != null)
            {
                UtilCapturer.Capture(screenshotPath);
                //UtilCmd.WriteTitle($"Restart Times: {titleLaunchTimes} - The device was not displayed");
                UtilFile.WriteFile(LogPathRestart, $"{restartLogTime}: Restart Times: {titleLaunchTimes} - The device was not displayed.");
            }
            xmlOps.SetRestartTimes(Convert.ToInt16(titleLaunchTimes) + 1);
            UtilTime.WaitTime(1);
            UtilProcess.KillProcessByName(this.SwProcessName);
            //UtilProcess.ExecuteCmd();// sometimes it does not work somehow.
            UtilOS.Reboot();
        }
示例#7
0
 public void ShowTopMenu()
 {
     try
     {
         var result = _cmd.ShowCmdMenu(_optionsTopMenu);
         if (result.Equals(MARK_FOUND_RESULT))
         {
             UtilCmd.WriteLine(" >>>>>>>>>>>>>> Test Done!");
         }
         //_cmd.WriteCmdMenu(_optionsProjects, true);
     }
     catch (Exception ex)
     {
         var a = ex.Message;
         //HandleWrongStepResult(ex.Message);
         UtilCmd.PressAnyContinue();
         ShowTopMenu();
     }
 }
示例#8
0
        private void ConnectRemoteOsAvailable(string remoteOsIp)
        {
            var currentTitle  = UtilCmd.GetTitle();
            var waitAnimation = UtilWait.WaitTimeElapseThread("Connecting...");

            try
            {
                _remoteOs = new RemoteOS(remoteOsIp);
                waitAnimation.Start();
                _remoteOs.IsRemoteOsAvailable();
                waitAnimation.Abort();
                UtilCmd.PressAnyContinue("The communication between the Local OS and the Remote OS established successfully. Press any key to continue.");
            }
            catch (Exception)
            {
                waitAnimation.Abort();
                UtilCmd.WriteTitle(currentTitle);
                throw;
            }
        }
示例#9
0
 private void CustomizeIp()
 {
     while (true)
     {
         var remoteOsIp = UtilCmd.ReadLine();
         if (remoteOsIp.Equals("q", StringComparison.CurrentCultureIgnoreCase))
         {
             break;
         }
         if (UtilRegex.IsIp(remoteOsIp))
         {
             _xmlOps.SetRemoteOsIp(remoteOsIp);
             ConnectRemoteOsAvailable(remoteOsIp);
             break;
         }
         else
         {
             UtilCmd.WriteLine("The words you input is not a invalid IP. Re-input or input \"q\" to quit.");
         }
     }
 }