Esempio n. 1
0
 public DataConfigModel GetConfig()
 {
     //string connStr = string.Format("Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3}");
     Configuration configuration = ConfigurationManager.OpenExeConfiguration(servicesHost);
     string connStr = configuration.ConnectionStrings.ConnectionStrings["ZSXTDataConfig"].ConnectionString;
     DataConfigModel config = new DataConfigModel();
     Match m = Regex.Match(connStr, @"Data Source=(\S*);", RegexOptions.IgnoreCase);
     if (m.Success)
     {
         config.DataServiceName= m.Groups[1].Value;
     }
     m = Regex.Match(connStr, @"Initial Catalog=(\S*);", RegexOptions.IgnoreCase);
     if (m.Success)
     {
         config.DataServiceDatabase = m.Groups[1].Value;
     }
     m = Regex.Match(connStr, @"User ID=(\S*);", RegexOptions.IgnoreCase);
     if (m.Success)
     {
         config.DataServiceUser = m.Groups[1].Value;
     }
     m = Regex.Match(connStr, @"Password=(\S*)", RegexOptions.IgnoreCase);
     if (m.Success)
     {
         config.DataServicePwd = m.Groups[1].Value;
     }
     return config;
 }
Esempio n. 2
0
 public void SaveConfig(DataConfigModel config)
 {
     string connStr = string.Format("Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3}", config.DataServiceName, config.DataServiceDatabase, config.DataServiceUser, config.DataServicePwd);
     Configuration configuration = ConfigurationManager.OpenExeConfiguration(servicesHost);
     configuration.ConnectionStrings.ConnectionStrings["ZSXTDataConfig"].ConnectionString = connStr;
     configuration.Save();
     ConfigurationManager.RefreshSection("connectionStrings");
 }
Esempio n. 3
0
 public MainWindow()
 {
     InitializeComponent();
     config = new ConfigData().GetConfig();
     string ip, point;
     GetServiceInfo(out ip, out point);
     config.ServiceIp = ip;
     config.ServicePoint = point;
     this.DataContext = config;
 }
Esempio n. 4
0
 /// <summary>
 /// 设置配置文件
 /// </summary>
 /// <param name="config"></param>
 public void SetDataConfig(DataConfigModel config)
 {
     ConfigData configData = new ConfigData();
     configData.SaveConfig(config);
 }