/// <summary> /// Return Validate Code Iamge /// </summary> /// <returns></returns> public FileContentResult ValidateCodeImage() { string code = String_Helper_DG.GetRandomString(4); //Code Length is four(4) Cache_Helper_DG.Cache_Add("ValidateCode", code); //storage SecurityCode to cache return(File(Graphic_Helper_DG.CreateValidateGraphic(code), "image/Jpeg")); }
public ActionResult LoginDeal() { try { string account = Request["account"]; string password = Request["password"]; string validateCode = Request["validateCode"]; int online = Request["online"].ToInt(); if (!Cache_Helper_DG.Cache_Get("ValidateCode").ToString().ToUpper().Equals(validateCode.ToUpper())) { return(ERROR("验证码错误!")); } using (var fact = Wcf <UserAccountService>()) { var channel = fact.CreateChannel(); TB_UserAccount userAccount = channel.QuerySingle(new TB_UserAccountQueryObject { QueryCondition = t => t.LoginId.Equals(account) }).Cast <TB_UserAccount>(); if (userAccount != null) { if (userAccount.Password.Equals(Encrypt_Helper_DG.MD5_Encrypt(password))) { Session["uid"] = userAccount.UserUid; Session["loginId"] = userAccount.LoginId; if (online == 1) { Cookie_Helper_DG.Add("loginId", userAccount.LoginId, DateTime.Now.AddDays(1)); Cookie_Helper_DG.Add("uid", userAccount.UserUid.ToString(), DateTime.Now.AddDays(1)); } return(OK("登录成功!")); } } return(ERROR("账号或密码错误!")); } } catch (Exception ex) { return(ERROR(ex.ToString(), 0, 0, System.Net.HttpStatusCode.InternalServerError)); } }