// loads configuration parameters and returns a string of all configuration settings // that can be used to store in database string LoadConfigurationSettings() { StringBuilder configSettings = new StringBuilder(); _connectionKey = AppConfigMgr.GetValue(DataAccess.Constants.ConnectionKey); configSettings.AppendFormat("{0} : {1}", DataAccess.Constants.ConnectionKey, _connectionKey); _loggingKey = AppConfigMgr.GetValue(ILoggingManagement.Constants.LoggingKey); configSettings.AppendFormat("{0} : {1}", ILoggingManagement.Constants.LoggingKey, _loggingKey); _engineId = AppConfigMgr.GetValueOrDefault(TaskProcessing.Constants.EngineId, null); configSettings.AppendFormat("{0} : {1}", TaskProcessing.Constants.EngineId, _engineId); _taskAssemblyPath = AppConfigMgr.GetValueOrDefault(TaskProcessing.Constants.TaskAssemblyPath, null); configSettings.AppendFormat("{0} : {1}", TaskProcessing.Constants.TaskAssemblyPath, _taskAssemblyPath); _hostEndpointAddress = AppConfigMgr.GetValueOrDefault(TaskProcessing.Constants.HostEndpointAddress, null); configSettings.AppendFormat("{0} : {1}", TaskProcessing.Constants.HostEndpointAddress, _hostEndpointAddress); string maxTasks = AppConfigMgr.GetValueOrDefault(TaskProcessing.Constants.MaxTasksInParallel , _maxTasks.ToString()); if (!string.IsNullOrEmpty(maxTasks)) { int maxTasksTmp; if (int.TryParse(maxTasks, out maxTasksTmp)) { _maxTasks = maxTasksTmp; } } configSettings.AppendFormat("{0} : {1}", TaskProcessing.Constants.MaxTasksInParallel, maxTasks); configSettings.AppendFormat("{0} : {1}", ILoggingManagement.Constants.TraceLevel, enumTraceLevel.None.ToString()); _configId = AppConfigMgr.GetValueOrDefault(TaskProcessing.Constants.ConfigId, null); configSettings.AppendFormat("{0} : {1}", TaskProcessing.Constants.ConfigId, _configId); return(configSettings.ToString()); }
private static void HandleException(Exception e) { try { LoggingMgr loggingMgr = new LoggingMgr(AppConfigMgr.GetValue(Configuration.Constants.LoggingKey).ToString()); loggingMgr.WriteToLog(e, enumEventPriority.Critical); } finally { string errorFileName = "DbSetupMgr.Exception.txt"; string msg = "Will attempt to write exception details to file: " + errorFileName + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace + Environment.NewLine; MessageBox.Show(msg, "Fatal Error - Look for file: " + errorFileName); FileManagement.FileMgr.WriteTextToFile(errorFileName, msg, false, true); } }
public static void RunTest() { ////string configConnStr = ConfigurationManager.AppSettings[ "ConfigConnStr" ]; ////string appConfigSetName = ConfigurationManager.AppSettings[ "AppConfigSetName" ]; ////string sysConfigSetName = ConfigurationManager.AppSettings[ "SysConfigSetName" ]; ////AppConfigMgr.Initialize( configConnStr, appConfigSetName, sysConfigSetName ); //?? AppConfigMgr.ConfigChanging += new AppConfigMgr.ConfigChangingCallback( AppConfigMgr_ConfigChanging ); // Read configuration string vehicleSourceBook = AppConfigMgr.GetValue("VehicleSourceBook"); // Example for IP address object returned by AppConfigMgr class System.Net.IPAddress ipAddress = AppConfigMgr.GetValue("VehicleServer_IPAddress", val => System.Net.IPAddress.Parse(val)); }