/// <summary> /// Конструктор класса. Получает настройки из файла конфигурации /// </summary> /// <param name="configFileName"> /// Имя конфигурации /// </param> public Configurator(string configFileName) { try { var CL = new ConfLoader(configFileName); //Получаем настройки БД Master this.MasterAuthorization = CL.LoadConfig("MasterAuthorization"); this.MasterServerName = CL.LoadConfig("MasterServerName"); this.MasterDBName = CL.LoadConfig("MasterDBName"); this.MasterDBUser = CL.LoadConfig("MasterDBUser"); this.MasterDBPassword = CL.LoadConfig("MasterDBPassword"); //Получаем настройки БД Slave this.SlaveAuthorization = CL.LoadConfig("SlaveAuthorization"); this.SlaveServerName = CL.LoadConfig("SlaveServerName"); this.SlaveDBName = CL.LoadConfig("SlaveDBName"); this.SlaveDBUser = CL.LoadConfig("SlaveDBUser"); this.SlaveDBPassword = CL.LoadConfig("SlaveDBPassword"); //Получаем дополнительные настройки программы this.SchemaName = CL.LoadConfig("SchemaName"); this.MainTimerValue = CL.LoadIntConfig("MainTimer"); this.MaxDBErrorCount = CL.LoadIntConfig("MaxDBErrorCount"); this.SecondaryTimer = CL.LoadIntConfig("SecodaryTimer"); //Получаем настройки почты this.AdminEMail = CL.LoadConfig("AdminEMail"); this.SmtpHost = CL.LoadConfig("SmtpHost"); this.SmtpPort = CL.LoadIntConfig("SmtpPort"); this.SmtpUser = CL.LoadConfig("SmtpUser"); this.SmtpPassword = CL.LoadConfig("SmtpPassword"); this.ProgMail = CL.LoadConfig("ProgMail"); string send = CL.LoadConfig("SendMail"); if (send == "true") { this.SendMail = true; } else { this.SendMail = false; } } catch (System.IO.FileNotFoundException exp) { string errorMsg = String.Format("File Not Found. Check file address. \n Error details:\n {0}", exp.Message); Console.WriteLine(errorMsg); _log.ErrorFormat(errorMsg); } catch (System.Xml.XmlException exp) { string errorMsg = String.Format("Error in XML file. \n Error details:\n {0}", exp.Message); Console.WriteLine(errorMsg); _log.ErrorFormat(errorMsg); } catch (System.FormatException exp) { string errorMsg = String.Format("Error. Wrong format. Error details:\n {0}", exp.Message); Console.WriteLine(errorMsg); _log.ErrorFormat(errorMsg); } }