예제 #1
0
        private void InitLogin()
        {
            Excel2007Addin.Settings settings = Excel2007Addin.Settings.Default;

            this._login            = new Login(_user);
            _login.authSuccessful += new Login.AuthSuccessful(User_Successful_Login);
            _login.logOut         += new Login.Logout(User_Logout);


            _login.Username         = settings.Username;
            _login.Password         = DataProtectionHelper.UnProtect(settings.Password);
            _login.RememberPassword = settings.RememberPassword;
            if (_login.ShowDialog().GetValueOrDefault(false))
            {
                settings.RememberPassword = _login.RememberPassword;
                settings.Username         = _login.Username;
                if (_login.RememberPassword)
                {
                    settings.Password = DataProtectionHelper.Protect(_login.Password);
                }
                else
                {
                    settings.Password = DataProtectionHelper.Protect("");
                }
                settings.Save();
            }
        }
예제 #2
0
        private void SettingsButton_Click(object sender, RibbonControlEventArgs e)
        {
            Excel2007Addin.Settings settings    = Excel2007Addin.Settings.Default;
            SettingsDialog          settingsdlg = new SettingsDialog();

            settingsdlg.AutoEscapeFilter = settings.AutoEscapeFilter;
            settingsdlg.UseProxy         = settings.UseProxy;
            settingsdlg.ProxyAddress     = settings.ProxyAddress;
            settingsdlg.ProxyPort        = settings.ProxyPort;
            settingsdlg.ProxyUsername    = settings.ProxyUsername;
            settingsdlg.ProxyPassword    = DataProtectionHelper.UnProtect(settings.ProxyPassword);
            settingsdlg.RequestTimeout   = settings.RequestTimeout;
            settingsdlg.CellFormatting   = (CellFormattingEnum)settings.CellFormatting;

            if (settingsdlg.ShowDialog().GetValueOrDefault(false))
            {
                // Update metrics xml?
                if (!string.IsNullOrEmpty(settingsdlg.MetricsFileName))
                {
                    System.Xml.XmlDocument doc = new System.Xml.XmlDataDocument();
                    try
                    {
                        doc.Load(XmlReader.Create(settingsdlg.MetricsFileName,
                                                  new XmlReaderSettings()
                        {
                            Schemas        = Analytics.Data.Validation.XmlValidator.LoadSchema("metrics.xsd"),
                            ValidationType = ValidationType.Schema
                        }));
                        settings.Metrics = doc;
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error parsing metrics xml. No metrics updated.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                // Update dimensions xml?
                if (!string.IsNullOrEmpty(settingsdlg.DimensionsFileName))
                {
                    System.Xml.XmlDocument doc = new System.Xml.XmlDataDocument();
                    try
                    {
                        doc.Load(XmlReader.Create(settingsdlg.DimensionsFileName,
                                                  new XmlReaderSettings()
                        {
                            Schemas        = Analytics.Data.Validation.XmlValidator.LoadSchema("dimensions.xsd"),
                            ValidationType = ValidationType.Schema
                        }));
                        settings.Dimensions = doc;
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Error parsing dimension xml. No dimensions updated.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                settings.AutoEscapeFilter = settingsdlg.AutoEscapeFilter;
                settings.UseProxy         = settingsdlg.UseProxy;
                settings.ProxyAddress     = settingsdlg.ProxyAddress;
                settings.ProxyUsername    = settingsdlg.ProxyUsername;
                settings.ProxyPassword    = DataProtectionHelper.Protect(settingsdlg.ProxyPassword);
                settings.ProxyPort        = settingsdlg.ProxyPort;
                settings.RequestTimeout   = settingsdlg.RequestTimeout;
                settings.CellFormatting   = (int)settingsdlg.CellFormatting;
                settings.Save();

                Analytics.Settings.Instance.AutoEscapeFilter = settingsdlg.AutoEscapeFilter;
                Analytics.Settings.Instance.UseProxy         = settings.UseProxy;
                Analytics.Settings.Instance.ProxyAddress     = settings.ProxyAddress;
                Analytics.Settings.Instance.ProxyPassword    = settings.ProxyPassword;
                Analytics.Settings.Instance.ProxyPort        = settings.ProxyPort;
                Analytics.Settings.Instance.ProxyUsername    = settings.ProxyUsername;

                Analytics.Settings.Instance.RequestTimeout = settings.RequestTimeout;
                Analytics.Settings.Instance.MetricsXml     = settings.Metrics;
                Analytics.Settings.Instance.DimensionsXml  = settings.Dimensions;
            }
        }