Ejemplo n.º 1
0
        private long getOldParentId(long id, CommentLevel level)
        {
            Object p = ndb.findById(commentType, id);

            if (p == null)
            {
                return(0);
            }

            IComment comment = p as IComment;

            if (comment == null)
            {
                return(0);
            }

            if (comment.ParentId == 0)
            {
                return(id);
            }
            if (comment.ParentId == id)
            {
                return(id);
            }

            level.Count = level.Count + 1;

            if (level.Count > 5)
            {
                return(0);
            }

            return(getOldParentId(comment.ParentId, level));
        }
Ejemplo n.º 2
0
        private long getParentId(IComment x)
        {
            if (x.ParentId <= 0)
            {
                return(0);
            }

            // 旧版数据
            if (x.ParentId == x.RootId)
            {
                return(0);
            }

            CommentLevel level = new CommentLevel {
                Count = 1
            };
            long parentId = getOldParentId(x.ParentId, level);

            OpenCommentTrans trans = OpenCommentTrans.find("CommentId=:cid and CommentType=:ctype")
                                     .set("cid", parentId)
                                     .set("ctype", x.GetType().FullName)
                                     .first();

            if (trans == null)
            {
                return(0);
            }

            if (trans.OpenCommentId <= 0)
            {
                return(0);
            }

            return(trans.OpenCommentId);
        }