public void btnRefer_Click(object sender, System.EventArgs e) { if (!HiContext.Current.CheckVerifyCode(this.txtLeaveCode.Value)) { this.ShowMessage("验证码不正确", false); return; } if (!this.ValidateConvert()) { return; } if (HiContext.Current.User.UserRole != UserRole.Member && !this.userRegion(this.txtLeaveUserName.Value, this.txtLeavePsw.Value)) { return; } LeaveCommentInfo leaveCommentInfo = new LeaveCommentInfo(); leaveCommentInfo.UserName = Globals.HtmlEncode(this.txtUserName.Text); leaveCommentInfo.UserId = new int?(HiContext.Current.User.UserId); leaveCommentInfo.Title = Globals.HtmlEncode(this.txtTitle.Text); leaveCommentInfo.PublishContent = Globals.HtmlEncode(this.txtContent.Text); ValidationResults validationResults = Validation.Validate <LeaveCommentInfo>(leaveCommentInfo, new string[] { "Refer" }); string text = string.Empty; if (!validationResults.IsValid) { foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults) { text += Formatter.FormatErrorMessage(current.Message); } this.ShowMessage(text, false); return; } if (CommentBrowser.InsertLeaveComment(leaveCommentInfo)) { this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "success", string.Format("<script>alert(\"{0}\");window.location.href=\"{1}\"</script>", "留言成功,管理员回复后即可显示", Globals.GetSiteUrls().UrlData.FormatUrl("LeaveComments"))); } else { this.ShowMessage("留言失败", false); } this.txtTitle.Text = string.Empty; this.txtContent.Text = string.Empty; }
public IHttpActionResult Feedback(JObject request) { Logger.WriterLogger("Common.Feedback, Params: " + request.ToString(), LoggerType.Info); ParamFeedback param = new ParamFeedback(); try { param = request.ToObject <ParamFeedback>(); } catch { // 参数无效 return(base.JsonFaultResult(new CommonException(40100).GetMessage(), request.ToString())); } string accessToken = param.accessToken; // 验证令牌 int accessTookenCode = VerifyAccessToken(accessToken); if (accessTookenCode > 0) { return(base.JsonFaultResult(new CommonException(accessTookenCode).GetMessage(), request.ToString())); } // 验证参数 //ThrowParamException(skuId); int channel = param.channel; int platform = param.platform; string ver = param.ver; string userId = param.UserId; string content = param.Content; int feedbackType = param.FeedbackType; string contactWay = param.ContactWay; int? innerUserId = new Nullable <int>(); string username = ""; Member member = GetMember(userId.ToSeesionId()); if (member != null) { innerUserId = member.UserId; username = member.Username; } LeaveCommentInfo leaveCommentInfo = new LeaveCommentInfo(); leaveCommentInfo.UserName = Globals.HtmlEncode(username); leaveCommentInfo.UserId = innerUserId; leaveCommentInfo.Title = ""; leaveCommentInfo.PublishContent = Globals.HtmlEncode(content); leaveCommentInfo.ContactWay = Globals.HtmlEncode(contactWay); leaveCommentInfo.FeedbackType = feedbackType; if (param.Images.Count > 0) { foreach (SubmitImage item in param.Images) { leaveCommentInfo.Images.Add(item.Image); } } if (CommentBrowser.InsertLeaveComment(leaveCommentInfo)) { StandardResult <string> result = new StandardResult <string>(); result.code = 0; result.msg = "保存成功"; result.data = null; return(base.JsonActionResult(result)); } return(base.JsonFaultResult(new CommonException(40999).GetMessage(), request.ToString())); }