Beispiel #1
0
 public ChromeDriverResolver(ChromeDriverTask task, ILogger lg, ChromeDriverSettings settings)
 {
     _lg       = lg;
     _prefix   = $"[ChromeDriver(Task:[{task.Name}]; ID:[{task.Guid}])] -";
     _settings = settings;
     _task     = task;
 }
        public void SolveSteps()
        {
            _logger.Info("Solving new program tree!");

            var t = new ChromeDriverTask
            {
                Name      = UserData.CustomerNameAndSurname,
                TargetUrl = Url,
                Proxy     = this._proxy
            };

            this.WebDriver = new ChromeDriverResolver(t, this._logger, this._settings.ChromeDriverSettings);

            if (!WebDriver.Initialize())
            {
                this._logger.Error("ChromeWebDriver can't be initialized -> Stop task!");
                return;
            }

            if (!this.SolveFields())
            {
                this._logger.Info("Fields cannot be filled successfully!");
                this.WebDriver.Dispose();
                return;
            }
            for (var i = 0; i < 200; i++)
            {
                if (!ReferenceEquals(this._currentTask, null))
                {
                    switch (this._currentTask.Status)
                    {
                    case Captcha.RuCaptcha.Enums.RuCaptchaTaskStatus.Unknow:
                        break;

                    case Captcha.RuCaptcha.Enums.RuCaptchaTaskStatus.NotReady:
                        break;

                    case Captcha.RuCaptcha.Enums.RuCaptchaTaskStatus.Solved:
                        this.Finish(this._currentTask.CaptchaSolution);
                        return;

                    case Captcha.RuCaptcha.Enums.RuCaptchaTaskStatus.Unsolvable:
                        return;

                    default:
                        return;
                    }
                }
                _logger.Info($"{i + 1} attemp to check captcha solution...");
                Thread.Sleep(5000);
            }
        }
Beispiel #3
0
        public void SolveSteps()
        {
            var t = new ChromeDriverTask
            {
                Name      = UserData.CustomerNameAndSurname,
                TargetUrl = _settings.SitaUrl,
                Proxy     = this._proxy
            };

            WebDriver = new ChromeDriverResolver(t, this._logger, this._controllerSettings.ChromeDriverSettings);

            if (!WebDriver.Initialize())
            {
                this._logger.Error("ChromeWebDriver can't be initialized -> Stop task!");
                return;
            }

            if (!this.DoFirstStep())
            {
                this._logger.Error("First step can't be solved, please, see messages higher to see more information");
                this.WebDriver.Dispose();
                return;
            }

            if (!this.DoSecondStep())
            {
                this.WebDriver.Dispose();
                this._logger.Error("Second step can't be solved, please, see messages higher to see more information");
                return;
            }

            if (!this.DoThirdStep())
            {
                this._logger.Error("Third step can't be solved, please, see messages higher to see more information");
                this.WebDriver.Dispose();
                return;
            }

            if (!this.DoFourthStep())
            {
                this._logger.Error("Fourth step can't be solved, please, see messages higher to see more information");
                this.WebDriver.Dispose();
                return;
            }

            for (var i = 0; i < 200; i++)
            {
                if (!ReferenceEquals(this._currentTask, null))
                {
                    switch (this._currentTask.Status)
                    {
                    case Captcha.RuCaptcha.Enums.RuCaptchaTaskStatus.Unknow:
                        break;

                    case Captcha.RuCaptcha.Enums.RuCaptchaTaskStatus.NotReady:
                        break;

                    case Captcha.RuCaptcha.Enums.RuCaptchaTaskStatus.Solved:
                        this.FinishSteps(this._currentTask.CaptchaSolution);
                        return;

                    case Captcha.RuCaptcha.Enums.RuCaptchaTaskStatus.Unsolvable:
                        return;

                    default:
                        return;
                    }
                }
                _logger.Info($"{i + 1} attemp to check captcha solution...");
                Thread.Sleep(5000);
            }
        }