예제 #1
0
        private async void ButtonStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (!Codes.Any())
            {
                Informer.RaiseOnResultReceived("No codes found");
                return;
            }

            ButtonIsEnabled(false);
            Utils.IsPermit = true;
            if (Utils.DriverList.Count > Settings.Default.CaptchaNum)
            {
                var num = Utils.DriverList.Count - Settings.Default.CaptchaNum;
                DeleteBrowsers(num);
            }
            else
            {
                var num = Settings.Default.CaptchaNum - Utils.DriverList.Count;
                LoadBrowsers(num);
            }
            CaptchaTimer.Elapsed += CaptchaTimer_Elapsed;
            Utils.CancelToken     = new CancellationTokenSource();
            CaptchaTimer.Start();

            await Task.Run(async() =>
            {
                try
                {
                    await MainCycle.InitializTask(Codes, Proxies, Settings.Default.CaptchaNum);
                }
                catch (Exception ex)
                {
                    Informer.RaiseOnResultReceived(ex);
                }
            });

            ButtonStop_OnClick(ButtonStop, null);
            ButtonIsEnabled(true);
        }
예제 #2
0
        private async void ButtonRegStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (Utils.PersonsList.Count < 1)
            {
                return;
            }

            ButtonIsEnable(false);
            Utils.CaptchaLife     = 120;
            Utils.MaxCaptchaQueue = 10;
            Utils.IsPermit        = true;
            Utils.AntigateService = "rucaptcha.com";
            CaptchaTimer.Elapsed += RaiseOnTimerElapsed;
            CaptchaTimer.Start();
            Utils.ResultPers = new List <PersonStruct>();

            var list = Utils.PersonsList;

            await Task.Run(async() =>
            {
                while (list.Count > 0 && Utils.IsPermit)
                {
                    var current = new PersonStruct();
                    try
                    {
                        while (Utils.CaptchaQueueCount < 1 && Utils.IsPermit)
                        {
                            await Task.Delay(1000);
                        }

                        if (!Utils.IsPermit)
                        {
                            break;
                        }

                        current = list[0];
                        Utils.PersonsList.Remove(current);

                        var result = await MainCycle.GetResult(list[0], Utils.CaptchaQueue);

                        if (result == "Compleate")
                        {
                            Informer.RaiseOnResultReceived($"Account for {list[0].Mail} successfully registered");
                            current.Result = "registered but not confirmed";
                        }
                        else
                        {
                            throw new Exception(result);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("There is already"))
                        {
                            current.Result = "confirmed";
                        }
                        else if (ex.Message.Contains("Не удалось соединиться с HTTP-сервером"))
                        {
                            current.Result = "proxy fail";
                        }
                        else
                        {
                            current.Result = "fail register";
                        }
                        Informer.RaiseOnResultReceived(ex.Message.Contains("Не удалось соединиться с HTTP-сервером")
                            ? $"Bad proxy {current.Proxy.Host} for {current.Mail}"
                            : $"{ex.Message} for {current.Mail}");
                    }
                    Utils.ResultPers.Add(current);
                }

                //CaptchaTimer.Stop();
                //CaptchaTimer.Elapsed -= RaiseOnTimerElapsed;

                await XlsxSave.SaveInXls(Utils.ResultPers, "ResultReg.xlsx");
                await XlsxSave.SaveInXls(list, "RestReg.xlsx");

                Utils.DisposeWebDrivers();
            });

            ButtonIsEnable(true);
        }