/// <summary> /// Initialises the internal variables that hold the Server Settings, using the current config file. /// /// </summary> /// <returns>void</returns> public TSrvSetting() { FConfigurationFile = TAppSettingsManager.ConfigFileName; FExecutingOS = Utilities.DetermineExecutingOS(); // Server.RDBMSType FRDBMSType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType", "postgresql")); FApplicationBinFolder = TAppSettingsManager.GetValue("Server.ApplicationBinDirectory", string.Empty, false); if (TAppSettingsManager.HasValue("Server.LogFile")) { FServerLogFile = TAppSettingsManager.GetValue("Server.LogFile", false); } else { // maybe the log file has already been set, eg. by the NUnit Server Test FServerLogFile = TLogging.GetLogFileName(); if (FServerLogFile.Length == 0) { // this is effectively the bin directory (current directory) FServerLogFile = "Server.log"; } } // Server.Port FIPBasePort = TAppSettingsManager.GetInt16("Server.Port", 80); // Determine network configuration of the Server Networking.DetermineNetworkConfig(out FHostName, out FHostIPAddresses); FApplicationVersion = TFileVersionInfo.GetApplicationVersion(); }
public void Init() { new TLogging("../../log/test.log"); new TAppSettingsManager("../../etc/TestServer.config"); FDBType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType")); FDataBase = DBAccess.Connect(DefaultDBConnName); // Reset some Fields for every Test FTestDBInstance1 = null; FTestDBInstance2 = null; FTestCallDBCommand1 = null; FTestCallDBCommand2 = null; FTestingThread1 = null; FTestingThread2 = null; FTestingThread1NewTransaction = false; FTestingThread2NewTransaction = false; FTestingThread1Exception = null; FTestingThread2Exception = null; FEstablishedDBConnectionSignalDBConn1 = null; FEstablishedDBConnectionSignalDBConn2 = null; FCloseDBConnectionSignalDBConn1 = null; FCloseDBConnectionSignalDBConn2 = null; FDBConnectionClosedSignalDBConn1 = null; FDBConnectionClosedSignalDBConn2 = null; FGotNewOrExistingDBTransactionSignal1 = null; FGotNewOrExistingDBTransactionSignal2 = null; FRollbackDBTransactionSignal1 = null; FRollbackDBTransactionSignal2 = null; FDBTransactionRolledbackSignal1 = null; FDBTransactionRolledbackSignal2 = null; FProgressUpdateCounter = 0; FProgressUpdateNumber = 0; }
/// establish a database connection to the alternative sqlite database for the sessions private static TDataBase EstablishDBConnectionSqliteSessionDB(String AConnectionName = "") { TDBType DBType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType", "postgresql")); if (DBType != TDBType.SQLite) { throw new Exception("EstablishDBConnectionSqliteSessionDB: we should not get here."); } string DatabaseHostOrFile = TAppSettingsManager.GetValue("Server.DBSqliteSession", "localhost"); string DatabasePort = String.Empty; string DatabaseName = TAppSettingsManager.GetValue("Server.DBName", "openpetra"); string DBUsername = TAppSettingsManager.GetValue("Server.DBUserName", "petraserver"); string DBPassword = TAppSettingsManager.GetValue("Server.DBPassword", string.Empty, false); if (!File.Exists(DatabaseHostOrFile)) { // create the sessions database file TLogging.Log("create the sessions database file: " + DatabaseHostOrFile); // sqlite on Windows does not support encryption with a password // System.EntryPointNotFoundException: sqlite3_key DBPassword = string.Empty; SqliteConnection conn = new SqliteConnection("Data Source=" + DatabaseHostOrFile + (DBPassword.Length > 0 ? ";Password="******"")); conn.Open(); string createStmt = @"CREATE TABLE s_session ( s_session_id_c varchar(128) NOT NULL, s_valid_until_d datetime NOT NULL, s_session_values_c text, s_date_created_d date, s_created_by_c varchar(20), s_date_modified_d date, s_modified_by_c varchar(20), s_modification_id_t timestamp, CONSTRAINT s_session_pk PRIMARY KEY (s_session_id_c) )"; SqliteCommand cmd = new SqliteCommand(createStmt, conn); cmd.ExecuteNonQuery(); conn.Close(); } TDataBase DBAccessObj = new TDataBase(); DBAccessObj.EstablishDBConnection(DBType, DatabaseHostOrFile, DatabasePort, DatabaseName, DBUsername, DBPassword, "", true, AConnectionName); return(DBAccessObj); }
/// <summary> /// open a connection to an RDBMS /// </summary> /// <param name="ADataBaseType"></param> /// <param name="ADsn"></param> /// <param name="ADBPort"></param> /// <param name="ADatabaseName"></param> /// <param name="AUsername"></param> /// <param name="APassword"></param> /// <param name="AConnectionString"></param> /// <param name="APetraUserName"></param> public new void EstablishDBConnection(TDBType ADataBaseType, String ADsn, String ADBPort, String ADatabaseName, String AUsername, String APassword, String AConnectionString, String APetraUserName) { // A Method of the same name and Method signature in the Base Class has got an optional string Argument // 'AConnectionName' in exactly the same Argument position than APetraUserName has got here. The Base Class // supplies 'null' as a Default for this Argument. For these reasons the Method *here* *could* get legally called // with 'APetraUserName' *omitted* and 'null' would be supplied in lieu in that case. As this would not make // sense here we throw an ArgumentNullException in that case. if (APetraUserName == null) { throw new ArgumentNullException("APetraUserName"); } UserID = APetraUserName; FCache.Invalidate(); // Call base Method with same name and same Method signature but different functionality! base.EstablishDBConnection(ADataBaseType, ADsn, ADBPort, ADatabaseName, AUsername, APassword, AConnectionString, "Client's Default DB Connection"); }
/// Copy constructor public TSrvSetting(TSrvSetting ACopyFrom) { if (USingletonSrvSetting == null) { USingletonSrvSetting = this; } FConfigurationFile = ACopyFrom.FConfigurationFile; FExecutingOS = ACopyFrom.FExecutingOS; FRDBMSType = ACopyFrom.FRDBMSType; FDatabaseHostOrFile = ACopyFrom.FDatabaseHostOrFile; FDatabasePort = ACopyFrom.FDatabasePort; FDatabaseName = ACopyFrom.FDatabaseName; FDBUsername = ACopyFrom.FDBUsername; FDBPassword = ACopyFrom.FDBPassword; FIPBasePort = ACopyFrom.FIPBasePort; FServerLogFile = ACopyFrom.FServerLogFile; FHostName = ACopyFrom.FHostName; FHostIPAddresses = ACopyFrom.FHostIPAddresses; FClientIdleStatusAfterXMinutes = ACopyFrom.FClientIdleStatusAfterXMinutes; FClientKeepAliveCheckIntervalInSeconds = ACopyFrom.FClientKeepAliveCheckIntervalInSeconds; FClientKeepAliveTimeoutAfterXSecondsLAN = ACopyFrom.FClientKeepAliveTimeoutAfterXSecondsLAN; FClientKeepAliveTimeoutAfterXSecondsRemote = ACopyFrom.FClientKeepAliveTimeoutAfterXSecondsRemote; FClientConnectionTimeoutAfterXSeconds = ACopyFrom.FClientConnectionTimeoutAfterXSeconds; FClientAppDomainShutdownAfterKeepAliveTimeout = ACopyFrom.FClientAppDomainShutdownAfterKeepAliveTimeout; FApplicationVersion = ACopyFrom.FApplicationVersion; FSMTPServer = ACopyFrom.FSMTPServer; FAutomaticIntranetExportEnabled = ACopyFrom.FAutomaticIntranetExportEnabled; FRunAsStandalone = ACopyFrom.FRunAsStandalone; FIntranetDataDestinationEmail = ACopyFrom.FIntranetDataDestinationEmail; FIntranetDataSenderEmail = ACopyFrom.FIntranetDataSenderEmail; FApplicationBinFolder = ACopyFrom.FApplicationBinFolder; }
/// <summary> /// open a connection to an RDBMS /// </summary> /// <param name="ADataBaseType"></param> /// <param name="ADsn"></param> /// <param name="ADBPort"></param> /// <param name="ADatabaseName"></param> /// <param name="AUsername"></param> /// <param name="APassword"></param> /// <param name="AConnectionString"></param> /// <param name="APetraUserName"></param> public void EstablishDBConnection(TDBType ADataBaseType, String ADsn, String ADBPort, String ADatabaseName, String AUsername, String APassword, String AConnectionString, String APetraUserName) { UserID = APetraUserName; FCache.Invalidate(); // inherited EstablishDBConnection(ADataBaseType, ADsn, ADBPort, ADatabaseName, AUsername, APassword, AConnectionString); }
/// Copy constructor public TSrvSetting(TSrvSetting ACopyFrom) { if (USingletonSrvSetting == null) { USingletonSrvSetting = this; } FConfigurationFile = ACopyFrom.FConfigurationFile; FExecutingOS = ACopyFrom.FExecutingOS; FRDBMSType = ACopyFrom.FRDBMSType; FDatabaseHostOrFile = ACopyFrom.FDatabaseHostOrFile; FDatabasePort = ACopyFrom.FDatabasePort; FDatabaseName = ACopyFrom.FDatabaseName; FDBUsername = ACopyFrom.FDBUsername; FDBPassword = ACopyFrom.FDBPassword; FDBConnectionCheckInterval = ACopyFrom.FDBConnectionCheckInterval; FIPBasePort = ACopyFrom.FIPBasePort; FServerLogFile = ACopyFrom.FServerLogFile; FHostName = ACopyFrom.FHostName; FHostIPAddresses = ACopyFrom.FHostIPAddresses; FClientIdleStatusAfterXMinutes = ACopyFrom.FClientIdleStatusAfterXMinutes; FClientKeepAliveCheckIntervalInSeconds = ACopyFrom.FClientKeepAliveCheckIntervalInSeconds; FClientKeepAliveTimeoutAfterXSecondsLAN = ACopyFrom.FClientKeepAliveTimeoutAfterXSecondsLAN; FClientKeepAliveTimeoutAfterXSecondsRemote = ACopyFrom.FClientKeepAliveTimeoutAfterXSecondsRemote; FClientConnectionTimeoutAfterXSeconds = ACopyFrom.FClientConnectionTimeoutAfterXSeconds; FClientAppDomainShutdownAfterKeepAliveTimeout = ACopyFrom.FClientAppDomainShutdownAfterKeepAliveTimeout; FApplicationVersion = ACopyFrom.FApplicationVersion; FSmtpHost = ACopyFrom.FSmtpHost; FSmtpPort = ACopyFrom.FSmtpPort; FSmtpUser = ACopyFrom.FSmtpUser; FSmtpPassword = ACopyFrom.FSmtpPassword; FSmtpEnableSsl = ACopyFrom.FSmtpEnableSsl; FSmtpAuthenticationType = ACopyFrom.FSmtpAuthenticationType; FSmtpIgnoreServerCertificateValidation = ACopyFrom.FSmtpIgnoreServerCertificateValidation; FRunAsStandalone = ACopyFrom.FRunAsStandalone; FApplicationBinFolder = ACopyFrom.FApplicationBinFolder; }
/// <summary> /// Initialises the internal variables that hold the Server Settings, using the current config file. /// /// </summary> /// <returns>void</returns> public TSrvSetting() { if (USingletonSrvSetting == null) { USingletonSrvSetting = this; } FConfigurationFile = TAppSettingsManager.ConfigFileName; FExecutingOS = Utilities.DetermineExecutingOS(); // Server.RDBMSType FRDBMSType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType", "postgresql")); FDatabaseHostOrFile = TAppSettingsManager.GetValue("Server.DBHostOrFile", "localhost"); FDatabasePort = TAppSettingsManager.GetValue("Server.DBPort", "5432"); FDatabaseName = TAppSettingsManager.GetValue("Server.DBName", "openpetra"); FDBUsername = TAppSettingsManager.GetValue("Server.DBUserName", "petraserver"); FDBPassword = TAppSettingsManager.GetValue("Server.DBPassword", string.Empty, false); if (FDBPassword == "PG_OPENPETRA_DBPWD") { // get the password from the file ~/.pgpass. This currently only works for PostgreSQL on Linux using (StreamReader sr = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar + ".pgpass")) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.StartsWith(FDatabaseHostOrFile + ":" + FDatabasePort + ":" + FDatabaseName + ":" + FDBUsername + ":") || line.StartsWith("*:" + FDatabasePort + ":" + FDatabaseName + ":" + FDBUsername + ":")) { FDBPassword = line.Substring(line.LastIndexOf(':') + 1); break; } } } } if (TAppSettingsManager.HasValue("Server.LogFile")) { FServerLogFile = TAppSettingsManager.GetValue("Server.LogFile", false); } else { // maybe the log file has already been set, eg. by the NUnit Server Test FServerLogFile = TLogging.GetLogFileName(); if (FServerLogFile.Length == 0) { // this is effectively the bin directory (current directory) FServerLogFile = "Server.log"; } } // Server.Port FIPBasePort = TAppSettingsManager.GetInt16("Server.Port", 9000); FRunAsStandalone = TAppSettingsManager.GetBoolean("Server.RunAsStandalone", false); // Server.ClientIdleStatusAfterXMinutes FClientIdleStatusAfterXMinutes = TAppSettingsManager.GetInt32("Server.ClientIdleStatusAfterXMinutes", 5); // Server.ClientKeepAliveCheckIntervalInSeconds FClientKeepAliveCheckIntervalInSeconds = TAppSettingsManager.GetInt32("Server.ClientKeepAliveCheckIntervalInSeconds", 60); // Server.ClientKeepAliveTimeoutAfterXSeconds_LAN FClientKeepAliveTimeoutAfterXSecondsLAN = TAppSettingsManager.GetInt32("Server.ClientKeepAliveTimeoutAfterXSeconds_LAN", 60); // Server.ClientKeepAliveTimeoutAfterXSeconds_Remote FClientKeepAliveTimeoutAfterXSecondsRemote = TAppSettingsManager.GetInt32("Server.ClientKeepAliveTimeoutAfterXSeconds_Remote", (ClientKeepAliveTimeoutAfterXSecondsLAN * 2)); // Server.ClientConnectionTimeoutAfterXSeconds FClientConnectionTimeoutAfterXSeconds = TAppSettingsManager.GetInt32("Server.ClientConnectionTimeoutAfterXSeconds", 20); // Server.ClientAppDomainShutdownAfterKeepAliveTimeout FClientAppDomainShutdownAfterKeepAliveTimeout = TAppSettingsManager.GetBoolean("Server.ClientAppDomainShutdownAfterKeepAliveTimeout", true); FSMTPServer = TAppSettingsManager.GetValue("Server.SMTPServer", "localhost"); // This is disabled in processing at the moment, so we reflect that here. When it works change to true FAutomaticIntranetExportEnabled = TAppSettingsManager.GetBoolean("Server.AutomaticIntranetExportEnabled", false); // The following setting specifies the email address where the Intranet Data emails are sent to when "Server.AutomaticIntranetExportEnabled" is true. FIntranetDataDestinationEmail = TAppSettingsManager.GetValue("Server.IntranetDataDestinationEmail", "???@???.org"); // The following setting is temporary - until we have created a GUI where users can specify the email address for the // responsible Personnel and Finance persons themselves. Those will be stored in SystemDefaults then. FIntranetDataSenderEmail = TAppSettingsManager.GetValue("Server.IntranetDataSenderEmail", "???@???.org"); // Determine network configuration of the Server Networking.DetermineNetworkConfig(out FHostName, out FHostIPAddresses); FApplicationVersion = TFileVersionInfo.GetApplicationVersion(); }
/// Copy constructor public TSrvSetting(TSrvSetting ACopyFrom) { if (USingletonSrvSetting == null) { USingletonSrvSetting = this; } FConfigurationFile = ACopyFrom.FConfigurationFile; FExecutingOS = ACopyFrom.FExecutingOS; FRDBMSType = ACopyFrom.FRDBMSType; FDatabaseHostOrFile = ACopyFrom.FDatabaseHostOrFile; FDatabasePort = ACopyFrom.FDatabasePort; FDatabaseName = ACopyFrom.FDatabaseName; FDBUsername = ACopyFrom.FDBUsername; FDBPassword = ACopyFrom.FDBPassword; FIPBasePort = ACopyFrom.FIPBasePort; FServerLogFile = ACopyFrom.FServerLogFile; FHostName = ACopyFrom.FHostName; FHostIPAddresses = ACopyFrom.FHostIPAddresses; FClientIdleStatusAfterXMinutes = ACopyFrom.FClientIdleStatusAfterXMinutes; FClientKeepAliveCheckIntervalInSeconds = ACopyFrom.FClientKeepAliveCheckIntervalInSeconds; FClientKeepAliveTimeoutAfterXSecondsLAN = ACopyFrom.FClientKeepAliveTimeoutAfterXSecondsLAN; FClientKeepAliveTimeoutAfterXSecondsRemote = ACopyFrom.FClientKeepAliveTimeoutAfterXSecondsRemote; FClientConnectionTimeoutAfterXSeconds = ACopyFrom.FClientConnectionTimeoutAfterXSeconds; FClientAppDomainShutdownAfterKeepAliveTimeout = ACopyFrom.FClientAppDomainShutdownAfterKeepAliveTimeout; FApplicationVersion = ACopyFrom.FApplicationVersion; FSMTPServer = ACopyFrom.FSMTPServer; FAutomaticIntranetExportEnabled = ACopyFrom.FAutomaticIntranetExportEnabled; FRunAsStandalone = ACopyFrom.FRunAsStandalone; FIntranetDataDestinationEmail = ACopyFrom.FIntranetDataDestinationEmail; FIntranetDataSenderEmail = ACopyFrom.FIntranetDataSenderEmail; }
public static void Main(string[] args) { try { // establish connection to database TCmdOpts settings = new TCmdOpts(); if (!settings.IsFlagSet("Server.ODBC_DSN")) { Console.WriteLine( "sample call: " + "ExportDataProgress.exe -Server.ODBC_DSN:Petra2_2sa -username:demo_sql -password:demo -sql:\"SELECT * from pub.a_account\" -output:test.xml"); Environment.Exit(-1); } new TLogging("debug.log"); TDataBase db = new TDataBase(); TDBType dbtype = TDBType.ProgressODBC; if (settings.IsFlagSet("Server.RDBMSType")) { dbtype = CommonTypes.ParseDBType(settings.GetOptValue("Server.RDBMSType")); } if (dbtype != TDBType.ProgressODBC) { throw new Exception("at the moment only Progress ODBC db is supported"); } db.EstablishDBConnection(dbtype, settings.GetOptValue("Server.ODBC_DSN"), "", "", settings.GetOptValue("username"), settings.GetOptValue("password"), ""); DBAccess.GDBAccessObj = db; TLogging.DebugLevel = 10; string sqlText = ""; if (!settings.IsFlagSet("sql")) { Console.WriteLine("Please enter sql and finish with semicolon: "); while (!sqlText.Trim().EndsWith(";")) { sqlText += " " + Console.ReadLine(); } sqlText = sqlText.Substring(0, sqlText.Length - 1); } else { sqlText = settings.GetOptValue("sql"); Console.WriteLine(sqlText); } TDBTransaction transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.ReadUncommitted); DataTable table = db.SelectDT(sqlText, "temp", transaction); XmlDocument doc = TDataBase.DataTableToXml(table); if (settings.IsFlagSet("output")) { if (settings.GetOptValue("output").EndsWith("yml")) { TYml2Xml.Xml2Yml(doc, settings.GetOptValue("output")); } else if (settings.GetOptValue("output").EndsWith("csv")) { TCsv2Xml.Xml2Csv(doc, settings.GetOptValue("output")); } else if (settings.GetOptValue("output").EndsWith("xml")) { StreamWriter sw = new StreamWriter(settings.GetOptValue("output")); sw.Write(TXMLParser.XmlToString2(doc)); sw.Close(); } } else { TYml2Xml.Xml2Yml(doc, "temp.yml"); StreamReader sr = new StreamReader("temp.yml"); Console.WriteLine(sr.ReadToEnd()); sr.Close(); } db.RollbackTransaction(); db.CloseDBConnection(); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } }
/// <summary> /// Initialises the internal variables that hold the Server Settings, using the current config file. /// /// </summary> /// <returns>void</returns> public TSrvSetting() { if (USingletonSrvSetting == null) { USingletonSrvSetting = this; } FConfigurationFile = TAppSettingsManager.ConfigFileName; FExecutingOS = Utilities.DetermineExecutingOS(); // Server.RDBMSType FRDBMSType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType", "postgresql")); FDatabaseHostOrFile = TAppSettingsManager.GetValue("Server.DBHostOrFile", "localhost"); FDatabasePort = TAppSettingsManager.GetValue("Server.DBPort", "5432"); FDatabaseName = TAppSettingsManager.GetValue("Server.DBName", "openpetra"); FDBUsername = TAppSettingsManager.GetValue("Server.DBUserName", "petraserver"); FDBPassword = TAppSettingsManager.GetValue("Server.DBPassword", string.Empty, false); FApplicationBinFolder = TAppSettingsManager.GetValue("Server.ApplicationBinDirectory", string.Empty, false); if (FDBPassword == "PG_OPENPETRA_DBPWD") { // get the password from the file ~/.pgpass. This currently only works for PostgreSQL on Linux using (StreamReader sr = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar + ".pgpass")) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.StartsWith(FDatabaseHostOrFile + ":" + FDatabasePort + ":" + FDatabaseName + ":" + FDBUsername + ":") || line.StartsWith("*:" + FDatabasePort + ":" + FDatabaseName + ":" + FDBUsername + ":")) { FDBPassword = line.Substring(line.LastIndexOf(':') + 1); break; } } } } if (TAppSettingsManager.HasValue("Server.LogFile")) { FServerLogFile = TAppSettingsManager.GetValue("Server.LogFile", false); } else { // maybe the log file has already been set, eg. by the NUnit Server Test FServerLogFile = TLogging.GetLogFileName(); if (FServerLogFile.Length == 0) { // this is effectively the bin directory (current directory) FServerLogFile = "Server.log"; } } // Server.Port FIPBasePort = TAppSettingsManager.GetInt16("Server.Port", 9000); FRunAsStandalone = TAppSettingsManager.GetBoolean("Server.RunAsStandalone", false); // Server.ClientIdleStatusAfterXMinutes FClientIdleStatusAfterXMinutes = TAppSettingsManager.GetInt32("Server.ClientIdleStatusAfterXMinutes", 5); // Server.ClientKeepAliveCheckIntervalInSeconds FClientKeepAliveCheckIntervalInSeconds = TAppSettingsManager.GetInt32("Server.ClientKeepAliveCheckIntervalInSeconds", 60); // Server.ClientKeepAliveTimeoutAfterXSeconds_LAN FClientKeepAliveTimeoutAfterXSecondsLAN = TAppSettingsManager.GetInt32("Server.ClientKeepAliveTimeoutAfterXSeconds_LAN", 60); // Server.ClientKeepAliveTimeoutAfterXSeconds_Remote FClientKeepAliveTimeoutAfterXSecondsRemote = TAppSettingsManager.GetInt32("Server.ClientKeepAliveTimeoutAfterXSeconds_Remote", (ClientKeepAliveTimeoutAfterXSecondsLAN * 2)); // Server.ClientConnectionTimeoutAfterXSeconds FClientConnectionTimeoutAfterXSeconds = TAppSettingsManager.GetInt32("Server.ClientConnectionTimeoutAfterXSeconds", 20); // Server.ClientAppDomainShutdownAfterKeepAliveTimeout FClientAppDomainShutdownAfterKeepAliveTimeout = TAppSettingsManager.GetBoolean("Server.ClientAppDomainShutdownAfterKeepAliveTimeout", true); FSMTPServer = TAppSettingsManager.GetValue("Server.SMTPServer", "localhost"); // This is disabled in processing at the moment, so we reflect that here. When it works change to true FAutomaticIntranetExportEnabled = TAppSettingsManager.GetBoolean("Server.AutomaticIntranetExportEnabled", false); // The following setting specifies the email address where the Intranet Data emails are sent to when "Server.AutomaticIntranetExportEnabled" is true. FIntranetDataDestinationEmail = TAppSettingsManager.GetValue("Server.IntranetDataDestinationEmail", "???@???.org"); // The following setting is temporary - until we have created a GUI where users can specify the email address for the // responsible Personnel and Finance persons themselves. Those will be stored in SystemDefaults then. FIntranetDataSenderEmail = TAppSettingsManager.GetValue("Server.IntranetDataSenderEmail", "???@???.org"); // Determine network configuration of the Server Networking.DetermineNetworkConfig(out FHostName, out FHostIPAddresses); FApplicationVersion = TFileVersionInfo.GetApplicationVersion(); }
/// <summary> /// Initialises the internal variables that hold the Server Settings, using the current config file. /// /// </summary> /// <returns>void</returns> public TSrvSetting() { if (USingletonSrvSetting == null) { USingletonSrvSetting = this; } FConfigurationFile = TAppSettingsManager.ConfigFileName; FExecutingOS = Utilities.DetermineExecutingOS(); // Server.RDBMSType FRDBMSType = CommonTypes.ParseDBType(TAppSettingsManager.GetValue("Server.RDBMSType", "postgresql")); FDatabaseHostOrFile = TAppSettingsManager.GetValue("Server.DBHostOrFile", "localhost"); FDatabasePort = TAppSettingsManager.GetValue("Server.DBPort", "5432"); FDatabaseName = TAppSettingsManager.GetValue("Server.DBName", "openpetra"); FDBUsername = TAppSettingsManager.GetValue("Server.DBUserName", "petraserver"); FDBPassword = TAppSettingsManager.GetValue("Server.DBPassword", string.Empty, false); FDBConnectionCheckInterval = TAppSettingsManager.GetInt32("Server.DBConnectionCheckInterval", 0); FApplicationBinFolder = TAppSettingsManager.GetValue("Server.ApplicationBinDirectory", string.Empty, false); if (FDBPassword == "PG_OPENPETRA_DBPWD") { // get the password from the file ~/.pgpass. This currently only works for PostgreSQL on Linux using (StreamReader sr = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar + ".pgpass")) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.StartsWith(FDatabaseHostOrFile + ":" + FDatabasePort + ":" + FDatabaseName + ":" + FDBUsername + ":") || line.StartsWith("*:" + FDatabasePort + ":" + FDatabaseName + ":" + FDBUsername + ":")) { FDBPassword = line.Substring(line.LastIndexOf(':') + 1); break; } } } } if (TAppSettingsManager.HasValue("Server.LogFile")) { FServerLogFile = TAppSettingsManager.GetValue("Server.LogFile", false); } else { // maybe the log file has already been set, eg. by the NUnit Server Test FServerLogFile = TLogging.GetLogFileName(); if (FServerLogFile.Length == 0) { // this is effectively the bin directory (current directory) FServerLogFile = "Server.log"; } } // Server.Port FIPBasePort = TAppSettingsManager.GetInt16("Server.Port", 9000); FRunAsStandalone = TAppSettingsManager.GetBoolean("Server.RunAsStandalone", false); // Server.ClientIdleStatusAfterXMinutes FClientIdleStatusAfterXMinutes = TAppSettingsManager.GetInt32("Server.ClientIdleStatusAfterXMinutes", 5); // Server.ClientKeepAliveCheckIntervalInSeconds FClientKeepAliveCheckIntervalInSeconds = TAppSettingsManager.GetInt32("Server.ClientKeepAliveCheckIntervalInSeconds", 60); // Server.ClientKeepAliveTimeoutAfterXSeconds_LAN FClientKeepAliveTimeoutAfterXSecondsLAN = TAppSettingsManager.GetInt32("Server.ClientKeepAliveTimeoutAfterXSeconds_LAN", 60); // Server.ClientKeepAliveTimeoutAfterXSeconds_Remote FClientKeepAliveTimeoutAfterXSecondsRemote = TAppSettingsManager.GetInt32("Server.ClientKeepAliveTimeoutAfterXSeconds_Remote", (ClientKeepAliveTimeoutAfterXSecondsLAN * 2)); // Server.ClientConnectionTimeoutAfterXSeconds FClientConnectionTimeoutAfterXSeconds = TAppSettingsManager.GetInt32("Server.ClientConnectionTimeoutAfterXSeconds", 20); // Server.ClientAppDomainShutdownAfterKeepAliveTimeout FClientAppDomainShutdownAfterKeepAliveTimeout = TAppSettingsManager.GetBoolean("Server.ClientAppDomainShutdownAfterKeepAliveTimeout", true); FSmtpHost = TAppSettingsManager.GetValue("SmtpHost", ""); FSmtpPort = TAppSettingsManager.GetInt32("SmtpPort", 25); FSmtpUser = TAppSettingsManager.GetValue("SmtpUser", "YourSmtpUser"); FSmtpPassword = TAppSettingsManager.GetValue("SmtpPassword", "YourSmtpPassword"); FSmtpEnableSsl = TAppSettingsManager.GetBoolean("SmtpEnableSsl", true); FSmtpAuthenticationType = TAppSettingsManager.GetValue("SmtpAuthenticationType", "config").ToLower(); FSmtpIgnoreServerCertificateValidation = TAppSettingsManager.GetBoolean("IgnoreServerCertificateValidation", false); // Determine network configuration of the Server Networking.DetermineNetworkConfig(out FHostName, out FHostIPAddresses); FApplicationVersion = TFileVersionInfo.GetApplicationVersion(); }