コード例 #1
0
        /// <summary>
        /// 判断输入的字符串是否是合法的IPV6 地址
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool IsIPV6(string input)
        {
            string pattern = "";
            string temp    = input;

            string[] strs = temp.Split(':');
            if (strs.Length > 8)
            {
                return(false);
            }
            int count = MetarnetRegex.GetStringCount(input, "::");

            if (count > 1)
            {
                return(false);
            }
            else if (count == 0)
            {
                pattern = @"^([\da-f]{1,4}:){7}[\da-f]{1,4}$";

                Regex regex = new Regex(pattern);
                return(regex.IsMatch(input));
            }
            else
            {
                pattern = @"^([\da-f]{1,4}:){0,5}::([\da-f]{1,4}:){0,5}[\da-f]{1,4}$";
                Regex regex1 = new Regex(pattern);
                return(regex1.IsMatch(input));
            }
        }
コード例 #2
0
 //获取验证码按钮
 private void SecurityCodeBtu_Click(object sender, EventArgs e)
 {
     if (MetarnetRegex.IsMobilePhone(this.PhoneNumberTXT.Text.Trim()))
     {
         DataSet ds =
             Database.RunDataSet("select * from Person where PersonPN='" +
                                 this.PhoneNumberTXT.Text.Trim() + "'");
         if (ds.Tables[0].Rows.Count != 0)
         {
             MessageBox.Show("此手机号已被注册!", "温馨提示", MessageBoxButtons.OK);
             return;
         }
         else
         {
             SendMessage send = new SendMessage();
             SecurityCodes = send.SendMessages(this.PhoneNumberTXT.Text.Trim());
             if (!string.IsNullOrEmpty(SecurityCodes))
             {
                 IsHaveSend = true;
                 MessageBox.Show("验证码已发送,请注意查收!", "温馨提示", MessageBoxButtons.OK);
                 this.SecurityCodeTXT.Focus();
             }
         }
     }
     else
     {
         MessageBox.Show("手机号格式不正确,请检查!", "温馨提示", MessageBoxButtons.OK);
     }
 }
コード例 #3
0
 public static MetarnetRegex GetInstance()
 {
     if (MetarnetRegex.instance == null)
     {
         MetarnetRegex.instance = new MetarnetRegex();
     }
     return(MetarnetRegex.instance);
 }
コード例 #4
0
ファイル: SendMessage.cs プロジェクト: WeberBon/ShopManger
        private static int SecurityCode; //验证码


        //发送验证码
        private string SendSecurityCode(string SecurityCode, string phoneNumber)
        {
            string result = "";

            if (MetarnetRegex.IsMobilePhone(phoneNumber))
            {
                ITopClient client = new DefaultTopClient(url, AppKey, Security);

                AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();

                req.Extend = "123456";

                req.SmsType = "normal";

                req.SmsFreeSignName = "注册验证";
                //    req.SmsParam = String.Format("{\"code\":\"1234\",\"product\":\"打堆云打印\"}", SecurityCode);// "{\"code\":\"1234\",\"product\":\"打堆云打印\"}";
                req.SmsParam        = "{\"code\":\"" + SecurityCode + "\",\"product\":\"宋刚之云商行\"}";
                req.RecNum          = phoneNumber;
                req.SmsTemplateCode = "SMS_3125049";
                AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req);
                result = rsp.Body;
            }
            return(result);
        }