Пример #1
0
 private void BindConfig()
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         this.conf      = MainConfiguration.GetConfig();
         if (this.conf == null)
         {
             return;
         }
         this.BindLsbEndPoints(this.conf.ConfigValues);
         ConfigValue configValue = Enumerable.FirstOrDefault <ConfigValue>((IEnumerable <ConfigValue>) this.conf.ConfigValues);
         if (configValue != null)
         {
             this.BindConfig(configValue.ConfigName);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Пример #2
0
 private void btDeleteConfigValue_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         if (this.lsbEndpoints.Items.Count <= 0)
         {
             return;
         }
         MainConfiguration config = MainConfiguration.GetConfig();
         config.DeleteConfigValue(this.tbConfigname.Text);
         int selectedIndex = this.lsbEndpoints.SelectedIndex;
         this.BindConfig();
         if (this.lsbEndpoints.Items.Count >= selectedIndex && this.lsbEndpoints.Items.Count > 0)
         {
             this.lsbEndpoints.SelectedIndex = selectedIndex - 1;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Пример #3
0
 private void btSaveConfig_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         if (string.IsNullOrEmpty(this.txtEndpoint.Text))
         {
             return;
         }
         if (Uri.IsWellFormedUriString(this.txtEndpoint.Text, UriKind.Absolute))
         {
             Cursor.Current = Cursors.WaitCursor;
             var bindingType = this.rbBasicHttpBinding.Checked ? BindingType.BasicHttpBinding : BindingType.WSHttpBinding;
             var config      = MainConfiguration.GetConfig();
             config.SetConfig(this.tbConfigname.Text, this.txtDomain.Text, this.txtUsername.Text, this.txtPassword.Text, new Uri(this.txtEndpoint.Text), bindingType);
             int selectedIndex = this.lsbEndpoints.SelectedIndex;
             BindConfig();
             lsbEndpoints.SelectedIndex = selectedIndex;
         }
         else
         {
             MessageBox.Show("The endpoint uri is not valid!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Пример #4
0
        public static MainConfiguration GetConfig(string file)
        {
            if (!File.Exists(file))
            {
                return(new MainConfiguration(file).SaveConfig());
            }
            XmlSerializer     xmlSerializer     = new XmlSerializer(typeof(MainConfiguration));
            StreamReader      streamReader      = File.OpenText(file);
            MainConfiguration mainConfiguration = xmlSerializer.Deserialize((TextReader)streamReader) as MainConfiguration;

            streamReader.Close();
            return(mainConfiguration);
        }
Пример #5
0
        private void PermissionsManager_Load(object sender, EventArgs e)
        {
            try
            {
                cbConnection.ComboBox.SelectionChangeCommitted  += cbConnection_SelectedIndexChanged;
                cbConnection2.ComboBox.SelectionChangeCommitted += cbConnection_SelectedIndexChanged;
                var configValues = MainConfiguration.GetConfigValues();
                configValues.Add(new ConfigValue("XML_File", ""));


                configValues.ForEach(cf => cbConnection.ComboBox.Items.Add(cf));
                configValues.ForEach(cf => cbConnection2.ComboBox.Items.Add(cf));

                // cbConnection.ComboBox.DataSource = dataSource;
                cbConnection.ComboBox.DisplayMember = "ConfigName";
                //cbConnection2.ComboBox.DataSource = dataSource;
                cbConnection2.ComboBox.DisplayMember = "ConfigName";
            }
            catch (Exception exc)
            {
                UIHelper.TreatException(exc);
            }
        }
Пример #6
0
        //private static MainConfiguration GetConfig(StringBuilder XmlConfigurationString)
        //{
        //    try
        //    {
        //        XmlSerializer xmlSerializer = new XmlSerializer(typeof(MainConfiguration));
        //        StringReader stringReader = new StringReader(((object)XmlConfigurationString).ToString());
        //        XmlTextReader xmlTextReader = new XmlTextReader((TextReader)stringReader);
        //        MainConfiguration mainConfiguration = xmlSerializer.Deserialize((XmlReader)xmlTextReader) as MainConfiguration;
        //        xmlTextReader.Close();
        //        stringReader.Close();
        //        return mainConfiguration;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}



        public static List <ConfigValue> GetConfigValues()
        {
            return(MainConfiguration.GetConfig().ConfigValues);
        }
Пример #7
0
 private void LoadConfigurations()
 {
     cbEndPointAddress.DataSource    = MainConfiguration.GetConfigValues();
     cbEndPointAddress.DisplayMember = "ConfigName";
 }