예제 #1
0
        private async void ButtonConfStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (Utils.PersonsList.Count < 1)
            {
                return;
            }

            ButtonIsEnable(false);
            Utils.IsPermit   = true;
            Utils.ResultPers = new List <PersonStruct>();

            var list = Utils.PersonsList;

            await Task.Run(async() =>
            {
                while (list.Count > 0 && Utils.IsPermit)
                {
                    var current = list[0];
                    Utils.PersonsList.Remove(list[0]);

                    try
                    {
                        var result = await MailConfirm.AcceptConfirm(current.Mail, current.Pass);
                        if (result)
                        {
                            Informer.RaiseOnResultReceived($"{list[0].Mail} successfully confirmed");
                            current.Result = "confirmed";
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception)
                    {
                        Informer.RaiseOnResultReceived($"{list[0].Mail} is not confirmed");
                        current.Result = "fail confirm";
                    }

                    Utils.ResultPers.Add(current);
                }

                await XlsxSave.SaveInXls(Utils.ResultPers, "ResultConf.xlsx");
                await XlsxSave.SaveInXls(list, "RestConf.xlsx");
                Utils.DisposeWebDrivers();
            });

            ButtonIsEnable(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);
        }