/// <summary> /// Перезапуск слушателя изменений при обновлении конфигурации приложения /// </summary> /// <param name="config"></param> private void Config_OnConfigUpdated(IConfig config) { _config = config; if (string.IsNullOrEmpty(_config?.ServerAddress) || string.IsNullOrEmpty(_config?.UserName) || string.IsNullOrEmpty(_config?.UserPassword)) { return; } Stop(); Thread.Sleep(1000); RunAsync(3000); AdNotifySender.Instance(); }
/// <summary> /// Включение компонента /// </summary> /// <param name="decorators"></param> public override void Init(params IComponent[] decorators) { base.Init(decorators); HelpMessage.MsgList.Add( "/NotificationsOn [/non] -uUSER_AD_ACCOUNT_NAME -pUSER_AD_PASSWORD : Subscribe to notifications on AD changes"); HelpMessage.MsgList.Add("/NotificationsOff [/nof] : Unsubscribe to notifications on AD changes"); _decorators = decorators; _logger = _decorators?.OfType <ILogger>().FirstOrDefault(); _config = (Config.Config)_decorators?.OfType <IConfig>().FirstOrDefault(); _logger?.Log("Initializing Service: Active Directory Snapshot...", OutputTarget.Console); if (string.IsNullOrEmpty(_config?.ServerAddress) || string.IsNullOrEmpty(_config?.UserName) || string.IsNullOrEmpty(_config?.UserPassword)) { return; } Config.Config.OnConfigUpdated += Config_OnConfigUpdated; RunAsync(3000); AdNotifySender.Instance(); }