static void Logout() { inputCleared = true; user = null; Draw.Status(-1, false); ClearEntry(); ReaderHardware.Logout(); try { controller.Logout(key); } catch (Exception ex) { Log.Exception(ex); switch (ex.InnerException) { case HttpRequestException e when e.Message == "Response status code does not indicate success: 500 (Internal Server Error).": break; default: Connect(); break; } return; } }
static void EnterServiceMenu() { UpdateStatus(); var draw = true; var trigger = false; while (true) { if (draw) { Draw.MenuOverride = true; Draw.Service($@"Version: {status.Version} Uptime: {status.Uptime} Hardware: {status.Hardware} IP Address: {status.Ip} Reader Id: {status.Id} Server: {status.Server} Controller: {status.Controller} Snapshot: {status.LocalSnapshot} [1] Set Reader Id [2] Set Server [3] Test Cabinet [4] Toggle Trigger [5] Update Reader [6] Reboot Reader [7] Shutdown Reader [8] Exit App [9] Download Snapshot"); draw = false; } var input = ReaderHardware.Read(); if (input.Length != 1) { continue; } switch (input[0]) { case 'A': Draw.MenuOverride = false; Draw.Loading("Reconnecting"); return; case '1': EnterReaderId(); break; case '2': EnterServer(); break; case '3': EnterCabinetMenu(); break; case '4': if (trigger) { trigger = false; ReaderHardware.Logout(); } else { trigger = true; ReaderHardware.Login(); } break; case '5': switch (ReaderHardware.Platform) { case HardwareType.OrangePi: Process.Start("bash", "-c \"cd /tmp; rm -f installOPi.sh; wget https://raw.githubusercontent.com/DanDude0/MilwaukeeMakerspacePiFobReader/master/installOPi.sh; chmod +x installOPi.sh; sudo ./installOPi.sh\""); break; case HardwareType.RaspberryPi: Process.Start("bash", "-c \"cd /tmp; rm -f installRPi.sh; wget https://raw.githubusercontent.com/DanDude0/MilwaukeeMakerspacePiFobReader/master/installRPi.sh; chmod +x installRPi.sh; sudo ./installRPi.sh\""); break; } Process.Start("systemctl", "stop MmsPiW26Interface"); Process.Start("systemctl", "stop MmsPiFobReader"); Environment.Exit(0); break; case '6': Process.Start("reboot"); Process.Start("systemctl", "stop MmsPiW26Interface"); Process.Start("systemctl", "stop MmsPiFobReader"); Environment.Exit(0); break; case '7': Process.Start("shutdown", "-hP 0"); Process.Start("systemctl", "stop MmsPiW26Interface"); Process.Start("systemctl", "stop MmsPiFobReader"); Environment.Exit(0); break; case '8': Process.Start("systemctl", "stop MmsPiFobReader"); Environment.Exit(0); break; case '9': Draw.Loading("Downloading Database Snapshot"); //TODO: If we can talk to the server, push attempt history back up BEFORE we overwrite it. try { server.DownloadSnapshot(); Draw.Service("Snapshot updated"); Thread.Sleep(2000); } catch { Draw.Service("Could not download snapshot"); Thread.Sleep(2000); } UpdateStatus(); break; } draw = true; } }