// must still be added to the Tool code private static void HsconfReader(List <string> HsconfPropertiesList) { //IDictionary<string,string> HsConfPropertiesVal; ConfigFileReader confFileParser = new ConfigFileReader("<ServerHsConfLocation>", "test"); ConfigFileDBInfo platformDBInfo = confFileParser.DBPlatformInfo; string _propValue; IDictionary <string, string> HsConfPropertiesVal = new Dictionary <string, string>(); foreach (string HsconfProperty in HsconfPropertiesList) { bool isEncrypted = platformDBInfo.GetProperty(HsconfProperty).IsEncrypted; // checking if prop is encrypted if (isEncrypted) { _propValue = platformDBInfo.GetProperty(HsconfProperty).GetDecryptedValue(CryptoUtils.GetPrivateKeyFromFile("<ServerHsConfLocation>")); } else { _propValue = platformDBInfo.GetProperty(HsconfProperty).Value; } HsConfPropertiesVal.Add(HsconfProperty, _propValue); Console.WriteLine(HsconfProperty + " " + _propValue); } }
public static string GetPlatformDBAdminUser() { ConfigFileReader confFileParser = new ConfigFileReader(Program.platformConfigurationFilepath, Program.osPlatformVersion); ConfigFileDBInfo platformDBInfo = confFileParser.DBPlatformInfo; return(platformDBInfo.GetProperty("AdminUser").Value); }
static void Main(string[] args) { OSDiagToolConfReader dgtConfReader = new OSDiagToolConfReader(); var configurations = dgtConfReader.GetOsDiagToolConfigurations(); try { RegistryKey OSPlatformInstaller = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(_osServerRegistry); osPlatformVersion = (string)OSPlatformInstaller.GetValue("Server"); } catch (Exception e) { osPlatformVersion = null; } if (osPlatformVersion == null) { Application.Run(new OSDiagToolForm.puf_popUpForm(OSDiagToolForm.puf_popUpForm._feedbackErrorType, "OutSystems Platform Server not found. ")); } else { _osInstallationFolder = Platform.PlatformUtils.GetPlatformInstallationPath(_osServerRegistry); _platformConfigurationFilepath = Path.Combine(_osInstallationFolder, "server.hsconf"); ConfigFileReader confFileParser = new ConfigFileReader(_platformConfigurationFilepath, osPlatformVersion); ConfigFileDBInfo platformDBInfo = confFileParser.DBPlatformInfo; dbEngine = platformDBInfo.DBMS.ToLower(); var sqlConnString = new DBConnector.SQLConnStringModel(); var orclConnString = new DBConnector.OracleConnStringModel(); if (dbEngine.Equals("sqlserver")) { sqlConnString.dataSource = platformDBInfo.GetProperty("Server").Value; sqlConnString.initialCatalog = platformDBInfo.GetProperty("Catalog").Value; } else if (dbEngine.Equals("oracle")) { orclConnString.host = platformDBInfo.GetProperty("Host").Value; orclConnString.port = platformDBInfo.GetProperty("Port").Value; orclConnString.serviceName = platformDBInfo.GetProperty("ServiceName").Value; } Application.EnableVisualStyles(); Application.Run(new OSDiagToolForm.OsDiagForm(configurations, platformDBInfo.DBMS, sqlConnString, orclConnString)); } }
public DBConnector.OracleConnStringModel SetPlatformOracleConnString(bool isLogDatabase, bool isSaCredentials, ConfigFileDBInfo platformDBInfo = null, ConfigFileDBInfo loggingDBInfo = null, string saUser = null, string saPwd = null) { var orclConnString = new DBConnector.OracleConnStringModel(); FileLogger.TraceLog("isLogDB: " + isLogDatabase); if (!isLogDatabase && !isSaCredentials) // Uses Runtime user and Platform Main Catalog { orclConnString.host = platformDBInfo.GetProperty("Host").Value; orclConnString.port = platformDBInfo.GetProperty("Port").Value; orclConnString.serviceName = platformDBInfo.GetProperty("ServiceName").Value; orclConnString.userId = platformDBInfo.GetProperty("RuntimeUser").Value; orclConnString.pwd = platformDBInfo.GetProperty("RuntimePassword").GetDecryptedValue(CryptoUtils.GetPrivateKeyFromFile(Program.privateKeyFilepath)); } else if (isLogDatabase) // Uses Runtime Log user and Log Catalog //ConfigFileDBInfo loggingDBInfo = confFileParser.DBLoggingInfo; { orclConnString.host = loggingDBInfo.GetProperty("Host").Value; orclConnString.port = loggingDBInfo.GetProperty("Port").Value; orclConnString.serviceName = loggingDBInfo.GetProperty("ServiceName").Value; orclConnString.userId = loggingDBInfo.GetProperty("AdminUser").Value; // needs to use oslog configurations orclConnString.pwd = loggingDBInfo.GetProperty("AdminPassword").GetDecryptedValue(CryptoUtils.GetPrivateKeyFromFile(Program.privateKeyFilepath)); } else if (isSaCredentials) // Uses SA Credentials inputted on the Form { orclConnString.host = platformDBInfo.GetProperty("Host").Value; orclConnString.port = platformDBInfo.GetProperty("Port").Value; orclConnString.serviceName = platformDBInfo.GetProperty("ServiceName").Value; orclConnString.userId = saUser; orclConnString.pwd = saPwd; } return(orclConnString); }
public DBConnector.SQLConnStringModel SetPlatformSQLConnString(bool isLogDatabase, bool isSaCredentials, ConfigFileDBInfo platformDBInfo = null, ConfigFileDBInfo loggingDBInfo = null, string saUser = null, string saPwd = null) { var sqlConnString = new DBConnector.SQLConnStringModel(); if (!isLogDatabase && !isSaCredentials) // Uses Runtime user and Platform Main Catalog { string platformDBRuntimeUser = platformDBInfo.GetProperty("RuntimeUser").Value; string platformDBRuntimeUserPwd = platformDBInfo.GetProperty("RuntimePassword").GetDecryptedValue(CryptoUtils.GetPrivateKeyFromFile(Program.privateKeyFilepath)); sqlConnString.dataSource = platformDBInfo.GetProperty("Server").Value; sqlConnString.initialCatalog = platformDBInfo.GetProperty("Catalog").Value; sqlConnString.userId = platformDBRuntimeUser; sqlConnString.pwd = platformDBRuntimeUserPwd; } else if (isLogDatabase) // Uses Runtime Log user and Log Catalog { sqlConnString.dataSource = loggingDBInfo.GetProperty("Server").Value; sqlConnString.userId = loggingDBInfo.GetProperty("RuntimeUser").Value; // needs to use oslog configurations sqlConnString.pwd = loggingDBInfo.GetProperty("RuntimePassword").GetDecryptedValue(CryptoUtils.GetPrivateKeyFromFile(Program.privateKeyFilepath)); sqlConnString.initialCatalog = loggingDBInfo.GetProperty("Catalog").Value; } else if (isSaCredentials) // Uses SA Credentials inputted on the Form { sqlConnString.dataSource = platformDBInfo.GetProperty("Server").Value; sqlConnString.initialCatalog = platformDBInfo.GetProperty("Catalog").Value; sqlConnString.userId = saUser; sqlConnString.pwd = saPwd; } return(sqlConnString); }
public PlatformConnectionStringDefiner GetConnectionString(string dbEngine, bool isLogDatabase, bool isSaCredentials, PlatformConnectionStringDefiner ConnStringDefiner, string saUser = null, string saPwd = null) { ConfigFileReader confFileParser = new ConfigFileReader(Program.platformConfigurationFilepath, Program.osPlatformVersion); ConfigFileDBInfo platformDBInfo = confFileParser.DBPlatformInfo; ConfigFileDBInfo loggingDBInfo = confFileParser.DBLoggingInfo; if (dbEngine.Equals("sqlserver")) { ConnStringDefiner.SQLConnString = SetPlatformSQLConnString(isLogDatabase, isSaCredentials, platformDBInfo, loggingDBInfo, saUser, saPwd); return(ConnStringDefiner); } else if (dbEngine.Equals("oracle")) { ConnStringDefiner.OracleConnString = SetPlatformOracleConnString(isLogDatabase, isSaCredentials, platformDBInfo, loggingDBInfo, saUser, saPwd); ConnStringDefiner.AdminSchema = platformDBInfo.GetProperty("AdminUser").Value; return(ConnStringDefiner); } return(null); }