Esempio n. 1
0
        /// <summary>
        /// 删除搜索结果
        /// </summary>
        /// <param name="operatorID"></param>
        /// <param name="filter"></param>
        /// <param name="isDeleteArticle"></param>
        /// <param name="isUpdatePoint"></param>
        /// <param name="deleteTopCount"></param>
        /// <param name="deletedCount"></param>
        /// <returns></returns>
        public bool DeleteCommentsForAdmin(int operatorID, AdminCommentFilter filter, bool isUpdatePoint, int deleteTopCount, out int deletedCount)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter");
            }

            deletedCount = 0;

            if (ValidateCommentAdminPermission(operatorID) == false)
            {
                return(false);
            }

            int deleteCountTemp = 0;

            bool succeed = ProcessDeleteComments(operatorID, isUpdatePoint, delegate(Guid[] excludeRoleIDs)
            {
                return(CommentDao.Instance.DeleteCommentsBySearch(filter, operatorID, excludeRoleIDs, deleteTopCount, out deleteCountTemp));
            });

            deletedCount = deleteCountTemp;

            return(succeed);
        }
Esempio n. 2
0
        public override CommentCollection GetCommentsByFilter(AdminCommentFilter filter, int operatorUserID, IEnumerable <Guid> excludeRoleIDs, int pageNumber, out int totalCount)
        {
            totalCount = 0;

            using (SqlQuery query = new SqlQuery())
            {
                query.Pager.TableName = "bx_Comments";
                query.Pager.SortField = filter.Order.ToString();
                if (filter.Order != AdminCommentFilter.OrderBy.CommentID)
                {
                    query.Pager.PrimaryKey = "CommentID";
                }
                query.Pager.IsDesc      = filter.IsDesc;
                query.Pager.PageNumber  = pageNumber;
                query.Pager.PageSize    = filter.PageSize;
                query.Pager.SelectCount = true;
                query.Pager.Condition   = BuildConditionsByFilter(query, filter, false, operatorUserID, excludeRoleIDs);


                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    CommentCollection comments = new CommentCollection(reader);
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            totalCount = reader.Get <int>(0);
                        }
                    }
                    return(comments);
                }
            }
        }
Esempio n. 3
0
        public override CommentCollection GetCommentsBySearch(int operatorID, Guid[] excludeRoleIDs, AdminCommentFilter filter, int pageNumber)
        {
            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, false, operatorID, excludeRoleIDs);

                query.Pager.TableName = "[bx_Comments]";
                query.Pager.SortField = filter.Order.ToString();
                query.Pager.IsDesc = filter.IsDesc;
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = filter.PageSize;
                query.Pager.SelectCount = true;

                query.Pager.Condition = conditions.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    CommentCollection comments = new CommentCollection(reader);

                    if (reader.NextResult())
                    {
                        if (reader.Read())
                        {
                            comments.TotalRecords = reader.Get<int>(0);
                        }
                    }

                    return comments;
                }
            }
        }
Esempio n. 4
0
        public override DeleteResult DeleteCommentsByFilter(AdminCommentFilter filter, int operatorUserID, IEnumerable <Guid> excludeRoleIDs, bool getDeleteResult)
        {
            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, true, operatorUserID, excludeRoleIDs);

                string sql = string.Empty;

                if (getDeleteResult)
                {
                    sql = @"SELECT [UserID],COUNT(*) AS [Count] FROM [bx_Comments] {0} GROUP BY [UserID];";
                }
                sql += "DELETE FROM bx_Comments {0};";


                query.CommandText = string.Format(sql, conditions);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DeleteResult deleteResult = new DeleteResult();
                    while (reader.Read())
                    {
                        deleteResult.Add(reader.Get <int>("UserID"), reader.Get <int>("Count"));
                    }
                    return(deleteResult);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 搜索评论
        /// </summary>
        /// <param name="operatorID"></param>
        /// <param name="filter"></param>
        /// <param name="pageNumber"></param>
        /// <returns></returns>
        public CommentCollection GetCommentsForAdmin(int operatorID, AdminCommentFilter filter, int pageNumber)
        {
            if (ValidateCommentAdminPermission(operatorID) == false)
            {
                return(null);
            }

            Guid[] excludeRoleIDs = ManagePermission.GetNoPermissionTargetRoleIds(operatorID, PermissionTargetType.Content);

            CommentCollection comments = CommentDao.Instance.GetCommentsBySearch(operatorID, excludeRoleIDs, filter, pageNumber);

            ProcessKeyword(comments, ProcessKeywordMode.FillOriginalText);

            return(comments);
        }
Esempio n. 6
0
        public override DeleteResult DeleteCommentsBySearch(AdminCommentFilter filter, int operatorID, IEnumerable <Guid> excludeRoleIDs, int topCount, out int deletedCount)
        {
            deletedCount = 0;

            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, true, operatorID, excludeRoleIDs);

                StringBuffer sql = new StringBuffer();

                sql += @"
DECLARE @DeleteData table (UserID int, CommentID int);

INSERT INTO @DeleteData SELECT TOP (@TopCount) [UserID],[CommentID] FROM [bx_Comments] " + conditions + @";

DELETE [bx_Comments] WHERE CommentID IN (SELECT [CommentID] FROM @DeleteData);

SELECT @@ROWCOUNT;

SELECT [UserID],COUNT(*) AS [Count] FROM @DeleteData GROUP BY [UserID];";

                query.CreateTopParameter("@TopCount", topCount);

                query.CommandText = sql.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DeleteResult deleteResult = new DeleteResult();

                    if (reader.Read())
                    {
                        deletedCount = reader.Get <int>(0);
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            deleteResult.Add(reader.Get <int>("UserID"), reader.Get <int>("Count"));
                        }
                    }

                    return(deleteResult);
                }
            }
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            m_Filter = AdminCommentFilter.GetFromFilter("filter");

            if (_Request.IsClick("deletecomment"))
            {
                Delete();
            }
            else if (_Request.IsClick("searchcomment"))
            {
                Search();
            }
            else if (_Request.IsClick("approvecomment"))
            {
                Approve();
            }
            else if (_Request.IsClick("deletesearch"))
            {
                DeleteBySearch();
            }

            using (ErrorScope es = new ErrorScope())
            {
                int pageNumber = _Request.Get <int>("page", 0);

                m_CommentList = CommentBO.Instance.GetCommentsForAdmin(MyUserID, m_Filter, pageNumber);

                if (m_CommentList != null)
                {
                    m_CommentTotalCount = m_CommentList.TotalRecords;

                    UserBO.Instance.WaitForFillSimpleUsers <Comment>(m_CommentList);
                }

                if (es.HasUnCatchedError)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        ShowError(error);
                    });
                }
            }
        }
Esempio n. 8
0
        public override bool BeforeExecute(int operatorUserID, string param, ref long offset, ref int totalCount, out string title)
        {
            StringList paramData = StringList.Parse(param);

            AdminCommentFilter filter = AdminCommentFilter.Parse(paramData[0]);

            //只取一条数据测试下就可以
            filter.PageSize = 1;

            CommentCollection comments = CommentBO.Instance.GetCommentsForAdmin(operatorUserID, filter, 1);

            if (comments == null || comments.Count == 0)
            {
                title = "没有数据可以删除";
                return(false);
            }

            totalCount = comments.TotalRecords;

            title = "将删除 " + totalCount + " 条评论";

            return(true);
        }
Esempio n. 9
0
        public override bool StepExecute(int operatorUserID, string param, ref long offset, ref int totalCount, ref int finishedCount, out string title, out bool isLastStep)
        {
            StringList paramData = StringList.Parse(param);

            AdminCommentFilter filter = AdminCommentFilter.Parse(paramData[0]);

            int stepCount;

            if (CommentBO.Instance.DeleteCommentsForAdmin(operatorUserID, filter, paramData[1] == "1", stepDeleteCount, out stepCount))             // .DeleteDoingsBySearch(filter, 200);
            {
                finishedCount += stepCount;

                isLastStep = stepCount < stepDeleteCount;

                title = "正在删除评论,总数 " + totalCount + ",已删 " + finishedCount;
            }
            else
            {
                isLastStep = true;
                title      = string.Empty;
            }

            return(true);
        }
Esempio n. 10
0
 /// <summary>
 /// 搜索评论 后台
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="pageNumber"></param>
 /// <param name="pageSize"></param>
 /// <param name="totalCount"></param>
 /// <returns></returns>
 public abstract CommentCollection GetCommentsByFilter(AdminCommentFilter filter, int operatorUserID, IEnumerable <Guid> excludeRoleIDs, int pageNumber, out int totalCount);
Esempio n. 11
0
        private void Search()
        {
            AdminCommentFilter filter = AdminCommentFilter.GetFromForm();

            filter.Apply("filter", "page");
        }
Esempio n. 12
0
        public override DeleteResult DeleteCommentsBySearch(AdminCommentFilter filter, int operatorID, IEnumerable<Guid> excludeRoleIDs, int topCount, out int deletedCount)
        {
            deletedCount = 0;

            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, true, operatorID, excludeRoleIDs);

                StringBuffer sql = new StringBuffer();

                sql += @"
DECLARE @DeleteData table (UserID int, CommentID int);

INSERT INTO @DeleteData SELECT TOP (@TopCount) [UserID],[CommentID] FROM [bx_Comments] " + conditions + @";

DELETE [bx_Comments] WHERE CommentID IN (SELECT [CommentID] FROM @DeleteData);

SELECT @@ROWCOUNT;

SELECT [UserID],COUNT(*) AS [Count] FROM @DeleteData GROUP BY [UserID];";

                query.CreateTopParameter("@TopCount", topCount);

                query.CommandText = sql.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DeleteResult deleteResult = new DeleteResult();

                    if (reader.Read())
                        deletedCount = reader.Get<int>(0);

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            deleteResult.Add(reader.Get<int>("UserID"), reader.Get<int>("Count"));
                        }
                    }

                    return deleteResult;
                }
            }

        }
Esempio n. 13
0
 /// <summary>
 /// 删除搜索结果
 /// </summary>
 /// <param name="filter"></param>
 /// <param name="operatorID"></param>
 /// <param name="excludeRoleIDs"></param>
 /// <param name="topCount"></param>
 /// <param name="deletedCount"></param>
 /// <returns></returns>
 public abstract DeleteResult DeleteCommentsBySearch(AdminCommentFilter filter, int operatorID, IEnumerable <Guid> excludeRoleIDs, int topCount, out int deletedCount);
Esempio n. 14
0
        public override CommentCollection GetCommentsByFilter(AdminCommentFilter filter, int operatorUserID, IEnumerable<Guid> excludeRoleIDs, int pageNumber, out int totalCount)
        {
            totalCount = 0;

            using (SqlQuery query = new SqlQuery())
            {

                query.Pager.TableName = "bx_Comments";
                query.Pager.SortField = filter.Order.ToString();
                if (filter.Order != AdminCommentFilter.OrderBy.CommentID)
                    query.Pager.PrimaryKey = "CommentID";
                query.Pager.IsDesc = filter.IsDesc;
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = filter.PageSize;
                query.Pager.SelectCount = true;
                query.Pager.Condition = BuildConditionsByFilter(query, filter, false, operatorUserID, excludeRoleIDs);


                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    CommentCollection comments = new CommentCollection(reader);
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                            totalCount = reader.Get<int>(0);
                    }
                    return comments;
                }
            }
        }
Esempio n. 15
0
        public override DeleteResult DeleteCommentsByFilter(AdminCommentFilter filter, int operatorUserID, IEnumerable<Guid> excludeRoleIDs, bool getDeleteResult)
        {

            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, true, operatorUserID, excludeRoleIDs);

                string sql = string.Empty;

                if (getDeleteResult)
                {
                    sql = @"SELECT [UserID],COUNT(*) AS [Count] FROM [bx_Comments] {0} GROUP BY [UserID];";
                }
                sql += "DELETE FROM bx_Comments {0};";


                query.CommandText = string.Format(sql, conditions);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    DeleteResult deleteResult = new DeleteResult();
                    while (reader.Read())
                    {
                        deleteResult.Add(reader.Get<int>("UserID"), reader.Get<int>("Count"));
                    }
                    return deleteResult;
                }
            }
        }
Esempio n. 16
0
        private string BuildConditionsByFilter(SqlQuery query, AdminCommentFilter filter, bool startWithWhere, int operatorUserID, IEnumerable<Guid> excludeRoleIds)
        {
            StringBuffer sqlCondition = new StringBuffer();

            if (filter.Type != CommentType.All)
            {
                sqlCondition += " AND Type = @Type";
                query.CreateParameter<int>("@Type", (int)filter.Type, SqlDbType.Int);
            }

            if (filter.IsApproved != null)
            {
                sqlCondition += " AND IsApproved = @IsApproved";
                query.CreateParameter<bool?>("@IsApproved", filter.IsApproved, SqlDbType.Bit);
            }

            if (string.IsNullOrEmpty(filter.Username) == false)
            {
                sqlCondition += " AND UserID = (SELECT UserID FROM bx_Users WHERE Username = @Username)";
                query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
            }

            if (string.IsNullOrEmpty(filter.TargetUsername) == false)
            {
                sqlCondition += " AND TargetUserID IN (SELECT UserID FROM bx_Users WHERE Username = @TargetUsername)";
                query.CreateParameter<string>("@TargetUsername", filter.TargetUsername, SqlDbType.NVarChar, 50);
            }

            if (filter.BeginDate != null)
            {
                sqlCondition += " AND CreateDate >= @BeginDate";
                query.CreateParameter<DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime);
            }

            if (filter.EndDate != null)
            {
                sqlCondition += " AND CreateDate <= @EndDate";
                query.CreateParameter<DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime);
            }

            if (!string.IsNullOrEmpty(filter.Content))
            {
                sqlCondition += " AND Content LIKE '%'+@Content+'%'";
                query.CreateParameter<string>("@Content", filter.Content, SqlDbType.NVarChar, 50);
            }

            if (!string.IsNullOrEmpty(filter.IP))
            {
                sqlCondition += " AND CreateIP = @CreateIP";
                query.CreateParameter<string>("@CreateIP", filter.IP, SqlDbType.VarChar, 50);
            }

            string excludeRoleSQL = DaoUtil.GetExcludeRoleSQL("[UserID]", "[LastEditUserID]", operatorUserID, excludeRoleIds, query);

            if (string.IsNullOrEmpty(excludeRoleSQL) == false)
            {
                sqlCondition += " AND " + excludeRoleSQL;
            }


            if (sqlCondition.Length != 0)
            {
                sqlCondition.Remove(0, 5);
            }

            if (startWithWhere && sqlCondition.Length > 0)
            {
                sqlCondition.InnerBuilder.Insert(0, " WHERE ");
            }

            return sqlCondition.ToString();
        }
Esempio n. 17
0
 /// <summary>
 /// 搜索评论
 /// </summary>
 /// <param name="excludeRoleIDs"></param>
 /// <param name="filter"></param>
 /// <param name="pageNumber"></param>
 /// <param name="pageSize"></param>
 /// <returns></returns>
 public abstract CommentCollection GetCommentsBySearch(int operatorID, Guid[] excludeRoleIDs, AdminCommentFilter filter, int pageNumber);
Esempio n. 18
0
 /// <summary>
 /// 删除搜索结果
 /// </summary>
 /// <param name="filter"></param>
 public abstract DeleteResult DeleteCommentsByFilter(AdminCommentFilter filter, int operatorUserID, IEnumerable <Guid> excludeRoleIDs, bool getDeleteResult);
Esempio n. 19
0
        public override CommentCollection GetCommentsBySearch(int operatorID, Guid[] excludeRoleIDs, AdminCommentFilter filter, int pageNumber)
        {
            using (SqlQuery query = new SqlQuery())
            {
                string conditions = BuildConditionsByFilter(query, filter, false, operatorID, excludeRoleIDs);

                query.Pager.TableName   = "[bx_Comments]";
                query.Pager.SortField   = filter.Order.ToString();
                query.Pager.IsDesc      = filter.IsDesc;
                query.Pager.PageNumber  = pageNumber;
                query.Pager.PageSize    = filter.PageSize;
                query.Pager.SelectCount = true;

                query.Pager.Condition = conditions.ToString();

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    CommentCollection comments = new CommentCollection(reader);

                    if (reader.NextResult())
                    {
                        if (reader.Read())
                        {
                            comments.TotalRecords = reader.Get <int>(0);
                        }
                    }

                    return(comments);
                }
            }
        }
Esempio n. 20
0
        private string BuildConditionsByFilter(SqlQuery query, AdminCommentFilter filter, bool startWithWhere, int operatorUserID, IEnumerable <Guid> excludeRoleIds)
        {
            StringBuffer sqlCondition = new StringBuffer();

            if (filter.Type != CommentType.All)
            {
                sqlCondition += " AND Type = @Type";
                query.CreateParameter <int>("@Type", (int)filter.Type, SqlDbType.Int);
            }

            if (filter.IsApproved != null)
            {
                sqlCondition += " AND IsApproved = @IsApproved";
                query.CreateParameter <bool?>("@IsApproved", filter.IsApproved, SqlDbType.Bit);
            }

            if (string.IsNullOrEmpty(filter.Username) == false)
            {
                sqlCondition += " AND UserID = (SELECT UserID FROM bx_Users WHERE Username = @Username)";
                query.CreateParameter <string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
            }

            if (string.IsNullOrEmpty(filter.TargetUsername) == false)
            {
                sqlCondition += " AND TargetUserID IN (SELECT UserID FROM bx_Users WHERE Username = @TargetUsername)";
                query.CreateParameter <string>("@TargetUsername", filter.TargetUsername, SqlDbType.NVarChar, 50);
            }

            if (filter.BeginDate != null)
            {
                sqlCondition += " AND CreateDate >= @BeginDate";
                query.CreateParameter <DateTime?>("@BeginDate", filter.BeginDate, SqlDbType.DateTime);
            }

            if (filter.EndDate != null)
            {
                sqlCondition += " AND CreateDate <= @EndDate";
                query.CreateParameter <DateTime?>("@EndDate", filter.EndDate, SqlDbType.DateTime);
            }

            if (!string.IsNullOrEmpty(filter.Content))
            {
                sqlCondition += " AND Content LIKE '%'+@Content+'%'";
                query.CreateParameter <string>("@Content", filter.Content, SqlDbType.NVarChar, 50);
            }

            if (!string.IsNullOrEmpty(filter.IP))
            {
                sqlCondition += " AND CreateIP = @CreateIP";
                query.CreateParameter <string>("@CreateIP", filter.IP, SqlDbType.VarChar, 50);
            }

            string excludeRoleSQL = DaoUtil.GetExcludeRoleSQL("[UserID]", "[LastEditUserID]", operatorUserID, excludeRoleIds, query);

            if (string.IsNullOrEmpty(excludeRoleSQL) == false)
            {
                sqlCondition += " AND " + excludeRoleSQL;
            }


            if (sqlCondition.Length != 0)
            {
                sqlCondition.Remove(0, 5);
            }

            if (startWithWhere && sqlCondition.Length > 0)
            {
                sqlCondition.InnerBuilder.Insert(0, " WHERE ");
            }

            return(sqlCondition.ToString());
        }