Beispiel #1
0
        private void Check(CheckParams checkParams, CancellationToken token)
        {
            if (checkParams == null)
            {
                throw new ArgumentNullException(nameof(checkParams));
            }

            try
            {
                NetHelper nHelper = new NetHelper {
                    UserAgent = UserAgentsManager.GetRandomUserAgent()
                };

                var context = new StateContext(_logger, _proxyManager, _captchaService);
                context.OnCheckCompleted += _context_OnCheckCompleted;
                context.Handle(checkParams, nHelper, token);
                context.OnCheckCompleted -= _context_OnCheckCompleted;
            }
            catch (Exception exception)
            {
                _logger.Debug("error while check");
                _logger.Error(exception);

                _accChecked++;
                _badAccounts++;

                FireOnCheckCompleted(CheckResults.Bad, checkParams);

                _eventAggregator.SendMessage(new InformUserMessage(new InformUserMessage.Message(exception.Message, InformUserMessage.MessageType.Error)));
            }
        }
Beispiel #2
0
        public void FireOnCheckCompleted(StateContext context, CheckResults results, CheckParams checkParams)
        {
            var evt = OnCheckCompleted;

            // ReSharper disable once UseNullPropagation
            if (evt != null)
            {
                evt(context, results, checkParams);
            }
        }
        public void Handle(CheckParams checkParams, NetHelper nHelper, CancellationToken token)
        {
            CheckParams = checkParams;
            SetRestartState();
            while (_currentState != null)
            {
                if (token.IsCancellationRequested)
                    token.ThrowIfCancellationRequested();

                _currentState.Handle(nHelper);
            }
        }
Beispiel #4
0
        public void Handle(CheckParams checkParams, NetHelper nHelper, CancellationToken token)
        {
            CheckParams = checkParams;
            SetRestartState();
            while (_currentState != null)
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                _currentState.Handle(nHelper);
            }
        }
Beispiel #5
0
        private void FireOnCheckCompleted(CheckResults results, CheckParams checkParams)
        {
            var evt = OnCheckCompleted;

            // ReSharper disable once UseNullPropagation
            if (evt != null)
            {
                if (checkParams == null)
                {
                    evt(results, null);
                }
                else
                {
                    evt(results, checkParams.Account);
                }
            }
        }
Beispiel #6
0
 private void _context_OnCheckCompleted(StateContext context, CheckResults results, CheckParams checkParams)
 {
     if (results != CheckResults.Init)
     {
         Interlocked.Increment(ref _accChecked);
         if (results == CheckResults.Bad)
         {
             Interlocked.Increment(ref _badAccounts);
         }
         else if (results == CheckResults.Good)
         {
             Interlocked.Increment(ref _validAccounts);
         }
     }
     FireOnCheckCompleted(results, checkParams);
 }
Beispiel #7
0
 private void _context_OnCheckCompleted(StateContext context, CheckResults results, CheckParams checkParams)
 {
     if (results != CheckResults.Init)
     {
         Interlocked.Increment(ref _accChecked);
         if (results == CheckResults.Bad)
         {
             Interlocked.Increment(ref _badAccounts);
         }
         else if (results == CheckResults.Good)
         {
             Interlocked.Increment(ref _validAccounts);
         }
     }
     FireOnCheckCompleted(results, checkParams);
 }
Beispiel #8
0
 private void FireOnCheckCompleted(CheckResults results, CheckParams checkParams)
 {
     var evt = OnCheckCompleted;
     // ReSharper disable once UseNullPropagation
     if (evt != null)
     {
         if (checkParams == null)
             evt(results, null);
         else
             evt(results, checkParams.Account);
     }
 }
Beispiel #9
0
        private void Check(CheckParams checkParams, CancellationToken token)
        {
            if (checkParams == null)
                throw new ArgumentNullException(nameof(checkParams));

            try
            {
                NetHelper nHelper = new NetHelper { UserAgent = UserAgentsManager.GetRandomUserAgent() };

                var context = new StateContext(_logger, _proxyManager, _captchaService);
                context.OnCheckCompleted += _context_OnCheckCompleted;
                context.Handle(checkParams, nHelper, token);
                context.OnCheckCompleted -= _context_OnCheckCompleted;
            }
            catch (Exception exception)
            {
                _logger.Debug("error while check");
                _logger.Error(exception);

                _accChecked++;
                _badAccounts++;

                FireOnCheckCompleted(CheckResults.Bad, checkParams);

                _eventAggregator.SendMessage(new InformUserMessage(new InformUserMessage.Message(exception.Message, InformUserMessage.MessageType.Error)));
            }
        }
Beispiel #10
0
 public void FireOnCheckCompleted(StateContext context, CheckResults results, CheckParams checkParams)
 {
     var evt = OnCheckCompleted;
     // ReSharper disable once UseNullPropagation
     if (evt != null)
     {
         evt(context, results, checkParams);
     }
 }