/// <summary>
                /// 数字验证码
                /// </summary>
                /// <returns></returns>
                public FileContentResult NumberCheckCode()
        {
            string code = CheckCodeHelper.GetSingleObj().CreateCheckCode(CheckCodeType.NumberCheckCode, GetCheckCodeLen());

            byte[] codeImage = CheckCodeHelper.GetSingleObj().CreateByteByImgCheckCode(code, 100, 40);
            return(File(codeImage, @"image/jpeg"));
        }
Exemple #2
0
        public ManagerResult <Verification> GenerateVerification(string phoneNumber)
        {
            ManagerResult <Verification> result = new ManagerResult <Verification>();

            try
            {
                Verification newVerification = VerificationDAL.Instance.AddOrUpdateVerification(new Verification()
                {
                    PhoneNumber = phoneNumber,
                    Code        = CheckCodeHelper.GenerateCheckCode(5)
                });

                if (newVerification == null)
                {
                    result.Code        = 1;
                    result.Description = "生成失败!";
                    result.ResultData  = null;
                }
                else
                {
                    result.Code        = 0;
                    result.Description = "生成成功!";
                    result.ResultData  = newVerification;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogType.Error, ex);
                result.Code = -1;
            }

            return(result);
        }
        public ActionResult CheckCode()
        {
            string checkCode = CheckCodeHelper.GetEngAndNum(4);

            Session["CheckCode"] = checkCode;
            CookieHelper.Add("QTXgt7AC5q5aLlVLwpTw", checkCode, 10);
            return(File(CheckCodeHelper.CreateToByte(checkCode, false), @"image/jpeg"));
        }
        /// <summary>
                /// 混合验证码
                /// </summary>
                /// <returns></returns>
        public FileContentResult MixCheckCode()
        {
            string       code   = CheckCodeHelper.GetSingleObj().CreateCheckCode(CheckCodeType.MixCheckCode, GetCheckCodeLen());
            var          bitmap = CheckCodeHelper.GetSingleObj().CreateBitmapByImgCheckCode(code, 100, 40);
            MemoryStream stream = new MemoryStream();

            bitmap.Save(stream, ImageFormat.Gif);
            return(File(stream.ToArray(), "image/gif"));
        }
Exemple #5
0
        /// <summary>
        /// 生成验证码
        /// </summary>
        public string CreateCheckCodeImage2()
        {
            var        checkCode = CheckCodeHelper.GenerateCheckCode();
            HttpCookie hc1       = new HttpCookie(SessionKey.ManagerUserLoginCode, checkCode);

            hc1.Expires = DateTime.Now.AddMinutes(10);
            HttpContext.Current.Response.Cookies.Add(hc1);
            var bytes = CheckCodeHelper.CreateCheckCodeImage(checkCode);

            return(Convert.ToBase64String(bytes));
        }
Exemple #6
0
        /// <summary>
        /// 生成验证码
        /// </summary>
        public void CreateCheckCodeImage()
        {
            var        checkCode = CheckCodeHelper.GenerateCheckCode();
            HttpCookie hc1       = new HttpCookie(SessionKey.ManagerUserLoginCode, checkCode);

            hc1.Expires = DateTime.Now.AddMinutes(10);
            HttpContext.Current.Response.Cookies.Add(hc1);
            var bytes = CheckCodeHelper.CreateCheckCodeImage(checkCode);

            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ContentType = "image/jpg";
            HttpContext.Current.Response.BinaryWrite(bytes);
        }
Exemple #7
0
 public dynamic GetCheckCode()
 {
     try
     {
         var result = CheckCodeHelper.GetCheckCode();
         var image  = result.image;
         image.Seek(0, SeekOrigin.Begin);
         var bytes = new byte[image.Length];
         image.Read(bytes, 0, bytes.Length);
         HttpContext.Session.Set("checkcode", Encoding.ASCII.GetBytes(result.text.ToLower()));
         return(new { result = 1, image = bytes });
     }
     catch
     {
         return(new { result = -1, message = "内部错误" });
     }
 }
Exemple #8
0
        public string Reset(string id)
        {
            if (string.IsNullOrEmpty(id) || TypeHelper.TypeToInt32(id, -1) < 0)
            {
                return(GeneralHandler.FBaseInfo);
            }
            var stateInfo = GeneralHandler.StateSuccess;

            if (int.Parse(id) == DawnauthHandler.UserId)
            {
                stateInfo = "不可对当前登录管理员进行密码重置操作!";
            }
            else
            {
                stateInfo  = "Dawn";
                stateInfo += CheckCodeHelper.GetEngAndNum(8);
                DawnAuthUserBLL.Update(int.Parse(id), CryptoHelper.MD5(stateInfo, true));
            }
            return(stateInfo);
        }
 /// <summary>
 /// 初始化
 /// </summary>
 private void InitializeThis()
 {
     this._checkCode     = CheckCodeHelper.GetChs(4);
     this.Text           = Core.ConfigHelper.AppName;
     this.picCoder.Image = CheckCodeHelper.CreateToImage(this._checkCode, true, false);
 }