/// <summary> /// 执行 /// </summary> public override void Execute() { CommentsHelper CommentsHelper = HelperFactory.GetHelper <CommentsHelper>(); if (!string.IsNullOrEmpty(ArticleIDByRedirect)) { Records = CommentsHelper.ArticleIDQueryComments(ArticleIDByRedirect, this.StartIndexs, PageSize, null, true); } else { Records = CommentsHelper.ArticleIDQueryComments(ArticleID, this.StartIndexs, PageSize, null, true); } }
/// <summary> /// 加载评论列表 /// </summary> void LoadComments() { List <Comments> list = new List <Comments>(); if (ArticleID == null) { CommentPager.RecorderCount = CommentsHelper.QueryAllCommentsCount(); list = CommentsHelper.QueryAllComments(CommentPager.Begin, CommentPager.Count, null); SummaryLabel.Text = "管理全部评论"; } else { CommentPager.RecorderCount = CommentsHelper.ArticleIDQueryCommentsCount(ArticleID); list = CommentsHelper.ArticleIDQueryComments(ArticleID, CommentPager.Begin, CommentPager.Count, null); try { SummaryLabel.Text = String.Format("管理文章:“{0}”的评论", ArticleHelper.GetArticle(ArticleID, new string[] { "Title" }).Title); } catch { string chID = ChannelHelper.GetChannelIDByOnlyName(ArticleID); Channel ch = ChannelHelper.GetChannel(chID, new string[] { "FullPath" }); if (ch != null) { SummaryLabel.Text = String.Format("管理栏目:“{0}”的评论", ch.FullPath); } } } foreach (Comments c in list) { if (c.Content.Length > TitleMaxLength) { c.Content = String.Format("{0}...", c.Content.Substring(0, TitleMaxLength)); } string[] fields = new string[] { "Title", "ModelName" }; string acticleTitle = ""; if (!We7Helper.IsEmptyID(c.ArticleID)) { //文章下的评论 try { Article ac = ArticleHelper.GetArticle(c.ArticleID, fields); if (ac != null) { acticleTitle = String.Format("{1}:{0}", ac.Title, "System.Article" == ac.ModelName ? "文章" : Model.Core.ModelHelper.GetModelInfoByName(ac.ModelName).Label); } } //栏目下的评论 catch { string chID = ChannelHelper.GetChannelIDByOnlyName(c.ArticleID); Channel ch = ChannelHelper.GetChannel(chID, new string[] { "FullPath" }); if (ch != null) { acticleTitle = String.Format("栏目:{0}", ch.FullPath); } } } if (acticleTitle.Length > TitleMaxLength) { c.ArticleTitle = String.Format("{0}...", acticleTitle.Substring(0, TitleMaxLength)); } else { c.ArticleTitle = acticleTitle; } } DataGridView.DataSource = list; DataGridView.DataBind(); }