public void SaveChanges() { using (RegBase regBase = new RegBase()) { var settings = regBase.settings.First(); settings.rucaptcha_api_key = RuCaptchaApiKey; settings.sms_reg_api_key = SmsRegApiKey; regBase.SaveChanges(); } }
public void SaveProxys() { using (RegBase regBase = new RegBase()) { foreach (var proxy in listProxys) { if (regBase.free_http_proxys.Where(p => p.ip.Equals(proxy.ip)).Count() != 0) { proxy.id = regBase.free_http_proxys.Where(p => p.ip.Equals(proxy.ip)).First().id; } if (regBase.free_http_proxys.Where(p => p.ip.Equals(proxy.ip)).Count() != 0) { var proxyDb = regBase.free_http_proxys.Where(p => p.ip.Equals(proxy.ip)).First(); proxyDb.port = proxy.port; } else { regBase.free_http_proxys.Add(proxy); } } regBase.SaveChanges(); } }
public bool OpenRegistration(AccGoogle acc) { //79296911370 //using (RegBase regBase = new RegBase()) //{ // google_accs googleAcc = new google_accs() // { // login = acc.Login, // alt_email = acc.AlterEmail, // date_birth = acc.DateBirth, // date_registered = DateTime.Now, // first_name = acc.FirstName, // last_name = acc.LastName, // password = acc.Password, // phone = "79296911370", // sex_id = (int)acc.Sex // }; // regBase.google_accs.Add(googleAcc); // regBase.SaveChanges(); //} //1-я страница driver.Navigate().GoToUrl("https://mail.google.com/mail/signup"); IWebElement element = null; if (!Check2Page()) { throw new Exception("Error in 2 page (registration form)"); } setFirstName(acc.FirstName); setLastName(acc.LastName); //Username setUserName(acc.Login); //Passwd setPassword(acc.Password); //ConfirmPasswd setConfirmPassword(acc.Password); Thread.Sleep(3000); //next click clickNext1(); Thread.Sleep(3000); //3 страница ввода телефона if (!Check3Page()) { throw new Exception("Error in 3 page (input phone)"); } SmsRegApi smsRegApi = new SmsRegApi(acc, settingsDB.SmsRegApiKey); //запрос на номер bool f = smsRegApi.GetNum().GetAwaiter().GetResult(); if (f) { //ввод номера и нажатие кнопки далее for (; ;) { Thread.Sleep(1000); var status = smsRegApi.getState().GetAwaiter().GetResult(); if (status is null) { return(false); } if (status.number != null) { setPhoneNumber(status.number); acc.Phone = status.number; //gradsIdvPhoneNext clickNext2(); smsRegApi.setReady(); break; } } //ввод ответа из смс if (!Check4Page()) { throw new Exception("Error in 4 page (after input phone)"); } for (; ;) { var status = smsRegApi.getState().GetAwaiter().GetResult(); if (status is null) { return(false); } if (status.msg != null) { setCodeFromSms(status.msg); //gradsIdvVerifyNext clickNext3(); smsRegApi.setOperationOk().GetAwaiter().GetResult(); break; } } //та страница, которая содержит поле для ввода альтернативного адреса электронной почты, дата рождения и пол if (!Check5Page()) { throw new Exception("Error in 5 page (alternative email, datebirth and other)"); } //email setAlternativeEmeil(acc.AlterEmail); //day setDay(acc.DateBirth.Day); //month element = driver.FindElement(By.XPath("//select[@id='month']/option[@value='" + acc.DateBirth.Month.ToString() + "']")); element.Click(); //year element = driver.FindElements(By.TagName("input"))[3]; element.SendKeys(acc.DateBirth.Year.ToString()); //Sex element = driver.FindElement(By.XPath("//select[@id='gender']/option[@value='" + (int)acc.Sex + "']")); element.Click(); //button next element = driver.FindElement(By.Id("personalDetailsNext")); element.Click(); //больше возможностей благодаря номеру if (!Check6Page()) { throw new Exception("Error in 6 page (More room features)"); } element = driver.FindElements(By.TagName("button"))[2]; element.Click(); if (!Check7Page()) { throw new Exception("Error in 7 page (Confidentiality and conditions)"); } element = driver.FindElement(By.Id("termsofserviceNext")); element.Click(); if (!Check8Page()) { throw new Exception("Error in 8 page (End Registration)"); } element = driver.FindElement(By.Id("profileIdentifier")); string email = element.Text; if (email.Remove(email.IndexOf('@')).Equals(acc.Login)) { using (RegBase regBase = new RegBase()) { google_accs googleAcc = new google_accs() { login = acc.Login, alt_email = acc.AlterEmail, date_birth = acc.DateBirth, date_registered = DateTime.Now, first_name = acc.FirstName, last_name = acc.LastName, password = acc.Password, phone = acc.Phone, sex_id = (int)acc.Sex }; regBase.google_accs.Add(googleAcc); regBase.SaveChanges(); } return(true); } } ////page3 телефонный номер //element = browser.FindElement(By.Id("countryList")); //var elements = element.FindElements(By.XPath("//div[@class and @data-value]")); //element.Click(); //foreach (var el in elements) //{ // if (el.GetAttribute("data-value").Equals("ru")) // { // el.FindElement(By.TagName("content")).Click(); // break; // } //} return(true); }
public bool OpenRegistration(AccIua acc) { acc.StatusText = "Открытие страницы"; Start: goToMainPage(); goToRegisterPage(); setLogin(acc.Login); //checkLoginErrors if (!checkLoginErrors()) { acc.ChangeLogin(); goto Start; } //domen setDomen(acc.Domen); //password setPasswords(acc.Password); //recaptcha try { RuCaptcha.SolveRecaptcha(settingsDB.RuCaptchaApiKey, acc, driver); } catch (Exception ex) { goto Start; } //submit clickSubmitButton(); Thread.Sleep(1000); //тут проверить перешло ли на следующую страницу if (!Check2pageIua()) { string errorStr = GetErrorStr1(); //Регистрация временно не доступна. Попробуйте позже. goto Start; } //firstName setFirstName(acc.FirstName); //LastName setLastName(acc.LastName); //sex setSex(acc.Sex); //day setDay(acc.DateBirth.Day); //month setMonth(acc.DateBirth.Month); //year setYear(acc.DateBirth.Year); //country setCountry(acc.Country); //city setCity(acc.City); //agree setAgree(); //quest setSecretQuestion(acc.SecretQuestion); //answer setAnswer(acc.Answer); //submit clickSubmitButton2(); if (!Check3PageIua()) { } using (RegBase regBase = new RegBase()) { var citysId = regBase.citys.Where(x => x.value.Equals(acc.City)).First().id; var countryId = regBase.countrys.Where(x => x.value.Equals(acc.Country)).First().id; var domenId = regBase.i_ua_domen_names.Where(x => x.value.Equals(acc.Domen)).First().id; var secretQuestion_id = regBase.secret_questions.Where(x => x.value.Equals(acc.SecretQuestion)).First().id; var sexId = (int)acc.Sex; var accDb = new i_ua_accs() { answer = acc.Answer, citys_id = citysId, country_id = countryId, date_birth = acc.DateBirth, date_registered = DateTime.Now, domen_id = domenId, first_name = acc.FirstName, last_name = acc.LastName, login = acc.Login, password = acc.Password, secret_question_id = secretQuestion_id, sex_id = sexId, }; regBase.i_ua_accs.Add(accDb); regBase.SaveChanges(); driver.Close(); acc.StatusText = "Зарегистрировано"; } return(true); }