Exemple #1
0
        private void updateComment(object[] args, object target)
        {
            ForumPost  post   = args[0] as ForumPost;
            User       editor = args[1] as User;
            ForumTopic topic  = ForumTopic.findById(post.TopicId);

            // 更新评论
            CommentSync objSync = CommentSync.find("PostId=" + post.Id).first();

            if (objSync == null)
            {
                return;
            }
            OpenComment comment = objSync.Comment;

            comment.Content = strUtil.ParseHtml(post.Content);
            comment.update();

            // 更新此ForumPost对应的Microblog
            Microblog mblog = Microblog.find("DataId=:id and DataType=:dtype")
                              .set("id", post.Id)
                              .set("dtype", typeof(ForumPost).FullName)
                              .first();

            if (mblog != null)
            {
                mblog.Content = getPostContent(post);
                mblog.update();
            }
        }
Exemple #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();
        }