GetTimes() public static méthode

获取验证码读取次数,用来作次数限制
public static GetTimes ( string moduleName ) : int
moduleName string
Résultat int
Exemple #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);
        }