/// <summary> /// Чтение настроек приложения из файла Config.config /// </summary> /// <returns></returns> public bool TryGetParamsFromFile() { if (!File.Exists("Config.config")) { _logger?.Log("Config not found. Ensure, it is exists in the application directory.", OutputTarget.Console | OutputTarget.File); return(false); } var xFile = new XmlDocument(); try { xFile.Load("Config.config"); var xElement = xFile.DocumentElement; GetAdParams(xElement); GetBotParams(xElement); GetUsersParams(xElement); } catch (XPathException e) { _logger?.Log($"Error occured on reading params from Config: {e.Message}", OutputTarget.Console | OutputTarget.File); return(false); } catch (XmlException e) { _logger?.Log($"Error occured on reading params Config: {e.Message}", OutputTarget.Console | OutputTarget.File); return(false); } catch (IOException e) { _logger?.Log($"Error occured on reading file Config: {e.Message}", OutputTarget.Console | OutputTarget.File); return(false); } catch (UnauthorizedAccessException e) { _logger?.Log($"Error occured on reading file Config: {e.Message}", OutputTarget.Console | OutputTarget.File); return(false); } if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPassword) || string.IsNullOrEmpty(ServerAddress) || string.IsNullOrEmpty(TelegramBotToken)) { _logger?.Log("Ensure, Config has correct parameters inside.", OutputTarget.Console | OutputTarget.File); return(false); } OnConfigUpdated?.Invoke(this); return(true); }
public void SetMaxWorker(int numberOfWorker) { Config.MaxWorkers = numberOfWorker; OnConfigUpdated?.Invoke(this, EventArgs.Empty); }
/// <inheritdoc/> public void TriggerConfigUpdate(object sender, EventArgs eventArgs) { OnConfigUpdated?.Invoke(sender, eventArgs); }