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))); } }
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); } }
public void Handle(CheckParams checkParams, NetHelper nHelper, CancellationToken token) { CheckParams = checkParams; SetRestartState(); while (_currentState != null) { if (token.IsCancellationRequested) { token.ThrowIfCancellationRequested(); } _currentState.Handle(nHelper); } }
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); } } }
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); }
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); } }
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))); } }