private void SaveButton_Click(object sender, EventArgs e) { if (!configurationDirty) { Close(); return; } if (InvalidControls > 0) { DialogResult result = MessageBox.Show("Some required fields are missing or invalid. Save changes anyway?", "Save changes?", MessageBoxButtons.OKCancel); if (result == DialogResult.Cancel) { return; } // else 'yes' so continue with the save... } bool somethingChanged = false; List <string> args = new List <string>(); string fullPath = null; if ((fullPath = SaveMailSettingsIfChanged()) != null) { args.Add(fullPath); somethingChanged = true; } if ((fullPath = SaveSmokeSignalSettingsIfChanged()) != null) { args.Add(fullPath); somethingChanged = true; } // resart the service if it is running in order for it to pickup new config if (somethingChanged && (ServiceManager.ServiceStatus("SmokeSignalSrvc") == ServiceControllerStatus.Running)) { using (ChangeCursor c = new ChangeCursor(Cursors.WaitCursor)) { if (ServiceManager.DoesServiceExist("SmokeSignalSrvc")) { // need to restart the Smoke Signal Service ServiceManager.StopService("SmokeSignalSrvc"); ServiceManager.StartService("SmokeSignalSrvc", args); } } serviceConfigured = (InvalidControls == 0); } ResetSaveButton(false); }
private void SendTestEmailButton_Click(object sender, EventArgs e) { int top = this.Bounds.Top; int right = this.Bounds.Right; if (!((bool)HostnameTextBox.Tag) || !((bool)PortTextBox.Tag)) { MessageBox.Show("A valid Hostname and Port are required, at a minimum, to send a test email"); return; } string emailAddr = Microsoft.VisualBasic.Interaction.InputBox( "Enter \"To\" email addr. A test email will be sent, verifying that your email configuration is working.", "Test email", "", right - 70, top + 130); if (string.IsNullOrEmpty(emailAddr)) { MessageBox.Show("No test email was sent."); return; } if (!Utils.IsValidEmail(emailAddr)) { MessageBox.Show(string.Format("\"{0}\" is an invalid email address. No test email was sent.", emailAddr)); return; } try { using (ChangeCursor cc = new ChangeCursor(Cursors.WaitCursor)) { Notifier mailer = new Notifier(); int port = 0; Int32.TryParse(PortTextBox.Text, out port); mailer.SentTestEmail(emailAddr, FromTextBox.Text, HostnameTextBox.Text, port, UsernameTextBox.Text, PasswordTextBox.Text, DefaultCredsCheckBox.Checked, SendWelcomeEmailCheckBox.Checked ? ExtraEmailMessage.Text : null); } MessageBox.Show("Mail was successfully sent, please check your InBox"); } catch (InvalidOperationException ex) { MessageBox.Show(string.Format("Sending mail failed. Exception: {0}, Message: {1}", ex.GetType().ToString(), ex.Message)); } catch (SmtpException ex) { MessageBox.Show(string.Format("Sending mail failed. Exception: {0}, Message: {1}", ex.GetType().ToString(), ex.Message)); } }
private void installButton_Click(object sender, EventArgs e) { WebClient wc = new WebClient(); DialogResult result = MessageBox.Show("Smoke Signal will automatically quit once the installation of the new version commences.", SmokeSignalSetup.Properties.Resources.DialogTitle, MessageBoxButtons.OKCancel); this.DialogResult = DialogResult.OK; if (result != DialogResult.OK) { this.DialogResult = result; return; } // delete any "SkipUpdate" registry entry //using (RegistryKey regKey = Registry.CurrentUser.OpenSubKey(Program.RegistryRootPath, true)) //{ // regKey.DeleteValue("SkipUpdate", false); //} try { //string flavor64 = OSUtils.IsOS64Bit() ? ".64x" : ""; string flavor64 = ""; string folder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache); string filename = System.IO.Path.Combine(folder, string.Format("SSInstaller{0}.msi", flavor64)); using (ChangeCursor cc = new ChangeCursor(Cursors.WaitCursor)) { wc.DownloadFile(string.Format("{0}{1}.{2}{3}{4}", LocationURL(Destination.InstallerBits), this.rawVersionString, "SSInstaller", flavor64, ".msi"), filename); // Launch the msi file to start the installation ProcessStartInfo psi = new ProcessStartInfo(filename); psi.UseShellExecute = true; Process.Start(psi); } } catch (Exception ex) { this.DialogResult = DialogResult.Abort; MessageBox.Show(string.Format("Installation failed: {0}", ex.Message), SmokeSignalSetup.Properties.Resources.DialogTitle); } this.Close(); }
private void SaveButton_Click(object sender, EventArgs e) { if (!configurationDirty) { Close(); return; } if (InvalidControls > 0) { DialogResult result = MessageBox.Show("Some required fields are missing or invalid. Save changes anyway?", "Save changes?", MessageBoxButtons.OKCancel); if (result == DialogResult.Cancel) { return; } // else 'yes' so continue with the save... } bool somethingChanged = false; List<string> args = new List<string>(); string fullPath = null; if ((fullPath = SaveMailSettingsIfChanged()) != null) { args.Add(fullPath); somethingChanged = true; } if ((fullPath = SaveSmokeSignalSettingsIfChanged()) != null) { args.Add(fullPath); somethingChanged = true; } // resart the service if it is running in order for it to pickup new config if (somethingChanged && (ServiceManager.ServiceStatus("SmokeSignalSrvc") == ServiceControllerStatus.Running)) { using (ChangeCursor c = new ChangeCursor(Cursors.WaitCursor)) { if (ServiceManager.DoesServiceExist("SmokeSignalSrvc")) { // need to restart the Smoke Signal Service ServiceManager.StopService("SmokeSignalSrvc"); ServiceManager.StartService("SmokeSignalSrvc", args); } } serviceConfigured = (InvalidControls == 0); } ResetSaveButton(false); }