📄 addcomment.cs
字号:
namespace PowerEasy.WebSite.CommentUI
{
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Contents;
using PowerEasy.Controls;
using PowerEasy.Model.Contents;
using PowerEasy.Model.UserManage;
using PowerEasy.Web.UI;
using System;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class AddComment : DynamicPage
{
protected Button BtnSubmit;
protected CheckBox ChkIsPrivate;
protected HtmlForm form1;
protected HiddenField HdnGeneralId;
protected HiddenField HdnNodeId;
protected Label LblCommentTitle;
protected RadioButtonList RadlPosition;
protected RadioButtonList RadlScore;
protected TextBox TxtCommentRestore;
protected TextBox TxtCommentTitle;
protected PowerEasy.Controls.RequiredFieldValidator ValrCommentRestore;
protected PowerEasy.Controls.RequiredFieldValidator ValrCommentTitle;
protected void BtnSubmit_Click(object sender, EventArgs e)
{
int num = BasePage.RequestInt32("NodeId");
if (num < 1)
{
DynamicPage.WriteErrMsg("<li>请选择隶属栏目!</li>");
}
CommentInfo commentInfo = new CommentInfo();
if (!HttpContext.Current.User.Identity.IsAuthenticated)
{
commentInfo.UserName = "游客";
}
else
{
commentInfo.UserName = PEContext.Current.User.UserName;
}
commentInfo.GeneralId = BasePage.RequestInt32("GeneralId");
commentInfo.TopicId = 1;
commentInfo.NodeId = num;
commentInfo.CommentTitle = StringHelper.RemoveXss(this.TxtCommentTitle.Text);
commentInfo.Content = StringHelper.RemoveXss(this.TxtCommentRestore.Text);
commentInfo.UpdateDateTime = DateTime.Now;
commentInfo.Score = DataConverter.CLng(this.RadlScore.SelectedValue);
commentInfo.Position = DataConverter.CLng(this.RadlPosition.SelectedValue);
commentInfo.IP = PEContext.Current.UserHostAddress;
commentInfo.IsPrivate = this.ChkIsPrivate.Checked;
int num2 = string.Compare(commentInfo.UserName, "游客", true);
NodeInfo cacheNodeById = Nodes.GetCacheNodeById(ContentManage.GetCommonModelInfoById(commentInfo.GeneralId).NodeId);
commentInfo.Status = cacheNodeById.Settings.CommentNeedCheck;
UserPurviewInfo userPurview = null;
if (num2 != 0)
{
userPurview = PEContext.Current.User.UserInfo.UserPurview;
if (userPurview.CommentNeedCheck)
{
commentInfo.Status = true;
}
else
{
commentInfo.Status = !cacheNodeById.Settings.CommentNeedCheck;
}
}
else if (!cacheNodeById.Settings.EnableTouristsComment)
{
DynamicPage.WriteErrMsg("<li>此栏目已禁止游客发表评论!</li>");
}
else
{
commentInfo.Status = !cacheNodeById.Settings.CommentNeedCheck;
}
bool enableComment = false;
bool commentNeedCheck = false;
if (userPurview != null)
{
enableComment = userPurview.EnableComment;
commentNeedCheck = userPurview.CommentNeedCheck;
}
if (cacheNodeById.Settings.EnableComment || enableComment)
{
if (Comment.Add(commentInfo))
{
string returnurl = "../Item/" + BasePage.RequestInt32("GeneralId").ToString() + ".aspx";
if (commentInfo.Status || commentNeedCheck)
{
DynamicPage.WriteSuccessMsg("<li>添加评论成功!</li>", returnurl);
}
else
{
DynamicPage.WriteSuccessMsg("<li>发表评论成功,请等待管理员审核。</li>", returnurl);
}
}
else
{
DynamicPage.WriteErrMsg("<li>添加评论失败,请返回!</li>");
}
}
else
{
DynamicPage.WriteErrMsg("<li>此栏目已禁止发表评论!</li>");
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
int nodeId = BasePage.RequestInt32("NodeId");
if (nodeId < 1)
{
DynamicPage.WriteErrMsg("<li>请选择隶属栏目!</li>");
}
if (!Nodes.GetCacheNodeById(nodeId).Settings.EnableComment)
{
DynamicPage.WriteErrMsg("<li>该栏目没有发表评论的权限!</li>");
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -