Exemplo n.º 1
0
        /// <summary>
        /// UnConfigure Features
        /// </summary>
        public static void UnConfigureFeatures()
        {
            frmApply apply = new frmApply(false);

            apply.Text = "UnConfigure Features";
            apply.lblDescription.Text = "Select the features that you would like to remove configuration for";

            if (apply.ShowDialog() == DialogResult.OK)
            {
                var progress = new frmProgress();
                try
                {
                    progress.Show();
                    XmlDocument configDocument = new XmlDocument();
                    configDocument.Load(ConfigurationApplicationContext.s_configFile);
                    int i = 0;
                    foreach (IConfigurationPanel itm in apply.chkActions.CheckedItems)
                    {
                        progress.Status     = (int)((++i / (float)apply.chkActions.CheckedItems.Count) * 100);
                        progress.StatusText = String.Format("Removing Configuration for {0}...", itm.ToString());
                        Application.DoEvents();

                        itm.UnConfigure(configDocument);
                    }
                    configDocument.Save(ConfigurationApplicationContext.s_configFile);
                    progress.StatusText = "Executing post configuration tasks...";
                    Application.DoEvents();
                    ConfigurationApplicationContext.OnConfigurationApplied();
                }
                finally
                {
                    progress.Close();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deploy
        /// </summary>
        public static void Deploy(StringCollection deploymentList, Dictionary <String, StringCollection> options)
        {
            frmProgress progress = new frmProgress();

            try
            {
                var configurationDom = new XmlDocument();

                if (File.Exists(ConfigurationApplicationContext.s_configFile))
                {
                    configurationDom.Load(ConfigurationApplicationContext.s_configFile);
                }
                else
                {
                    configurationDom.LoadXml(Resources.empty);
                }
                // Configure
                progress.Show();
                int i = 0;
                foreach (var pnl in ConfigurationApplicationContext.s_configurationPanels.FindAll(o => o is IAutoDeployConfigurationPanel && deploymentList.Contains(o.Name)))
                {
                    if (pnl.IsConfigured(configurationDom))
                    {
                        pnl.UnConfigure(configurationDom);
                    }
                    progress.StatusText = String.Format("Configuring {0}...", pnl.ToString());
                    (pnl as IAutoDeployConfigurationPanel).PrepareConfigure(configurationDom, options);
                    progress.Status = (int)((++i / (float)deploymentList.Count) * 100);
                    Application.DoEvents();
                    pnl.Configure(configurationDom);
                }

                // Always applied stuff changes
                foreach (var pnl in ConfigurationApplicationContext.s_configurationPanels.FindAll(o => o is IAlwaysDeployedConfigurationPanel))
                {
                    pnl.Configure(configurationDom);
                }

                configurationDom.Save(ConfigurationApplicationContext.s_configFile);
                progress.StatusText = "Executing post configuration tasks...";
                ConfigurationApplicationContext.OnConfigurationApplied();
            }
            finally
            {
                progress.Close();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Configure features
        /// </summary>
        public static void ConfigureFeatures()
        {
            frmApply apply = new frmApply(true);

            apply.Text = "Configure Features";
            apply.lblDescription.Text = "Select the features that you would like to apply configuration for";
            if (apply.ShowDialog() == DialogResult.OK)
            {
                var progress = new frmProgress();
                int i        = 0;

                XmlDocument configDocument = new XmlDocument();
                try
                {
                    // Try to make a backup
                    try
                    {
                        File.Copy(ConfigurationApplicationContext.s_configFile, ConfigurationApplicationContext.s_configFile + ".bak." + DateTime.Now.ToString("yyyy-MMM-dd"));
                    }
                    catch (Exception e)
                    {
                        if (MessageBox.Show("The configuration file could not be backed up, would you like to proceed making modifications without a backup?", "Backup failed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            return;
                        }
                    }

                    progress.Show();
                    configDocument.Load(ConfigurationApplicationContext.s_configFile);
                    foreach (IConfigurationPanel itm in apply.chkActions.CheckedItems)
                    {
                        try
                        {
                            if (!itm.Validate(configDocument))
                            {
                                MessageBox.Show(String.Format("Configuration of item '{0}' failed, validation failed", itm), "Validation Failure");
                                continue;
                            }
                        }
                        catch (ConfigurationException e)
                        {
                            MessageBox.Show(String.Format("Configuration of item '{0}' failed, validation failed with reason {1}", itm, e.Message), "Validation Failure");
                            continue;
                        }
                        progress.Status     = (int)((++i / (float)apply.chkActions.CheckedItems.Count) * 100);
                        progress.StatusText = String.Format("Configuring {0}...", itm.ToString());
                        Application.DoEvents();
                        itm.Configure(configDocument);
                    }

                    // Always applied stuff changes
                    foreach (var itm in ConfigurationApplicationContext.s_configurationPanels.FindAll(o => o is IAlwaysDeployedConfigurationPanel))
                    {
                        if (!itm.Validate(configDocument))
                        {
                            MessageBox.Show(String.Format("Configuration of item '{0}' failed, validation failed", itm), "Validation Failure");
                            continue;
                        }
                        itm.Configure(configDocument);
                    }
                    configDocument.Save(ConfigurationApplicationContext.s_configFile);
                    progress.StatusText = "Executing post configuration tasks...";
                    ConfigurationApplicationContext.OnConfigurationApplied();
                }
                catch (Exception ex)
                {
#if DEBUG
                    MessageBox.Show(ex.ToString(), "Error Configuring Service");
#else
                    MessageBox.Show(ex.Message, "Error Configuring Service");
#endif
                    foreach (IConfigurationPanel itm in apply.chkActions.CheckedItems)
                    {
                        progress.Status     = (int)((i-- / (float)ConfigurationApplicationContext.s_configurationPanels.Count) * 100);
                        progress.StatusText = String.Format("Removing Configuration for {0}...", itm.ToString());
                        Application.DoEvents();

                        itm.UnConfigure(configDocument);
                    }

                    return;
                }
                finally
                {
                    progress.Close();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Start the configuration process...
        /// </summary>
        private void btnContinue_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            btnContinue.Enabled = false;
            try
            {
                // Start by creating the configuration file
                XmlDocument configFile = new XmlDocument();
                configFile.LoadXml(Resources.empty);
                IDatabaseConfigurator conf = cbxProviderType.SelectedItem as IDatabaseConfigurator;

                // Do an easy config ... first with the connection strings
                foreach (IConfigurationPanel pnl in ConfigurationApplicationContext.s_configurationPanels)
                {
                    if (pnl is IDataboundConfigurationPanel)
                    {
                        (pnl as IDataboundConfigurationPanel).ConnectionString     = conf.CreateConnectionStringElement(configFile, txtDatabaseAddress.Text, txtUserName.Text, txtPassword.Text, cbxDatabase.SelectedItem.ToString());
                        (pnl as IDataboundConfigurationPanel).DatabaseConfigurator = conf;
                    }
                }

                // Easy or complex?
                if (rdoEasy.Checked)
                {
                    // Save the configuration
                    var progress = new frmProgress();
                    int i        = 0;
                    try
                    {
                        progress.Show();

                        foreach (IConfigurationPanel pnl in ConfigurationApplicationContext.s_configurationPanels)
                        {
                            progress.Status         = (int)((++i / (float)ConfigurationApplicationContext.s_configurationPanels.Count) * 100);
                            progress.StatusText     = String.Format("Applying Configuration for {0}...", pnl.ToString());
                            pnl.EnableConfiguration = true;
                            pnl.Configure(configFile);
                        }
                    }
                    catch (Exception ex)
                    {
#if DEBUG
                        MessageBox.Show(ex.ToString(), "Error Configuring Service");
#else
                        MessageBox.Show(ex.Message, "Error Configuring Service");
#endif
                        foreach (IConfigurationPanel pnl in ConfigurationApplicationContext.s_configurationPanels)
                        {
                            progress.Status         = (int)((i-- / (float)ConfigurationApplicationContext.s_configurationPanels.Count) * 100);
                            progress.StatusText     = String.Format("Removing Configuration for {0}...", pnl.ToString());
                            pnl.EnableConfiguration = true;
                            pnl.UnConfigure(configFile);
                        }

                        return;
                    }
                    finally
                    {
                        progress.Close();
                    }
                    configFile.Save(ConfigurationApplicationContext.s_configFile);
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    configFile.Save(ConfigurationApplicationContext.s_configFile);
                    this.DialogResult = DialogResult.OK;
                }

                this.Close();
            }
            finally
            {
                Cursor = Cursors.Default;
                btnContinue.Enabled = true;
            }
        }