private void btDisable_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.btDisable.Text == "Disable")
                {
                    ExchangeServer.DisableDkimTransportAgent();
                }
                else
                {
                    ExchangeServer.EnableDkimTransportAgent();
                }

                this.RefreshTransportServiceAgents();
                this.refreshMoveButtons( true );

                TransportService ts = new TransportService();
                try
                {
                    ts.Do(TransportServiceAction.Restart);
                }
                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);
            }
        }
Beispiel #2
0
        // ##########################################################
        // ####################### Events ###########################
        // ##########################################################

        /// <summary>
        /// Load information in the Windowform
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainWindow_Load(object sender, EventArgs e)
        {
            this.CheckExchangeInstalled();
            this.CheckDkimSignerAvailable();
            this.CheckDkimSignerInstalled();

            // Check transport service status each second
            try
            {
                this.transportService = new TransportService();
                this.transportService.StatusChanged += new EventHandler(this.transportService_StatusUptated);
            }
            catch (ExchangeServerException) { }

            // Load setting from XML file
            this.LoadDkimSignerConfig();
        }
        // ##########################################################
        // ####################### Events ###########################
        // ##########################################################

        private void InstallWindow_Load(object sender, EventArgs e)
        {
            this.CheckExchangeInstalled();       
            try
            {
                this.transportServiceActionCompleted = new AutoResetEvent(false);
                this.transportService = new TransportService();
                this.transportService.StatusChanged += new EventHandler(this.transportService_StatusUptated);
            }
            catch (ExchangeServerException) { }

            if (this.zipUrl == null)
            {
                this.CheckDkimSignerAvailable();
            }
            else
            {
                this.gbSelectVersionToInstall.Enabled = false;
            }
        }
        // ##########################################################
        // ####################### Events ###########################
        // ##########################################################

        private void InstallWindow_Load(object sender, EventArgs e)
        {
            CheckExchangeInstalled();
            try
            {
                transportServiceActionCompleted = new AutoResetEvent(false);
                transportService = new TransportService();
                transportService.StatusChanged += transportService_StatusUptated;
            }
            catch (ExchangeServerException) { }

            if (zipUrl == null && !performInstall)
            {
                CheckDkimSignerAvailable();
            }
            else
            {
                // the dkim signer should be installed directly. Disable selection
                gbSelectVersionToInstall.Enabled = false;
            }
        }
        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();
                    this.RefreshTransportServiceAgents();
                    TransportService ts = new TransportService();
                    try
                    {
                        ts.Do(TransportServiceAction.Restart);
                    }
                    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.DKIM_SIGNER_PATH + "'\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);
                }
            }
        }
Beispiel #6
0
 /// <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 (!this.CheckSaveConfig())
     {
         e.Cancel = true;
     }
     else
     {
         this.Hide();
         this.transportService.Dispose();
         this.transportService = null;
     }
 }
        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;
        }