Esempio n. 1
0
        protected void SubmitChangesClick(object sender, EventArgs e)
        {
            IIdentity user = HttpContext.Current.User.Identity;
            WindowsIdentity wi = (WindowsIdentity)user;
            WindowsImpersonationContext impersonater = wi.Impersonate();

            try
            {
                Dictionary<string, Dictionary<string, string>> newSettings = new Dictionary<string, Dictionary<string, string>>();
                MdwsConfiguration mdwsConfig = new MdwsConfiguration();
                Dictionary<string, Dictionary<string, string>> oldSettings = mdwsConfig.AllConfigs;

                newSettings.Add(MdwsConfigConstants.MDWS_CONFIG_SECTION, new Dictionary<string, string>());
                newSettings.Add(MdwsConfigConstants.SQL_CONFIG_SECTION, new Dictionary<string, string>());
                newSettings.Add(dropdownFacadeName.Text, new Dictionary<string, string>());

                newSettings[MdwsConfigConstants.MDWS_CONFIG_SECTION].Add(MdwsConfigConstants.SESSIONS_LOG_LEVEL, radioMdwsSessionsLogLevel.SelectedValue);
                newSettings[MdwsConfigConstants.MDWS_CONFIG_SECTION].Add(MdwsConfigConstants.SESSIONS_LOGGING, radioMdwsSessionsLogging.SelectedValue);
                newSettings[MdwsConfigConstants.MDWS_CONFIG_SECTION].Add(MdwsConfigConstants.MDWS_PRODUCTION, radioButtonMdwsProduction.SelectedValue);

                newSettings[MdwsConfigConstants.SQL_CONFIG_SECTION].Add(MdwsConfigConstants.SQL_HOSTNAME, textboxSqlServerPath.Text);
                newSettings[MdwsConfigConstants.SQL_CONFIG_SECTION].Add(MdwsConfigConstants.SQL_DB, textboxSqlDatabase.Text);
                newSettings[MdwsConfigConstants.SQL_CONFIG_SECTION].Add(MdwsConfigConstants.SQL_USERNAME, textboxSqlUsername.Text);
                newSettings[MdwsConfigConstants.SQL_CONFIG_SECTION].Add(MdwsConfigConstants.SQL_PASSWORD, textboxSqlPassword.Text);

                newSettings[dropdownFacadeName.Text].Add(MdwsConfigConstants.FACADE_PRODUCTION, radioFacadeIsProduction.SelectedValue);
                if (String.IsNullOrEmpty(textboxFacadeSitesFileName.Text))
                {
                    newSettings[dropdownFacadeName.Text].Add(MdwsConfigConstants.FACADE_SITES_FILE, MdwsConstants.DEFAULT_SITES_FILE_NAME);
                }
                else
                {
                    newSettings[dropdownFacadeName.Text].Add(MdwsConfigConstants.FACADE_SITES_FILE, textboxFacadeSitesFileName.Text);
                }

                foreach (string key in newSettings.Keys)
                {
                    // if old settings doesn't have facade config, add it
                    if (!oldSettings.ContainsKey(key))
                    {
                        oldSettings.Add(key, new Dictionary<string,string>());
                    }
                    foreach (string settingKey in newSettings[key].Keys)
                    {
                        if (oldSettings[key].ContainsKey(settingKey))
                        {
                            oldSettings[key][settingKey] = newSettings[key][settingKey];
                        }
                        else
                        {
                            oldSettings[key].Add(settingKey, newSettings[key][settingKey]);
                        }
                    }
                }

                gov.va.medora.mdo.dao.file.ConfigFileDao fileDao = new mdo.dao.file.ConfigFileDao(mdwsConfig.ConfigFilePath);
                fileDao.writeToFile(oldSettings); // not really old settings any more
            }
            catch (Exception exc)
            {
                labelMessage.Text = exc.ToString();
            }
            finally
            {
                impersonater.Undo();
            }
            setForm();
        }
Esempio n. 2
0
        protected void SubmitChangesClick(object sender, EventArgs e)
        {
            IIdentity                   user         = HttpContext.Current.User.Identity;
            WindowsIdentity             wi           = (WindowsIdentity)user;
            WindowsImpersonationContext impersonater = wi.Impersonate();

            try
            {
                Dictionary <string, Dictionary <string, string> > newSettings = new Dictionary <string, Dictionary <string, string> >();
                MdwsConfiguration mdwsConfig = new MdwsConfiguration();
                Dictionary <string, Dictionary <string, string> > oldSettings = mdwsConfig.AllConfigs;

                newSettings.Add(MdwsConfigConstants.MDWS_CONFIG_SECTION, new Dictionary <string, string>());
                newSettings.Add(MdwsConfigConstants.SQL_CONFIG_SECTION, new Dictionary <string, string>());
                newSettings.Add(dropdownFacadeName.Text, new Dictionary <string, string>());

                newSettings[MdwsConfigConstants.MDWS_CONFIG_SECTION].Add(MdwsConfigConstants.SESSIONS_LOG_LEVEL, radioMdwsSessionsLogLevel.SelectedValue);
                newSettings[MdwsConfigConstants.MDWS_CONFIG_SECTION].Add(MdwsConfigConstants.SESSIONS_LOGGING, radioMdwsSessionsLogging.SelectedValue);
                newSettings[MdwsConfigConstants.MDWS_CONFIG_SECTION].Add(MdwsConfigConstants.MDWS_PRODUCTION, radioButtonMdwsProduction.SelectedValue);

                newSettings[MdwsConfigConstants.SQL_CONFIG_SECTION].Add(MdwsConfigConstants.SQL_HOSTNAME, textboxSqlServerPath.Text);
                newSettings[MdwsConfigConstants.SQL_CONFIG_SECTION].Add(MdwsConfigConstants.SQL_DB, textboxSqlDatabase.Text);
                newSettings[MdwsConfigConstants.SQL_CONFIG_SECTION].Add(MdwsConfigConstants.SQL_USERNAME, textboxSqlUsername.Text);
                newSettings[MdwsConfigConstants.SQL_CONFIG_SECTION].Add(MdwsConfigConstants.SQL_PASSWORD, textboxSqlPassword.Text);

                newSettings[dropdownFacadeName.Text].Add(MdwsConfigConstants.FACADE_PRODUCTION, radioFacadeIsProduction.SelectedValue);
                if (String.IsNullOrEmpty(textboxFacadeSitesFileName.Text))
                {
                    newSettings[dropdownFacadeName.Text].Add(MdwsConfigConstants.FACADE_SITES_FILE, MdwsConstants.DEFAULT_SITES_FILE_NAME);
                }
                else
                {
                    newSettings[dropdownFacadeName.Text].Add(MdwsConfigConstants.FACADE_SITES_FILE, textboxFacadeSitesFileName.Text);
                }

                foreach (string key in newSettings.Keys)
                {
                    // if old settings doesn't have facade config, add it
                    if (!oldSettings.ContainsKey(key))
                    {
                        oldSettings.Add(key, new Dictionary <string, string>());
                    }
                    foreach (string settingKey in newSettings[key].Keys)
                    {
                        if (oldSettings[key].ContainsKey(settingKey))
                        {
                            oldSettings[key][settingKey] = newSettings[key][settingKey];
                        }
                        else
                        {
                            oldSettings[key].Add(settingKey, newSettings[key][settingKey]);
                        }
                    }
                }

                gov.va.medora.mdo.dao.file.ConfigFileDao fileDao = new mdo.dao.file.ConfigFileDao(mdwsConfig.ConfigFilePath);
                fileDao.writeToFile(oldSettings); // not really old settings any more
            }
            catch (Exception exc)
            {
                labelMessage.Text = exc.ToString();
            }
            finally
            {
                impersonater.Undo();
            }
            setForm();
        }