Esempio n. 1
0
 public bool LoadSetting(string settingPath)
 {
     var result = false;
     var obj = new DatabaseSetting();
     if (File.Exists(settingPath)) {
         FileStream fileStream = new FileStream(settingPath, FileMode.Open);
         try {
             XmlSerializer serializer = new XmlSerializer(typeof(DatabaseSetting));
             obj = (DatabaseSetting)serializer.Deserialize(fileStream);
             if (obj != null) {
                 Username = obj.Username;
                 Password = obj.Password;
                 Datasource = obj.Datasource;
                 DatabaseName = obj.DatabaseName;
                 Provider = obj.Provider;
             } else {
                 result = false;
             }
             result = true;
         } catch (Exception ex) {
             AppException.LogException(ex);
             result = false;
         } finally {
             fileStream.Close();
         }
     }
     return result;
 }
Esempio n. 2
0
 private void InitializeDatabaseSetting()
 {
     _databaseSetting = new DatabaseSetting {
         Username = txtUsername.Text,
         Password = txtPassword.Text,
         Provider = cmbProvider.Text,
         Datasource = txtDatasource.Text,
         DatabaseName = txtDatabase.Text,
         InstanceName = txtInstanceName.Text
     };
 }
Esempio n. 3
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     _databaseSetting = new DatabaseSetting();
     _databaseSetting.LoadSetting("d:\\ss.xml");
 }