📄 comment.cs
字号:
namespace PowerEasy.Contents
{
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.IDal.Contents;
using PowerEasy.Model.Contents;
using System;
using System.Collections.Generic;
public sealed class Comment
{
private static readonly IComment dal = DataAccess.CreateComment();
private Comment()
{
}
public static bool Add(CommentInfo commentInfo)
{
commentInfo.CommentId = MaxCommentId() + 1;
EncodeCommentInfo(commentInfo);
if (dal.Add(commentInfo))
{
ContentManage.UpdateCommentAuditedAndUnaudited(commentInfo.GeneralId);
return true;
}
return false;
}
public static bool AdministratorReply(CommentInfo commentInfo)
{
EncodeCommentInfo(commentInfo);
return dal.AdministratorReply(commentInfo);
}
private static void DecodeCommentInfo(CommentInfo commentInfo)
{
if (commentInfo != null)
{
commentInfo.Content = DataSecurity.HtmlDecode(commentInfo.Content);
commentInfo.Reply = DataSecurity.HtmlDecode(commentInfo.Reply);
}
}
public static bool Delete(int commentId)
{
CommentInfo commentInfo = dal.GetCommentInfo(commentId);
if (dal.Delete(commentId))
{
ContentManage.UpdateCommentAuditedAndUnaudited(commentInfo.GeneralId);
CommentPKZone.DeleteByCommentId(commentId);
return true;
}
return false;
}
public static bool Delete(string commentIds)
{
if (!DataValidator.IsValidId(commentIds))
{
return false;
}
string[] strArray = commentIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < strArray.Length; i++)
{
Delete(DataConverter.CLng(strArray[i]));
}
return true;
}
public static bool DeleteByGeneralId(int generalId)
{
bool flag = true;
foreach (CommentInfo info in GetList(0, 0, generalId))
{
if (!Delete(info.CommentId))
{
flag = false;
}
}
return flag;
}
public static bool DeleteByGeneralIdAndUserName(int generalId)
{
bool flag = true;
string userName = PEContext.Current.User.UserName;
foreach (CommentInfo info in GetList(0, 0, generalId))
{
if (!dal.Delete(info.CommentId, userName))
{
flag = false;
}
}
return flag;
}
public static bool DeleteByUserName(int commentId)
{
string userName = PEContext.Current.User.UserName;
CommentInfo commentInfo = dal.GetCommentInfo(commentId);
if (dal.Delete(commentId, userName))
{
ContentManage.UpdateCommentAuditedAndUnaudited(commentInfo.GeneralId);
CommentPKZone.DeleteByCommentId(commentId);
return true;
}
return false;
}
public static bool Elite(int commentId, bool isElite)
{
return dal.Elite(commentId, isElite);
}
private static void EncodeCommentInfo(CommentInfo commentInfo)
{
if (commentInfo != null)
{
commentInfo.Content = DataSecurity.HtmlEncode(commentInfo.Content);
commentInfo.Reply = DataSecurity.HtmlEncode(commentInfo.Reply);
}
}
public static CommentInfo GetCommentInfo(int commentId)
{
CommentInfo commentInfo = dal.GetCommentInfo(commentId);
DecodeCommentInfo(commentInfo);
return commentInfo;
}
public static CommentInfo GetExtendCommentInfo(int commentId)
{
CommentInfo extendCommentInfo = dal.GetExtendCommentInfo(commentId);
DecodeCommentInfo(extendCommentInfo);
return extendCommentInfo;
}
public static IList<CommentInfo> GetList(int startRowIndexId, int maxNumberRows)
{
return dal.GetList(startRowIndexId, maxNumberRows);
}
public static IList<CommentInfo> GetList(int startRowIndexId, int maxNumberRows, int generalId)
{
return dal.GetList(startRowIndexId, maxNumberRows, generalId);
}
public static IList<CommentInfo> GetList(int startRowIndexId, int maxNumberRows, int generalId, int type)
{
return dal.GetList(startRowIndexId, maxNumberRows, generalId, type);
}
public static IList<CommentInfo> GetListByNodeId(int startRowIndexId, int maxNumberRows, int nodeId, int type)
{
return dal.GetListByNodeId(startRowIndexId, maxNumberRows, nodeId, type);
}
public static int GetTotalOfCommentInfo()
{
return dal.GetTotalOfCommentInfo();
}
public static int GetTotalOfCommentInfo(int generalId)
{
return dal.GetTotalOfCommentInfo();
}
public static int GetTotalOfCommentInfo(int generalId, int type)
{
return dal.GetTotalOfCommentInfo();
}
public static IList<CommentInfo> GetUserCommentList(int startRowIndexId, int maxNumberRows, int nodeId, string userName)
{
return dal.GetUserCommentList(startRowIndexId, maxNumberRows, nodeId, DataSecurity.FilterBadChar(userName));
}
public static int MaxCommentId()
{
return dal.MaxCommentId();
}
public static int ScoreCount(int generalId)
{
return dal.ScoreCount(generalId);
}
public static bool SetStatus(int commentId, bool status)
{
CommentInfo commentInfo = dal.GetCommentInfo(commentId);
if (dal.SetStatus(commentId, status))
{
ContentManage.UpdateCommentAuditedAndUnaudited(commentInfo.GeneralId);
return true;
}
return false;
}
public static bool SetStatus(string commentIds, bool status)
{
if (!DataValidator.IsValidId(commentIds))
{
return false;
}
string[] strArray = commentIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < strArray.Length; i++)
{
SetStatus(DataConverter.CLng(strArray[i]), status);
}
return true;
}
public static bool Update(CommentInfo commentInfo)
{
EncodeCommentInfo(commentInfo);
return dal.Update(commentInfo);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -