예제 #1
0
        public IEnumerable <uint> GetListBy(SexStatus sexStatus, PhoneCode phoneCode, UintMultiUnionList union)
        {
            var codeOffset = PhoneCodeOffset(phoneCode.GetSpan().Slice(1));

            switch (sexStatus & SexStatus.AllSex)
            {
            case SexStatus.Male:
            {
                Free.MenWithPhoneCode(codeOffset, union);
                NotFree.MenWithPhoneCode(codeOffset, union);
                Complex.MenWithPhoneCode(codeOffset, union);
                return(union);
            }

            case SexStatus.Female:
            {
                Free.WomenWithPhoneCode(codeOffset, union);
                NotFree.WomenWithPhoneCode(codeOffset, union);
                Complex.WomenWithPhoneCode(codeOffset, union);
                return(union);
            }

            default:
            {
                Free.MenWithPhoneCode(codeOffset, union);
                NotFree.MenWithPhoneCode(codeOffset, union);
                Complex.MenWithPhoneCode(codeOffset, union);
                Free.WomenWithPhoneCode(codeOffset, union);
                NotFree.WomenWithPhoneCode(codeOffset, union);
                Complex.WomenWithPhoneCode(codeOffset, union);
                return(union);
            }
            }
        }
예제 #2
0
        public JsonResult SendRandomCodeToMobile(string phone, string username = "", int type = 0)
        {
            ITopClient client = new DefaultTopClient(url, appkey, secret);
            AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

            req.Extend          = "";
            req.SmsType         = "normal";
            req.SmsFreeSignName = "好油菜";
            var randomCode = GetID();

            //req.SmsParam = "{name:'stone',number:'3345'}";
            req.SmsParam        = "{name:'" + username + "',number:'" + randomCode + "'}";
            req.RecNum          = phone;
            req.SmsTemplateCode = "SMS_36290127";
            AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
            //存储结果,发送时间,随机数和手机号
            var code = new PhoneCode
            {
                Mobile        = phone,
                Code          = randomCode.ToString(),
                Successed     = !rsp.IsError,
                ErrorCode     = rsp.ErrCode,
                ErrorMsg      = rsp.ErrMsg,
                PhoneCodeType = (PhoneCodeType)type
            };

            _phoneCodeSerice.Insert(code);
            if (rsp.IsError)
            {
                Logger.Debug(rsp.ErrCode + " " + rsp.ErrMsg);
            }
            return(Json(new { success = !rsp.IsError, message = rsp.ErrMsg, code = rsp.ErrCode }, JsonRequestBehavior.AllowGet));
        }
 private void PrimaryInput_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Back && string.IsNullOrEmpty(PrimaryInput.Text))
     {
         PhoneCode.Focus(FocusState.Keyboard);
         PhoneCode.SelectionStart = PhoneCode.Text.Length;
         e.Handled = true;
     }
 }
예제 #4
0
 public override byte[] ToBytes()
 {
     return(TLUtils.Combine(
                TLUtils.SignatureToBytes(Signature),
                PhoneNumber.ToBytes(),
                PhoneCodeHash.ToBytes(),
                PhoneCode.ToBytes(),
                FirstName.ToBytes(),
                LastName.ToBytes()));
 }
예제 #5
0
        public bool AddPhoneCode(string value)
        {
            if (string.IsNullOrWhiteSpace(value) || value.Length != 3 || !char.IsDigit(value[0]) || !char.IsDigit(value[1]) || !char.IsDigit(value[2]))
            {
                return(false);
            }

            Fields.Add(Serializer.Fields.Phone);

            phoneCode = PhoneCode.From(value);
            AddFilter(FilterTypes.phone_code);
            return(true);
        }
예제 #6
0
        /// <summary>
        /// 创建手机验证码记录
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="code"></param>
        /// <param name="customerID"></param>
        public void CreatePhoneCode(string mobile, string code, string customerID)
        {
            var pc = new PhoneCode
            {
                Code       = code,
                CustomerID = customerID,
                SendTime   = DateTime.Now,
                Mobile     = mobile,
            };

            DAL.AddOrModify <PhoneCode>(pc, customerID);
            DAL.Commit();
        }
예제 #7
0
 private void PhoneNumber_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         ViewModel.SendCommand.Execute(null);
         e.Handled = true;
     }
     else if (e.Key == Windows.System.VirtualKey.Back && string.IsNullOrEmpty(PrimaryInput.Text))
     {
         PhoneCode.Focus(FocusState.Keyboard);
         PhoneCode.SelectionStart = PhoneCode.Text.Length;
         e.Handled = true;
     }
 }
예제 #8
0
        private async void SendExecute()
        {
            if (string.IsNullOrEmpty(_phoneCode))
            {
                RaisePropertyChanged("PHONE_CODE_INVALID");
                return;
            }

            if (string.IsNullOrEmpty(_phoneNumber))
            {
                RaisePropertyChanged("PHONE_NUMBER_INVALID");
                return;
            }

            IsLoading = true;

            var response = await ProtoService.SendChangePhoneCodeAsync(_phoneCode + _phoneNumber, /* TODO: Verify */ null);

            if (response.IsSucceeded)
            {
                var state = new SettingsPhoneSentCodePage.NavigationParameters
                {
                    PhoneNumber = PhoneCode.TrimStart('+') + PhoneNumber,
                    Result      = response.Result,
                };

                NavigationService.Navigate(typeof(SettingsPhoneSentCodePage), state);
            }
            else if (response.Error != null)
            {
                IsLoading = false;

                if (response.Error.TypeEquals(TLErrorType.PHONE_NUMBER_FLOOD))
                {
                    await TLMessageDialog.ShowAsync("Sorry, you have deleted and re-created your account too many times recently. Please wait for a few days before signing up again.", "Telegram", "OK");
                }
                else
                {
                    await new TLMessageDialog(response.Error.ErrorMessage ?? "Error message", response.Error.ErrorCode.ToString()).ShowQueuedAsync();
                }
            }
        }
예제 #9
0
        public IList <PhoneCode> GetPhoneCodes()
        {
            using (var stream = _assembly.GetManifestResourceStream(_prefix + "PhoneCodes.txt"))
                using (var reader = new StreamReader(stream))
                {
                    var codes = new List <PhoneCode>();
                    while (!reader.EndOfStream)
                    {
                        var line = reader.ReadLine();
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            var code  = new PhoneCode();
                            var parts = line.Split(';');

                            if (parts.Length > 0)
                            {
                                code.Code = parts[0];
                            }

                            if (parts.Length > 1)
                            {
                                code.CountryCode = parts[1];
                            }

                            if (parts.Length > 2)
                            {
                                code.CountryName = parts[2];
                            }

                            if (parts.Length > 3)
                            {
                                code.Mask = parts[3];
                            }

                            codes.Add(code);
                        }
                    }

                    return(codes);
                }
        }
예제 #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Email.Length != 0)
            {
                hash ^= Email.GetHashCode();
            }
            if (EmailCode.Length != 0)
            {
                hash ^= EmailCode.GetHashCode();
            }
            if (PhoneCode.Length != 0)
            {
                hash ^= PhoneCode.GetHashCode();
            }
            if (GoogleCode.Length != 0)
            {
                hash ^= GoogleCode.GetHashCode();
            }
            return(hash);
        }
예제 #11
0
 public void Insert(PhoneCode model)
 {
     _pRepository.Insert(model);
 }
예제 #12
0
 public static PhoneCodeView EntityMap(this PhoneCode model)
 {
     return(Mapper.Map <PhoneCode, PhoneCodeView>(model));
 }
예제 #13
0
        private async void SendExecute()
        {
            if (string.IsNullOrEmpty(_phoneCode))
            {
                RaisePropertyChanged("PHONE_CODE_INVALID");
                return;
            }

            if (string.IsNullOrEmpty(_phoneNumber))
            {
                RaisePropertyChanged("PHONE_NUMBER_INVALID");
                return;
            }

            IsLoading = true;

            var response = await ProtoService.SendCodeAsync(_phoneCode + _phoneNumber, /* TODO: Verify */ null);

            if (response.IsSucceeded)
            {
                var state = new SignInSentCodePage.NavigationParameters
                {
                    PhoneNumber = PhoneCode.TrimStart('+') + PhoneNumber,
                    Result      = response.Result,
                };

                NavigationService.Navigate(typeof(SignInSentCodePage), state);
            }
            else if (response.Error != null)
            {
                IsLoading = false;

                if (response.Error.TypeEquals(TLErrorType.PHONE_NUMBER_INVALID))
                {
                    //needShowInvalidAlert(req.phone_number, false);
                }
                else if (response.Error.TypeEquals(TLErrorType.PHONE_NUMBER_FLOOD))
                {
                    await TLMessageDialog.ShowAsync(Strings.Android.PhoneNumberFlood, Strings.Android.AppName, Strings.Android.OK);
                }
                //else if (response.Error.TypeEquals(TLErrorType.PHONE_NUMBER_BANNED))
                //{
                //    needShowInvalidAlert(req.phone_number, true);
                //}
                else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_EMPTY) || response.Error.TypeEquals(TLErrorType.PHONE_CODE_INVALID))
                {
                    await TLMessageDialog.ShowAsync(Strings.Android.InvalidCode, Strings.Android.AppName, Strings.Android.OK);
                }
                else if (response.Error.TypeEquals(TLErrorType.PHONE_CODE_EXPIRED))
                {
                    await TLMessageDialog.ShowAsync(Strings.Android.CodeExpired, Strings.Android.AppName, Strings.Android.OK);
                }
                else if (response.Error.ErrorMessage.StartsWith("FLOOD_WAIT"))
                {
                    await TLMessageDialog.ShowAsync(Strings.Android.FloodWait, Strings.Android.AppName, Strings.Android.OK);
                }
                else if (response.Error.ErrorCode != -1000)
                {
                    await TLMessageDialog.ShowAsync(response.Error.ErrorMessage, Strings.Android.AppName, Strings.Android.OK);
                }
            }
        }