private void cleanupNMTToolStripMenuItem_Click(object sender, EventArgs e) { string Warning = ""; string Command = Settings.Default.CommandsScriptURL.Substring(Settings.Default.CommandsScriptURL.LastIndexOf('/') + 1); Command = Command.Substring(0, Command.Length - 3) + "cgi"; string WarningTitle = ""; if (sender == shutdownNMTToolStripMenuItem) { Warning = Resources.MessageBox_HaltWarning; WarningTitle = Resources.MessageBox_HaltWarningCaption; Command += "?halt"; } else if (sender == cleanupNMTDeepToolStripMenuItem) { Warning = Resources.MessageBox_DeepCleanWarning; WarningTitle = Resources.MessageBox_DeepCleanCaption; Command += "?deepclean"; } else if (sender == cleanupNMTToolStripMenuItem) { Warning = Resources.MessageBox_CleanWarning; WarningTitle = Resources.MessageBox_CleanCaption; Command += "?clean"; } else { Warning += Resources.MessageBox_RestartNMTConfirm; WarningTitle = Resources.MessageBox_RestartNMTCaption; Command += "?reboot"; } if (MessageBox.Show(Warning, WarningTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { try { btnPrev.Enabled = btnNext.Enabled = btnExit.Enabled = menuStrip1.Enabled = false; Application.DoEvents(); string LocalFolder = HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.CommandsScriptURL, Constants.TemporaryFolder, true, null); RepositoryApplicationInfo app = new RepositoryApplicationInfo(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new string[0], Command, string.Empty, string.Empty); UploadInstaller ulinst = new UploadInstaller(app, ProgressChanges, OnInstallComplete); ulinst.Install(); } catch (Exception ex) { menuStrip1.Enabled = true; UpdateButtonState(); Logger.GetInstance().AddLogLine(LogLevel.Error, "Cleanup or restart of NMT failed", ex); MessageBox.Show(Resources.MessageBox_CleanupActionFailed, Resources.MessageBox_CleanupActionCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void installFirmwareToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show(Resources.MessageBox_InstallFirmwareWarning, Resources.MessageBox_InstallFirmwareCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { OpenFileDialog odf = new OpenFileDialog(); odf.Title = Resources.FileDialog_SelectFirmwareFileCaption; odf.Filter = Resources.FileDialog_SelectFirmwareFileFilter; if (odf.ShowDialog() == DialogResult.OK) { try { string LocalFolder = Constants.TemporaryFolder; if (Directory.Exists(LocalFolder)) { Directory.Delete(LocalFolder, true); } Directory.CreateDirectory(LocalFolder); File.Copy(odf.FileName, LocalFolder + "firmware.zip"); SimpleUnZipper.UnZipTo(LocalFolder + "firmware.zip", LocalFolder); File.Delete(LocalFolder + "firmware.zip"); if ((Directory.GetFiles(LocalFolder).Length == 0) && (Directory.GetDirectories(LocalFolder).Length == 1)) { LocalFolder = Directory.GetDirectories(LocalFolder)[0] + Path.DirectorySeparatorChar; } HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.CommandsScriptURL, LocalFolder, false, ProgressChanges); btnPrev.Enabled = btnNext.Enabled = btnExit.Enabled = menuStrip1.Enabled = false; Application.DoEvents(); RepositoryApplicationInfo app = new RepositoryApplicationInfo(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new string[0], "commands.cgi?firmwareinstall", string.Empty, string.Empty); UploadInstaller ulinst = new UploadInstaller(app, ProgressChanges, OnInstallComplete); ulinst.Install(); } catch (Exception ex) { menuStrip1.Enabled = true; UpdateButtonState(); Logger.GetInstance().AddLogLine(LogLevel.Error, "Installing firmware failed", ex); MessageBox.Show(Resources.MessageBox_InstallFirmwareFailed, Resources.MessageBox_InstallFirmwareCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public override bool Execute() { InstallationSuccessful = null; InstallationResult = string.Empty; //remove unselected background; if required if (panelResults["SelectedItem"] is RepositoryThemeInfo) { //fix background selection if (gbxThemeBackgroundSelect.Visible) { SetBackgroundSelection(); } } UploadInstaller upli = new UploadInstaller(panelResults["SelectedItem"] as RepositoryFileInfoBase, OnProgress, OnInstallationComplete); panelResults.Remove("InstallResult"); upli.Install(); while (InstallationSuccessful == null) { Thread.Sleep(10); Application.DoEvents(); } panelResults["InstallResult"] = InstallationResult; if ((bool)InstallationSuccessful) { Directory.Delete(Constants.TemporaryFolder, true); } return((bool)InstallationSuccessful); }