Example #1
0
        /// <summary>
        /// 记录发送记录
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="customerId"></param>
        public void SetLog(string mobile, int customerId)
        {
            string         key   = this.GetCacheKey(mobile, customerId);
            SafeSmsCodeLog model = this.GetLog(mobile, customerId);

            if (model != null)
            {
                if (model.LastTime.Date != DateTime.Now.Date)//每天清零
                {
                    model = new SafeSmsCodeLog()
                    {
                        LastTime = DateTime.Now, TodaySendTimes = 1
                    };
                }
                else
                {
                    model.TodaySendTimes += 1;
                    model.LastTime        = DateTime.Now;
                }
            }
            else
            {
                model = new SafeSmsCodeLog()
                {
                    LastTime = DateTime.Now, TodaySendTimes = 1
                };
            }
            HttpContext.Current.Session[key] = model;
        }
Example #2
0
        /// <summary>
        /// 是否属于频繁触发
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="customerId"></param>
        /// <returns></returns>
        public bool IsFrequentlySend(string mobile, int customerId)
        {
            SafeSmsCodeLog model = this.GetLog(mobile, customerId);

            if (model != null)
            {
                if (DateTime.Now.Subtract(model.LastTime).TotalSeconds < frequentlySeconds)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        /// <summary>
        /// 是否需要触发安全码(图形验证码)
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="customerId"></param>
        /// <returns></returns>
        public bool IsTriggerSafeCode(string mobile, int customerId)
        {
            SafeSmsCodeLog model = this.GetLog(mobile, customerId);

            if (model != null)
            {
                if (model.LastTime.Date == DateTime.Now.Date)//还是今天的
                {
                    if (model.TodaySendTimes >= safeCodeTriggerNum)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }