Exemple #1
0
        protected async Task <IAccountData> Registration(IAccountData accountData, SmsServiceCode smsServiceCode, ServiceCode serviceCode, CountryCode countryCode = CountryCode.RU, ILog log = null)
        {
            try
            {
                log?.Debug($@"{Enum.GetName(typeof(ServiceCode), serviceCode)}  via {Enum.GetName(typeof(SmsServiceCode), smsServiceCode)} start... - {DateTime.Now} {Environment.NewLine}");
                if (string.IsNullOrEmpty(accountData.AccountName))
                {
                    accountData.AccountName = Transliteration.CyrillicToLatin($"{accountData.Firstname.ToLower()}.{accountData.Lastname.ToLower()}", Language.Russian);
                    accountData.AccountName = accountData.AccountName.Replace("`", "");
                }
                accountData = StoreAccountData(accountData);
                ISmsService smsService = _smsServices.GetSmsService(smsServiceCode);
                IBot        iBot;
                switch (serviceCode)
                {
                case ServiceCode.MailRu:
                    iBot = new MailRuRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Yandex:
                    iBot = new YandexRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Gmail:
                    iBot = new GmailRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Facebook:
                    iBot = new FacebookRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Vk:
                    iBot = new VkRegistration(accountData, smsService, _chromiumSettings);
                    break;

                case ServiceCode.Ok:
                    iBot = new OkRegistration(accountData, smsService, _chromiumSettings);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                //var countryCode = CountryCode.RU;
                if (!string.IsNullOrEmpty(accountData.PhoneCountryCode))
                {
                    countryCode = (CountryCode)Enum.Parse(typeof(CountryCode), accountData.PhoneCountryCode);
                }
                accountData = await iBot.Registration(countryCode);

                StoreAccountData(accountData);
            }
            catch (Exception exception)
            {
                log?.Error(exception);
            }
            finally
            {
                log?.Debug($@"{Enum.GetName(typeof(ServiceCode), serviceCode)}  via {Enum.GetName(typeof(SmsServiceCode), smsServiceCode)} finish... - {DateTime.Now} {Environment.NewLine}");
            }
            return(accountData);
        }
Exemple #2
0
 public void RemoveSmsServiceLowBalance(SmsServiceCode smsServiceCode)
 {
     _smsServiceInfoList.RemoveAll(z => z.SmsServiceCode == smsServiceCode);
 }
Exemple #3
0
 public ISmsService GetSmsService(SmsServiceCode smsServiceCode)
 {
     return(_smsServiceDictionary[smsServiceCode]);
 }
Exemple #4
0
 private async Task <IAccountData> Registration(IAccountData accountData, SmsServiceCode smsServiceCode, ServiceCode serviceCode, CountryCode countryCode = CountryCode.RU)
 {
     return(await Registration(accountData, smsServiceCode, serviceCode, countryCode, Log));
 }