Exemplo n.º 1
0
        public static string GetReadTableFunction()
        {
            XmlKeyValueSection globalSettingSection = (XmlKeyValueSection)config.GetSection("GlobalSetting");

            //XmlKeyValueSection globalSettingSection = (XmlKeyValueSection)System.Configuration.ConfigurationManager.GetSection("GlobalSetting");
            return(globalSettingSection.KeyValues["DefaultReadTableFunction"].Value);
        }
Exemplo n.º 2
0
        private void txtRead_Click(object sender, EventArgs e)
        {
            // System.Configuration
            MySection1 mySectioin1 = (MySection1)SAPGlobalSettings.config.GetSection("MySection111");

            //MySection1 mySectioin1 = (MySection1)System.Configuration.ConfigurationManager.GetSection("MySection111");
            txtUsername1.Text = mySectioin1.UserName;
            txtUrl1.Text      = mySectioin1.Url;


            // MySection2 mySectioin2 = (MySection2)System.Configuration.ConfigurationManager.GetSection("MySection222");
            MySection2 mySectioin2 = (MySection2)SAPGlobalSettings.config.GetSection("MySection222");

            txtUsername2.Text = mySectioin2.Users.UserName;
            txtUrl2.Text      = mySectioin2.Users.Password;


            // MySection3 mySection3 = (MySection3)System.Configuration.ConfigurationManager.GetSection("MySection333");
            MySection3 mySection3 = (MySection3)SAPGlobalSettings.config.GetSection("MySection333");

            txtCommand1.Text = mySection3.Command1.CommandText.Trim();
            txtCommand2.Text = mySection3.Command2.CommandText.Trim();


            XmlKeyValueSection mySection4 = (XmlKeyValueSection)System.Configuration.ConfigurationManager.GetSection("MySection444");

            txtKeyValues.Text = string.Join("\r\n",
                                            (from kv in mySection4.KeyValues.Cast <XmlKeyValueSetting>()
                                             let s = string.Format("{0}={1}", kv.Key, kv.Value)
                                                     select s).ToArray());

            SmtpSection section = System.Configuration.ConfigurationManager.GetSection("system.net/mailSettings/smtp") as SmtpSection;

            labMailFrom.Text = "Mail From: " + section.From;
        }
Exemplo n.º 3
0
        public static string GetDefaultCodeManagerDb()
        {
            XmlKeyValueSection globalSettingSection = (XmlKeyValueSection)config.GetSection("GlobalSetting");

            //XmlKeyValueSection globalSettingSection = (XmlKeyValueSection)System.Configuration.ConfigurationManager.GetSection("GlobalSetting");
            return(globalSettingSection.KeyValues["CodeManagerDb"].Value);
        }
Exemplo n.º 4
0
        private void SaveConfig()
        {
            //Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            Configuration config = SAPGlobalSettings.config;

            SapDefaultSettingSection defaultSettingSection = config.GetSection("SAPDefaultSetting") as SapDefaultSettingSection;

            defaultSettingSection.DefaultSapClient = this.cbxSAPClient.Text.Trim();
            defaultSettingSection.DefaultSapServer = this.cbxSAPServer.Text.Trim();
            defaultSettingSection.DefaultDb        = this.cbxDb.Text.Trim();

            XmlKeyValueSection globalSettingSection = config.GetSection("GlobalSetting") as XmlKeyValueSection;

            globalSettingSection.KeyValues.Clear();

            (from s in txtKeyValues.Lines
             let p = s.IndexOf('=')
                     where p > 0
                     select new XmlKeyValueSetting {
                Key = s.Substring(0, p), Value = s.Substring(p + 1)
            }
            ).ToList()
            .ForEach(kv => globalSettingSection.KeyValues.Add(kv));

            config.Save(ConfigurationSaveMode.Modified);
            //这里需要刷新缓存
            ConfigurationManager.RefreshSection("SAPDefaultSetting");
            ConfigurationManager.RefreshSection("GlobalSetting");
            MessageBox.Show("OK", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 5
0
        private void txtSave_Click(object sender, EventArgs e)
        {
            Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            SmtpSection section = config.GetSection("system.net/mailSettings/smtp") as SmtpSection;

            section.From = "[email protected]";

            MySection1 mySectioin1 = config.GetSection("MySection111") as MySection1;

            mySectioin1.UserName = txtUsername1.Text.Trim();
            mySectioin1.Url      = txtUrl1.Text.Trim();

            MySection2 mySection2 = config.GetSection("MySection222") as MySection2;

            mySection2.Users.UserName = txtUsername2.Text.Trim();
            mySection2.Users.Password = txtUrl2.Text.Trim();

            MySection3 mySection3 = config.GetSection("MySection333") as MySection3;

            mySection3.Command1.CommandText = txtCommand1.Text.Trim();
            mySection3.Command2.CommandText = txtCommand2.Text.Trim();

            XmlKeyValueSection mySection4 = config.GetSection("MySection444") as XmlKeyValueSection;

            mySection4.KeyValues.Clear();

            (from s in txtKeyValues.Lines
             let p = s.IndexOf('=')
                     where p > 0
                     select new XmlKeyValueSetting {
                Key = s.Substring(0, p), Value = s.Substring(p + 1)
            }
            ).ToList()
            .ForEach(kv => mySection4.KeyValues.Add(kv));

            config.Save();

            MessageBox.Show("OK", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 6
0
        private void readConfig()
        {
            // SapDefaultSettingSection defaultSettingSection = (SapDefaultSettingSection)ConfigurationManager.GetSection("SAPDefaultSetting");
            SAPGlobalSettings.reload();
            this.cbxDb.DataSource   = SAPGlobalSettings.GetDbConnectionList();
            cbxSAPClient.DataSource = SAPGlobalSettings.GetSAPClientList();
            cbxSAPServer.DataSource = SAPGlobalSettings.GetSAPServerList();

            SapDefaultSettingSection defaultSettingSection = (SapDefaultSettingSection)SAPGlobalSettings.config.GetSection("SAPDefaultSetting");

            this.cbxSAPClient.Text = defaultSettingSection.DefaultSapClient;
            this.cbxDb.Text        = defaultSettingSection.DefaultDb;
            this.cbxSAPServer.Text = defaultSettingSection.DefaultSapServer;


            XmlKeyValueSection globalSettingSection = (XmlKeyValueSection)SAPGlobalSettings.config.GetSection("GlobalSetting");

            // XmlKeyValueSection globalSettingSection = (XmlKeyValueSection)System.Configuration.ConfigurationManager.GetSection("GlobalSetting");
            txtKeyValues.Text = string.Join("\r\n",
                                            (from kv in globalSettingSection.KeyValues.Cast <XmlKeyValueSetting>()
                                             let s = string.Format("{0}={1}", kv.Key, kv.Value)
                                                     select s).ToArray());
        }
Exemplo n.º 7
0
        public static string GetSettingsFromDb()
        {
            XmlKeyValueSection globalSettingSection = (XmlKeyValueSection)config.GetSection("GlobalSetting");

            return(globalSettingSection.KeyValues["SettingDb"].Value);
        }
Exemplo n.º 8
0
        public static string GetCodeTemplateDb()
        {
            XmlKeyValueSection globalSettingSection = (XmlKeyValueSection)config.GetSection("GlobalSetting");

            return(globalSettingSection.KeyValues["CodeTemplate"].Value);
        }