public ActionResult SubmitMessageBoardInfo(FormCollection form) { if (!ModelState.IsValid) { return(Json(new { Success = true, ErrorMessage = "提交内容有误,留言失败,请稍后重试!" }, JsonRequestBehavior.DenyGet)); } try { var host = HttpContext.Request.Url.Host.ToString() ?? string.Empty; var requestUrl = HttpContext.Request.Url.ToString() ?? string.Empty; var urlReferrer = HttpContext.Request.UrlReferrer.ToString(); var userName = HttpUtility.UrlDecode(form["nickname"].ToString() ?? string.Empty); var phone = HttpUtility.UrlDecode(form["cellphone"].ToString() ?? string.Empty); var sourceurl = HttpUtility.UrlDecode(form["sourceurl"].ToString() ?? string.Empty);// var isVerCode = HttpUtility.UrlDecode(form["isVerCode"].ToString() ?? string.Empty); var messageContent = HttpUtility.UrlDecode(form["messageInfo"].ToString() ?? string.Empty); if (isVerCode == "1") { var verCode = HttpUtility.UrlDecode(form["vercode"].ToString() ?? string.Empty); var IsCheckedPass = null != Session["VerCode"] && Session["VerCode"].ToString() == verCode; if (!IsCheckedPass) { return(Json(new { Success = false, ErrorMessage = "验证码有误,请重新填写!" }, JsonRequestBehavior.DenyGet)); } } if (string.IsNullOrEmpty(userName)) { return(Json(new { Success = false, ErrorMessage = "姓名不能为空!" }, JsonRequestBehavior.DenyGet)); } if (string.IsNullOrEmpty(phone) || !IsCheckPhone(phone)) { return(Json(new { Success = false, ErrorMessage = "手机号码有误,请重新填写!" }, JsonRequestBehavior.DenyGet)); } var entity = new MessageBoard { UserName = HttpUtility.UrlDecode(userName.Trim()), Phone = HttpUtility.UrlDecode(phone.Trim()), MessageContent = HttpUtility.UrlDecode(messageContent.Trim()), ClientIp = IPAddressHelper.GetClientIp(), LocalIp = IPAddressHelper.GetLocalIp(), RequestUrl = string.IsNullOrEmpty(sourceurl)? requestUrl: sourceurl, UrlReferrer = urlReferrer, Host = host, CreateTime = DateTime.Now }; var messageBoard = new MessageBoardBLL(); messageBoard.Add(entity); return(Json(new { Success = true, }, JsonRequestBehavior.DenyGet)); } catch (Exception ex) { Log.Error("留言板留言出现未处理异常", ex.ToString()); return(Json(new { Success = false, ErrorMessage = "留言失败,请稍后重试!" }, JsonRequestBehavior.DenyGet)); } }
public ActionResult AddMessageBoard(FormCollection form) { if (!ModelState.IsValid) { return(Json(new { Success = true, ErrorMessage = "留言失败,请稍后重试!" }, JsonRequestBehavior.DenyGet)); } try { var host = HttpUtility.UrlDecode(HttpContext.Request.Url.Host.ToString() ?? string.Empty); var requestUrl = HttpUtility.UrlDecode(HttpContext.Request.Url.ToString() ?? string.Empty); var urlReferrer = HttpUtility.UrlDecode(HttpContext.Request.UrlReferrer.ToString()); var userName = HttpUtility.UrlDecode(form["UserName"].ToString() ?? string.Empty); var phone = HttpUtility.UrlDecode(form["Phone"].ToString() ?? string.Empty); var messageContent = HttpUtility.UrlDecode(form["Comment"].ToString() ?? string.Empty); var IsPhone = System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+\d{10}"); if (string.IsNullOrEmpty(userName)) { return(Json(new { Success = false, ErrorMessage = "姓名不能为空!" }, JsonRequestBehavior.DenyGet)); } if (string.IsNullOrEmpty(phone) || !IsPhone) { return(Json(new { Success = false, ErrorMessage = "手机号码有误,请重新填写!" }, JsonRequestBehavior.DenyGet)); } var entity = new MessageBoard { UserName = HttpUtility.UrlDecode(userName.Trim()), Phone = HttpUtility.UrlDecode(phone.Trim()), MessageContent = HttpUtility.UrlDecode(messageContent.Trim()), ClientIp = IPAddressHelper.GetClientIp(), LocalIp = IPAddressHelper.GetLocalIp(), RequestUrl = requestUrl, UrlReferrer = urlReferrer, Host = host, CreateTime = DateTime.Now }; var messageBoard = new MessageBoardBll(); messageBoard.Add(entity); return(Json(new { Success = true, }, JsonRequestBehavior.DenyGet)); } catch { return(Json(new { Success = false, ErrorMessage = "留言失败,请稍后重试!" }, JsonRequestBehavior.DenyGet)); } }
public static LoginResultEnum GALogin(string userName, string password, bool rememberme, out string msg) { UserInfoBLL bll = new UserInfoBLL(); msg = "登录成功!"; //登录结果 LoginResultEnum loginResult = LoginResultEnum.LoginSuccess; try { UserInfo user = bll.Get(userName); if (user == null) { msg = "用户不存在!"; loginResult = LoginResultEnum.NoUser; return(loginResult); } if (password != user.Password) { msg = "密码错误!"; loginResult = LoginResultEnum.PasswordError; return(loginResult); } if (user.Status != 0) { msg = "用户被冻结或注销"; loginResult = LoginResultEnum.LockUser; return(loginResult); } var userInfoCookie = new UserInfoCookie { ID = user.ID, UserName = user.UserName, CreateTime = user.CreateTime, Status = user.Status, IsGeneralAviation = user.IsGeneralAviation, CompanyCode3 = user.CompanyCode3, RoleName = bll.GetRoleNameList(user.ID) }; if (!string.IsNullOrEmpty(user.CompanyCode3)) { var com = bll.GetCompany(user.CompanyCode3); if (com != null) { userInfoCookie.CompanyName = com.CompanyName; } } if (!UserLoginService.Instance.InsertOrUpdateLoginInfo(userInfoCookie, rememberme)) { throw new Exception(); } return(loginResult); } catch (Exception ex) { msg = "系统错误,无法登录"; loginResult = LoginResultEnum.OtherError; return(loginResult); } finally { LoginLogBLL loginbll = new LoginLogBLL(); //记用户登录日志 LoginLog entity = new LoginLog() { Msg = msg, UserName = userName, LoginTime = DateTime.Now, IPAddress = IPAddressHelper.GetClientIp() }; loginbll.Add(entity); } }