protected async Task <IAccountData> TryRegister(IEnumerable <SmsServiceInfo> infos) { var accountData = GetRandomAccountData(); foreach (var info in infos) { accountData = GetRandomAccountData(info.CountryCode); accountData.PhoneCountryCode = Enum.GetName(typeof(CountryCode), info.CountryCode); accountData = await Registration(accountData, info.SmsServiceCode, info.ServiceCode); if (accountData == null) { break; } if (accountData.Success) { break; } if (string.IsNullOrEmpty(accountData.ErrMsg)) { break; } if (accountData.ErrMsg.Equals(BotMessages.NoPhoneNumberMessage)) { info.Skiped = true; } if (!BotMessages.BadNumber.Contains(accountData.ErrMsg)) { break; } await _smsServices.AddFail(info); } return(accountData); }
private async void TryRegister(IEnumerable <SmsServiceInfo> infos) { if (infos == null || !infos.Any()) { textBox1.AppendText($"Нет стоимостных данных смс сервисов - {DateTime.Now} {Environment.NewLine}"); return; } foreach (var info in infos) { textBox1.AppendText($"Попытка {info.CountryCode} {info.ServiceCode} {info.SmsServiceCode} - {info.Price} руб - {DateTime.Now} {Environment.NewLine}"); var accountData = await Demo(info.ServiceCode, info.SmsServiceCode, info.CountryCode); // if not no numbers then break if (accountData == null) { break; } if (accountData.Success) { break; } if (string.IsNullOrEmpty(accountData.ErrMsg)) { break; } if (accountData.ErrMsg.Equals(BotMessages.NoPhoneNumberMessage)) { info.Skiped = true; } if (!BotMessages.BadNumber.Contains(accountData.ErrMsg)) { break; } await _smsServices.AddFail(info); } }