/// <summary>
 /// Confirm the configuration saving before quit the application
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
 {
     // Check if the config have been change and haven't been save
     if (!CheckSaveConfig())
     {
         e.Cancel = true;
     }
     else
     {
         Hide();
         if (transportService != null)
         {
             transportService.Dispose();
             transportService = null;
         }
     }
 }
Example #2
0
        private void btUninstall_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(this, "Do you really want to UNINSTALL the DKIM Exchange Agent?\n", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    ExchangeServer.UninstallDkimTransportAgent();
                    RefreshTransportServiceAgents();
                    TransportService ts = new TransportService();
                    try
                    {
                        ts.Do(TransportServiceAction.Restart, delegate(string msg)
                        {
                            MessageBox.Show(msg, "Service error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        });
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Couldn't restart MSExchangeTransport Service. Please restart it manually. \n" + ex.Message, "Error restarting Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        ts.Dispose();
                    }
                    MessageBox.Show(this, "Transport Agent unregistered from Exchange. Please remove the folder manually: '" + Constants.DkimSignerPath + "'\nWARNING: If you remove the folder, keep a backup of your settings and keys!", "Uninstalled", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    /*if (MessageBox.Show(this, "Transport Agent removed from Exchange. Would you like me to remove all the settings for Exchange DKIM Signer?'", "Remove settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                     * {
                     *  if (File.Exists(Path.Combine(Constants.DKIM_SIGNER_PATH, "settings.xml")))
                     *      File.Delete(Path.Combine(Constants.DKIM_SIGNER_PATH, "settings.xml"));
                     * }*/
                    /*if (MessageBox.Show(this, "Transport Agent removed from Exchange. Would you like me to remove the folder '" + Constants.DKIM_SIGNER_PATH + "' and all its content?\nWARNING: All your settings and keys will be deleted too!", "Remove files?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                     * {
                     *  var dir = new DirectoryInfo(Constants.DKIM_SIGNER_PATH);
                     *  dir.Delete(true);
                     * }*/
                }
                catch (ExchangeServerException ex)
                {
                    MessageBox.Show(this, ex.Message, "Uninstall error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #3
0
        private void btDisable_Click(object sender, EventArgs e)
        {
            try
            {
                if (btDisable.Text == "Disable")
                {
                    ExchangeServer.DisableDkimTransportAgent();
                }
                else
                {
                    ExchangeServer.EnableDkimTransportAgent();
                }

                RefreshTransportServiceAgents();
                RefreshMoveButtons(true);

                TransportService ts = new TransportService();
                try
                {
                    ts.Do(TransportServiceAction.Restart, delegate(string msg)
                    {
                        MessageBox.Show(msg, "Service error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Couldn't restart MSExchangeTransport Service. Please restart it manually. \n" + ex.Message, "Error restarting Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    ts.Dispose();
                }
            }
            catch (ExchangeServerException ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #4
0
        private void UninstallWindow_Shown(object sender, EventArgs e)
        {
            if (
                MessageBox.Show("Uninstall Exchange DKIM Signer?", "Uninstall?", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) != DialogResult.Yes)
            {
                this.Close();
                Application.Exit();
                return;
            }

            try
            {
                lbStep.Text = "Uninstalling Exchange Agent";
                ExchangeServer.UninstallDkimTransportAgent();

                lbStep.Text = "Restarting MS Exchange Transport";
                TransportService ts = new TransportService();
                try
                {
                    ts.Do(TransportServiceAction.Restart, delegate(string msg)
                    {
                        MessageBox.Show(msg, "Service error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Couldn't restart MSExchangeTransport Service. Please restart it manually. \n" + ex.Message, "Error restarting Service", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    ts.Dispose();
                }


                lbStep.Text = "Deleting directory";

                if (
                    MessageBox.Show(this,
                                    "The directory '" + Constants.DkimSignerPath +
                                    "' will now be deleted. Please make a backup of the keys stored within this directory before continuing.\n Continue deleting?",
                                    "Delete directory?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        Directory.Delete(Constants.DkimSignerPath, true);
                    }
                    catch (Exception)
                    {
                        //ignore exception. Delete directory on reboot
                        if (!NativeMethods.MoveFileEx(Constants.DkimSignerPath, null, MoveFileFlags.DelayUntilReboot))
                        {
                            MessageBox.Show(
                                "Unable to schedule '" + Constants.DkimSignerPath + "' for deletion on next reboot.",
                                "Delete error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }

                lbStep.Text = "Removing registry entry";
                CplControl.Unregister();
                UninstallerRegistry.Unregister();

                /*if (MessageBox.Show(this, "Transport Agent removed from Exchange. Would you like me to remove all the settings for Exchange DKIM Signer?'", "Remove settings?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                 * {
                 *  if (File.Exists(Path.Combine(Constants.DKIM_SIGNER_PATH, "settings.xml")))
                 *      File.Delete(Path.Combine(Constants.DKIM_SIGNER_PATH, "settings.xml"));
                 * }*/
                /*if (MessageBox.Show(this, "Transport Agent removed from Exchange. Would you like me to remove the folder '" + Constants.DKIM_SIGNER_PATH + "' and all its content?\nWARNING: All your settings and keys will be deleted too!", "Remove files?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                 * {
                 *  var dir = new DirectoryInfo(Constants.DKIM_SIGNER_PATH);
                 *  dir.Delete(true);
                 * }*/
                lbStep.Text             = "Uninstall complete";
                progressUninstall.Style = ProgressBarStyle.Continuous;
                progressUninstall.Value = 100;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Uninstall error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            btClose.Enabled = true;
        }