示例#1
0
        public int GetRepliesByData(int dataId, String dataType)
        {
            OpenCommentCount objCount = OpenCommentCount.find("DataType=:dtype and DataId=" + dataId)
                                        .set("dtype", dataType)
                                        .first();

            return(objCount == null ? 0 : objCount.Replies);
        }
示例#2
0
        public int GetRepliesByUrl(String url)
        {
            OpenCommentCount objCount = OpenCommentCount.find("TargetUrl=:url")
                                        .set("url", url)
                                        .first();

            return(objCount == null ? 0 : objCount.Replies);
        }
示例#3
0
        private static void insertCommentCount(OpenComment c, int replies)
        {
            OpenCommentCount objCount = new OpenCommentCount();

            objCount.TargetUrl = c.TargetUrl;
            objCount.DataType  = c.TargetDataType;
            objCount.DataId    = c.TargetDataId;
            objCount.Replies   = replies;

            objCount.insert();
        }
示例#4
0
        private static void clearRootTargetRepliesByUrl(String url)
        {
            OpenCommentCount objCount = OpenCommentCount.find("TargetUrl=:url")
                                        .set("url", url)
                                        .first();

            if (objCount == null)
            {
                return;
            }

            objCount.Replies = 0;
            objCount.update();
        }
示例#5
0
        private static void clearRootTargetRepliesByData(int dataId, string dataType)
        {
            OpenCommentCount objCount = OpenCommentCount.find("DataType=:dtype and DataId=" + dataId)
                                        .set("dtype", dataType)
                                        .first();

            if (objCount == null)
            {
                return;
            }

            objCount.Replies = 0;
            objCount.update();
        }
示例#6
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);
        }
示例#7
0
 private static void updateCommentCount(OpenCommentCount objCount, int replies)
 {
     objCount.Replies = replies;
     objCount.update();
 }