Beispiel #1
0
 public void btnRefer_Click(object sender, System.EventArgs e)
 {
     if (!Hidistro.Membership.Context.HiContext.Current.CheckVerifyCode(this.txtLeaveCode.Value))
     {
         this.ShowMessage("验证码不正确", false);
     }
     else
     {
         if (this.ValidateConvert() && (Hidistro.Membership.Context.HiContext.Current.User.UserRole == Hidistro.Membership.Core.Enums.UserRole.Member || Hidistro.Membership.Context.HiContext.Current.User.UserRole == Hidistro.Membership.Core.Enums.UserRole.Underling || this.userRegion(this.txtLeaveUserName.Value, this.txtLeavePsw.Value)))
         {
             LeaveCommentInfo leaveCommentInfo = new LeaveCommentInfo();
             leaveCommentInfo.UserName       = Globals.HtmlEncode(this.txtUserName.Text);
             leaveCommentInfo.UserId         = new int?(Hidistro.Membership.Context.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);
             }
             else
             {
                 if (CommentProcessor.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;
             }
         }
     }
 }
Beispiel #2
0
 public void btnRefer_Click(object sender, EventArgs e)
 {
     if (!HiContext.Current.CheckVerifyCode(this.txtLeaveCode.Value))
     {
         this.ShowMessage("验证码不正确", false);
     }
     else if (this.ValidateConvert() && (((HiContext.Current.User.UserRole == UserRole.Member) || (HiContext.Current.User.UserRole == UserRole.Underling)) || this.userRegion(this.txtLeaveUserName.Value, this.txtLeavePsw.Value)))
     {
         LeaveCommentInfo target = new LeaveCommentInfo();
         target.UserName       = Globals.HtmlEncode(this.txtUserName.Text);
         target.UserId         = new int?(HiContext.Current.User.UserId);
         target.Title          = Globals.HtmlEncode(this.txtTitle.Text);
         target.PublishContent = Globals.HtmlEncode(this.txtContent.Text);
         ValidationResults results = Hishop.Components.Validation.Validation.Validate <LeaveCommentInfo>(target, new string[] { "Refer" });
         string            msg     = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             this.ShowMessage(msg, false);
         }
         else
         {
             if (CommentProcessor.InsertLeaveComment(target))
             {
                 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;
         }
     }
 }