예제 #1
0
        //----------------------------------------------------------------------------------------------


        private List <OpenComment> addSubList(List <OpenComment> list, Boolean isDesc)
        {
            String subIds = "";

            foreach (OpenComment c in list)
            {
                if (isDesc)
                {
                    subIds = strUtil.Join(subIds, c.LastReplyIds, ",");
                }
                else
                {
                    subIds = strUtil.Join(subIds, c.FirstReplyIds, ",");
                }
            }

            subIds = subIds.Trim().TrimStart(',').TrimEnd(',');
            if (strUtil.IsNullOrEmpty(subIds))
            {
                return(list);
            }

            List <OpenComment> totalSubList = OpenComment.find("Id in (" + subIds + ")").list();

            foreach (OpenComment c in list)
            {
                c.SetReplyList(getSubListFromTotal(c, totalSubList));
            }

            return(list);
        }
예제 #2
0
        private static void updateParentReplies(OpenComment c)
        {
            if (c.ParentId == 0)
            {
                return;
            }

            OpenComment p = OpenComment.findById(c.ParentId);

            if (p == null)
            {
                c.ParentId = 0;
                c.update();
                return;
            }

            //------------------------------------------------
            p.Replies = OpenComment.count("ParentId=" + p.Id);

            //-------------------------------------------------
            List <OpenComment> subFirst = OpenComment.find("ParentId=" + p.Id + " order by Id asc").list(OpenComment.subCacheSize);
            List <OpenComment> subLast  = OpenComment.find("ParentId=" + p.Id + " order by Id desc").list(OpenComment.subCacheSize);

            p.FirstReplyIds = strUtil.GetIds(subFirst);
            p.LastReplyIds  = strUtil.GetIds(subLast);

            p.update();
        }
예제 #3
0
        public List <OpenComment> GetMore(int parentId, int startId, int replyPageSize, string sort)
        {
            String condition = "";

            if (sort == "asc")
            {
                condition = "ParentId=" + parentId + " and Id>" + startId + " order by Id asc";
            }
            else
            {
                condition = "ParentId=" + parentId + " and Id<" + startId + " order by Id desc";
            }

            return(OpenComment.find(condition).list(replyPageSize));
        }
예제 #4
0
        public List <OpenComment> GetByApp(Type type, int appId, int listCount)
        {
            if (listCount <= 0)
            {
                listCount = 7;
            }

            String condition = "TargetDataType='" + type + "'";

            if (appId > 0)
            {
                condition = condition + " and AppId=" + appId;
            }

            return(OpenComment.find(condition).list(listCount));
        }
예제 #5
0
        private void updateRootTargetReplies(OpenComment c)
        {
            int replies;
            OpenCommentCount objCount;

            if (c.TargetDataId > 0 && strUtil.HasText(c.TargetDataType))
            {
                replies = OpenComment.find("TargetDataType=:dtype and TargetDataId=" + c.TargetDataId)
                          .set("dtype", c.TargetDataType)
                          .count();

                objCount = OpenCommentCount.find("DataType=:dtype and DataId=" + c.TargetDataId)
                           .set("dtype", c.TargetDataType)
                           .first();
            }
            else
            {
                if (c.TargetUrl == null)
                {
                    replies  = 0;
                    objCount = null;
                }
                else
                {
                    replies = OpenComment.find("TargetUrl=:url")
                              .set("url", c.TargetUrl)
                              .count();

                    objCount = OpenCommentCount.find("TargetUrl=:url")
                               .set("url", c.TargetUrl)
                               .first();
                }
            }


            if (objCount == null)
            {
                insertCommentCount(c, replies);
            }
            else
            {
                updateCommentCount(objCount, replies);
            }

            updateTargetReplies(c, replies);
        }