CRL.Person.UserMobileVerify.SendCode C# (CSharp) Method

SendCode() public method

发送自定义格式短信
public SendCode ( string mobile, string content, string &error ) : bool
mobile string
content string 不为空时为自定义短信,验证码域请用{0}表示
error string
return bool
        public bool SendCode(string mobile, string content, out string error)
        {
            error = "";
            if (string.IsNullOrEmpty(mobile))
            {
                error = "发送失败,没有传入手机号";
                return false;
            }
            if (!mobile.IsCellPhone())
            {
                error = "手机号格式不正确";
                return false;
            }
            string chkCode = MakeRandomCode();

            if (string.IsNullOrEmpty(content))
            {
                content = "您本次操作的验证码为 " + chkCode + ",切勿将此验证码泄露给他人,如非本人操作请忽略";
            }
            else
            {
                content = string.Format(content, chkCode);
            }
            double n = MobileVerifyData.GetSendTimeDiff(ModuleName);
            if (n < NextSendSencond)
            {
                error = "发送失败,验证码距上次发送不足" + NextSendSencond + "秒,请稍后再试";
                return false;
            }
            int totalSend = MobileVerifyData.GetTotalSendTimes(ModuleName);
            if (totalSend > 5)
            {
                error = "发送失败,请求超过了限制,请稍后再试";
                return false;
            }
            //bool a = CoreHelper.SMSMessage.Send(mobile, content, out error); //老短信接口
            CurrentCode = chkCode;
            bool a = SendSms(mobile, content, out error);
            if (a)
            {
                MobileVerifyData.SetCode(ModuleName, chkCode, mobile.Trim());
                string str = string.Format("时间:{0} 验证码:{1} 模块:{2} \r\n", DateTime.Now.ToString("yy-MM-dd HH:mm:ss fffff"), chkCode, ModuleName);
                SmsSendRecordManage.Instance.Add(new SmsSendRecord() { Mobile = mobile, Code = chkCode, ModuleName = ModuleName });
            }
            return a;
        }