예제 #1
0
        /// <summary>
        /// 校验验证码,建议Validator构造函数中的nullOrEmptyable为false
        /// </summary>
        /// <param name="container"></param>
        /// <param name="checkCodeKind"></param>
        /// <param name="stopWhileFail"></param>
        /// <returns></returns>
        public static ValidatorContainer <T> ValidateCheckCode <T>(this ValidatorContainer <T> container, CheckCodeKind checkCodeKind, bool stopWhileFail)
        {
            if (container == null)
            {
                return(null);
            }

            if (container.ValidatorObject == null)
            {
                container.AddError("请输入验证码");
                if (stopWhileFail)
                {
                    return(null);
                }
            }

            CheckCodeHandle checkCodeHandle = new CheckCodeHandle(checkCodeKind, container.Controller.HttpContext);

            if (!checkCodeHandle.ValidateCheckCode(container.ValidatorObject.ToString()))
            {
                container.AddError("请输入正确的验证码");
                if (stopWhileFail)
                {
                    return(null);
                }
            }

            return(container);
        }
예제 #2
0
        public override void ExecuteResult(ActionContext context)
        {
            CheckCodeHandle checkcode = new CheckCodeHandle(_checkCodeKind, context.HttpContext);

            createcheckcodeimage(checkcode.GenerateCheckCode(), context);
        }