public static void Save(DBConnectionDetails DBConnection, LogHandler Logger) { if (Logger.DebugMode) { Logger.LogTrace("Enter Save DBConnection Method"); } try { DBConnection.DBPassword = Encrypt(DBConnection.DBPassword, DBConnection.DBServer, DBConnection.DBUsername); String _Serialized = Newtonsoft.Json.JsonConvert.SerializeObject(DBConnection, Newtonsoft.Json.Formatting.Indented); File.WriteAllText("./DBConnectionConfig.json", _Serialized); } catch (Exception ex) { Logger.LogError("Could not save Database Connection Settings file. " + ex.Message); } }
public IngestBase(LogHandler LogObject, ODL.Common.DBConnectionDetails DbConnectionInfo, String FileName) { this.Logger = LogObject; this.DataFile = new FileInfo(FileName); try { //Figure out which type of database we have and test the connection. if (DbConnectionInfo.DBType == ODL.Common.SupportedDatabases.PostgreSQL) { this.PostgresConnection = DatabaseUtils.Postgres.ConnectToPostGRES(DbConnectionInfo); } } catch (Exception ex) { LogObject.LogError("Can't connect to the database with specified parameters: " + ex.Message); } }