Example #1
0
        public static int CheckErrorCount(IVerifier verifier, string errorCountKey)
        {
            int.TryParse(RedisHelper.StringGet(RedisDBIndex, errorCountKey), out int errorCount);

            if (errorCount >= Constant.VIRIFY_FAILD_TIMES_LIMIT)
            {
                var minCount = GetErrorLockTime(errorCountKey);
                verifier.FailedMoreTimes(minCount);
            }
            return(errorCount);
        }
Example #2
0
        public static void IncreaseErrorCount(IVerifier verifier, string errorCountKey, Exception ex = null)
        {
            var errorCountsStr = RedisHelper.StringGet(RedisDBIndex, errorCountKey);

            int.TryParse(errorCountsStr, out int errorCount);
            ++errorCount;
            int spInt = verifier.GetLockTime();

            RedisHelper.StringSet(RedisDBIndex, errorCountKey, errorCount.ToString(), TimeSpan.FromMinutes(spInt));
            if (errorCount >= Constant.VIRIFY_FAILD_TIMES_LIMIT)
            {
                var minCount = GetErrorLockTime(errorCountKey);
                verifier.FailedMoreTimes(minCount);
            }
            else
            {
                if (ex != null)
                {
                    throw ex;
                }
                verifier.VerifyFaild(Constant.VIRIFY_FAILD_TIMES_LIMIT - errorCount);
            }
        }