CRL.Person.MobileVerifyData.GetTimes C# (CSharp) Метод

GetTimes() публичный статический Метод

获取验证码读取次数,用来作次数限制
public static GetTimes ( string moduleName ) : int
moduleName string
Результат int
        public static int GetTimes(string moduleName)
        {
            CoreHelper.ServerDataCache c = new CoreHelper.ServerDataCache(moduleName);
            if (c["T"] == null)
            {
                return 0;
            }
            return Convert.ToInt32(c["T"]);
        }

Usage Example

Пример #1
0
        /// <summary>
        /// 检验验证码,成功会清除缓存数据
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="code"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public bool CheckCode(string mobile, string code, out string error)
        {
            error = "";
            if (MobileVerifyData.GetTimes(ModuleName) > 10)
            {
                error = "调用次数超过了限制";
                return(false);
            }
            string code1   = MobileVerifyData.GetCode(ModuleName);
            string mobile1 = MobileVerifyData.GetReceiveMobile(ModuleName);

            if (string.IsNullOrEmpty(code1) || string.IsNullOrEmpty(mobile1))
            {
                error = "请重新发送";
                return(false);
            }
            code  = code.ToLower();
            code1 = code1.ToLower();
            bool a = code == code1 && mobile.Trim() == mobile1.Trim();

            if (a)
            {
                MobileVerifyData.Clear(ModuleName);
            }
            else
            {
                error = "验证码不正确";
            }
            return(a);
        }