/// <summary> /// Загрузка настроек на стороне сервера /// </summary> /// <param name="name">Имя настройки</param> /// <returns>класс содержащий настройки</returns> public void LoadSettings() { Logger logger = LogManager.GetCurrentClassLogger(); //logger.Debug("LoadSettings from "+Directory.GetCurrentDirectory()); if (File.Exists("set.xml")) { XmlSerializer mySerializer = new XmlSerializer(typeof(SA1CConfig)); FileStream myFileStream = new FileStream("set.xml", FileMode.Open); config = (SA1CConfig)mySerializer.Deserialize(myFileStream); myFileStream.Close(); //поддержка старой версии настроек if (config.Version == "1") { foreach (BaseConfig baseConfig in config.basesConfig) { //зашифруем пароли baseConfig.baseInfo.SetPassword(baseConfig.baseInfo.Password); //и разделим IP и Port int index = baseConfig.IP.LastIndexOf(':'); if (index == -1) { continue; } int length = baseConfig.IP.Length - 1; baseConfig.Port = baseConfig.IP.Substring(index + 1, length - index); baseConfig.IP = baseConfig.IP.Substring(0, index); } SaveSettings(); } } }
//Logger logger = LogManager.GetCurrentClassLogger(); #region Members public ServiceSA1C() { config = new SA1CConfig(); Logger logger = LogManager.GetCurrentClassLogger(); //logger.Debug("Создан экземпляр ServiceSA1C"); //проверим каталоги для обмена, если их нет, то создадим string OutDirectory = Path.GetTempPath() + @"SA1C\Out\"; string InDirectory = Path.GetTempPath() + @"SA1C\In\"; if (!Directory.Exists(OutDirectory)) { Directory.CreateDirectory(OutDirectory); } if (!Directory.Exists(InDirectory)) { Directory.CreateDirectory(InDirectory); } LoadSettings(); }