public void run() { Console.WriteLine("patch start"); string name = "[PATCH]"; Logger logger = new Logger(logPath + name + DateTime.Now.ToString("yyyyMMdd") + ".log"); AutomationTaskParameter atpKill = new AutomationTaskParameter(); atpKill.ClientID = clientID; atpKill.AcknowledgeURL = urlKillAck; atpKill.Name = name; atpKill.Logger = logger; atpKill.IsRepeat = false; atpKill.CommandURL = urlKill; atpKill.Observer = this; KillTask taskKill = new KillTask(atpKill); taskKill.start(); if (taskKill.MissionCompleted) { Console.WriteLine("kill succeed. getting download command."); AutomationTaskParameter atpDownload = new AutomationTaskParameter(); atpDownload.ClientID = clientID; atpDownload.AcknowledgeURL = urlDownloadAck; atpDownload.Name = name; atpDownload.Logger = logger; atpDownload.IsRepeat = false; atpDownload.CommandURL = urlDownload; atpDownload.Observer = this; DownloadTaskParameter dtp = new DownloadTaskParameter(downloadPath); DownloadTask taskDownload = new DownloadTask(atpDownload, dtp); taskDownload.start(); if (taskDownload.MissionCompleted) { Console.WriteLine("download succeed. getting execution command."); AutomationTaskParameter atpExec = new AutomationTaskParameter(); atpExec.ClientID = clientID; atpExec.AcknowledgeURL = urlExecuteAck; atpExec.Name = name; atpExec.Logger = logger; atpExec.IsRepeat = false; atpExec.CommandURL = urlExecute; atpExec.Observer = this; ExecuteTask taskExec = new ExecuteTask(atpExec); taskExec.start(); if (taskExec.MissionCompleted) { Console.WriteLine("patch complete."); } } } logger.print("press <Enter> to exit."); Console.ReadLine(); }
void run() { while (true) { hasError = false; print("Application start."); taskDownload.start(); taskUpload.start(); taskExecute.start(); taskKill.start(); taskSQL.start(); print("All tasks started. Wait for completion..."); while (!hasError) { Thread.Sleep(500); } Buzzer.Beep(); print("Auto revive in " + reviveTime + " seconds."); int reviveCount = reviveTime; while (reviveCount >= 0) { string msg = "\rAuto revive in " + reviveCount + " seconds"; string dots; if (reviveCount % 3 == 0) { dots = "..."; } else if (reviveCount % 3 == 1) { dots = ".."; } else { dots = "."; } Console.Write("\r" + new string(' ', Console.WindowWidth - 1) + "\r"); Console.Write(msg + dots); Thread.Sleep(1000); reviveCount--; } isTerminating = false; if (reviveFromDead) { print("The program revive now."); continue; } else { break; } } print("Press <Enter> to exit."); Console.ReadLine(); }