Пример #1
0
 private void OnSaveConnection(object sender, EventArgs e)
 {
     if (DbConnection != null)
     {
         SerializerPresenter.SerializeToFile(FlatFile.GetDBConfigsFile(), DbConnection);
         DbConnectionView.WriteSuccessful("Saved");
     }
     else
     {
         DbConnectionView.WriteError("Firstly test your connection. Only successful connection can be saved");
     }
 }
Пример #2
0
 private void GetConnectionInfoFromFile(string connectionName)
 {
     try {
         DbConnection connection = SerializerPresenter.DeserializeFromFile(FlatFile.GetDBConfigsFile(), connectionName);
         DbConnectionView.Host        = connection.Host;
         DbConnectionView.Port        = connection.Port;
         DbConnectionView.Schema      = connection.Schema;
         DbConnectionView.Password    = connection.Password;
         DbConnectionView.Sid         = connection.Sid;
         DbConnectionView.ServiceName = connection.ServiceName;
     } catch (InvalidOperationException) {
         DbConnectionView.WriteError("Connection to database does not set, please configure it");
         return;
     } catch (InvalidDataException) {
         DbConnectionView.WriteError(connectionName + " connection has errors and need to be reconfigured");
         DbConnectionView.ClearAllTextBoxes();
         return;
     } catch (NullReferenceException) {
         DbConnectionView.WriteError(connectionName + " connection not found. Please configure it");
         DbConnectionView.ClearAllTextBoxes();
         return;
     }
 }