private void cmdRemove_Click(object sender, EventArgs e) { selectedNumberOfMods = 0; List <string> modList = new List <string>(); foreach (DataGridViewRow gridRow in grdMods.SelectedRows) { modList.Add(gridRow.Cells[0].Value.ToString()); selectedNumberOfMods++; } if (selectedNumberOfMods == 0) { SwingMessageBox.Show("You haven't selected any mods to uninstall!", "Mod Uninistall", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (SwingMessageBox.Show($"Do you really want to remove {string.Join(", ", modList.ToArray())}?", "Remove Mod", MessageBoxButtons.YesNo, MessageBoxIcon.Question).Equals(DialogResult.No)) { return; } LockButtons(true); installerTask = Task.Run(() => RemoveSelectedMods(), installCts.Token); // Below message Will be replaced by spinner }
private void CmdInstall_Click(object sender, EventArgs e) { frmInstallRestore installRestoreForm = new frmInstallRestore(); if (shiftPressed) { shiftPressed = false; if (!SwingMessageBox.Show("This is very dangerous and should only be used incase of emergency! Only use " + "if you have already spoken to a dev and your console's nand needs a full restore. This " + "restore is generated from your original NAND partition backups. DO NOT USE THIS TO FACTORY " + "RESET YOUR CONSOLE! PLEASE UNINSTALL INSTEAD! Do you wish to continue?", "WARNING!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning).Equals(DialogResult.Yes)) { return; } if (!SwingMessageBox.Show("Are you sure you want to continue? Please note that ModMyClassic will not be responsible for any damages caused " + "to your console. Please ensure you speak to a developer first!", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation).Equals(DialogResult.Yes)) { return; } installRestoreForm.RestoreMode = true; } else if (controlPressed) { installRestoreForm.RecoveryMode = true; } if (installRestoreForm.ShowDialog() == DialogResult.OK) { } }
private static void HandleGeneralException(Exception ex) { SwingMessageBox.Show("An unexpected error occurred. If this error persists, please contact the developers at ModMyClassic. The application will exit now.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); LogException(ex); Application.Exit(); }
private static void HandleGeneralException(Exception ex) { SwingMessageBox.Show("An unexpected error occurred. If this error persists, please contact the developers at ModMyClassic. The application will exit now.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); File.WriteAllText($@"{Application.StartupPath}\lunar_data\logs\error-{DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss")}.txt", ex.ToString()); Application.Exit(); }
private void AddMods(string[] fileNames) { ShowLoadingBox("INSTALLING MOD(S)"); foreach (string filePath in fileNames) { try { using (ScpClient scp = new ScpClient("169.254.215.100", "root", "5A7213")) { string md5 = GetMd5Hash(filePath); scp.Connect(); string fileName = Path.GetFileName(filePath); string parsedfileName = fileName.Replace("_SEGAMD", "").Replace(".mod", "").ToUpper(); UpdateStatus("Uploading " + fileName); scp.Upload(File.OpenRead(filePath), $"/tmp/{fileName}"); using (SshClient ssh = new SshClient("169.254.215.100", "root", "5A7213")) { ssh.Connect(); string md5CommandText = $"cd /tmp;[ \"$(md5sum {fileName})\" = " + $"\"$(echo $'{md5} {fileName}')\" ] " + "&& echo \"File integrity OK\" || " + "echo \"File intergrity FAIL\""; string result = ssh.RunCommand(md5CommandText).Result; if (result.Contains("File integrity OK")) { UpdateStatus("Installing " + fileName); result = ssh.RunCommand($"cd /tmp ; mod-install {fileName}").Result; if (result.Contains("[PROJECT LUNAR](ERROR)")) { result = result.Replace("[PROJECT LUNAR](ERROR)", ""); throw new InvalidDataException(parsedfileName + "'\n\rFailed to install!\n\rReason: " + result); } } else { throw new InvalidDataException(parsedfileName + "'\n\rFailed to install!\n\rReason: Mod has corrupted in transit. Please try again."); } } } } catch (InvalidDataException ex) { string failureResult = ex.ToString(); Console.WriteLine(failureResult); failureResult = failureResult.Replace("System.IO.InvalidDataException: ", "'"); string[] splitFailureResult = failureResult.Split(new string[] { "at ProjectLunarUI" }, StringSplitOptions.None); SwingMessageBox.Show(splitFailureResult[0], "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } using (SshClient ssh = new SshClient("169.254.215.100", "root", "5A7213")) { ssh.Connect(); ssh.RunCommand("killall sdl_display &> \"/dev/null\""); ssh.RunCommand("sdl_display /opt/project_lunar/etc/project_lunar/IMG/PL_UpdateDone.png &"); UpdateStatus("Restarting console"); Thread.Sleep(5000); var shell = ssh.CreateShellStream("Lunar", 120, 9999, 120, 9999, 65536); shell.DataReceived += Shell_DataReceived; shell.WriteLine($"cd /"); Thread.Sleep(500); shell.WriteLine($"kill_ui_programs"); Thread.Sleep(500); shell.WriteLine($"restart"); while (ssh.IsConnected) { if (installCts.IsCancellationRequested) { installCts.Dispose(); return; } Thread.Sleep(500); } Debug.WriteLine("Finished wait."); } UpdateStatus("Waiting for console"); ShowLoadingBox("RESTARTING CONSOLE"); checkModTask = Task.Run(() => GetInstalledMods(), chkModCts.Token); //SwingMessageBox.Show("Mods installed successfuly.", "Mod Install", MessageBoxButtons.OK, MessageBoxIcon.Information); }