public static AdNotifySender Instance()
        {
            _instance               = _instance ?? new AdNotifySender();
            _adNotifier             = _adNotifier ?? new AdNotifyCollection();
            _active                 = false;
            AdSnapshot.OnAdChanged += SendNotifyFromQueue;

            return(_instance);
        }
예제 #2
0
        /// <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();
        }
예제 #3
0
        /// <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();
        }