Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
        private void addPost( object[] args, object target ) {

            OpenComment comment = args[0] as OpenComment;
            if (comment == null || comment.Id <= 0) return;

            // 只监控论坛评论,其他所有评论跳过
            if (comment.TargetDataType != typeof( ForumTopic ).FullName) return;

            // 附属信息
            ForumTopic topic = commentService.GetTarget( comment ) as ForumTopic;
            User creator = comment.Member;
            IMember owner = getOwner( topic );
            IApp app = ForumApp.findById( topic.AppId );

            // 内容
            ForumPost post = new ForumPost();

            post.ForumBoardId = topic.ForumBoard.Id;
            post.TopicId = topic.Id;
            post.ParentId = getParentId( comment, topic );
            post.Title = "re:" + topic.Title;
            post.Content = comment.Content;
            post.Ip = comment.Ip;


            // 保存
            // 因为comment本身已有通知,所以论坛不再发通知
            postService.InsertNoNotification( post, creator, owner, app );

            // 同步表
            CommentSync objSync = new CommentSync();
            objSync.Post = post;
            objSync.Comment = comment;
            objSync.insert();
        }
Exemplo n.º 3
0
        private void deleteCommentByPost(ForumPost post)
        {
            CommentSync objSync = CommentSync.find("PostId=" + post.Id).first();

            if (objSync == null)
            {
                return;
            }

            // 删除此评论
            OpenComment comment = objSync.Comment;

            commentService.Delete(comment);

            // 删除同步表 CommentSync
            objSync.delete();
        }
Exemplo n.º 4
0
        private void addComment(object[] args, object target)
        {
            ForumPost  post    = args[0] as ForumPost;
            ForumTopic topic   = ForumTopic.findById(post.TopicId);
            User       creator = args[1] as User;
            IMember    owner   = args[2] as IMember;
            IApp       app     = args[3] as IApp;

            OpenComment c = new OpenComment();

            c.Content   = strUtil.ParseHtml(post.Content);
            c.TargetUrl = alink.ToAppData(topic);

            c.TargetDataType = typeof(ForumTopic).FullName;
            c.TargetDataId   = topic.Id;
            c.TargetTitle    = topic.Title;
            c.TargetUserId   = topic.Creator.Id;

            c.OwnerId = owner.Id;
            c.AppId   = app.Id;
            c.FeedId  = getFeedId(topic);

            c.Ip       = post.Ip;
            c.Author   = creator.Name;
            c.ParentId = 0;
            c.AtId     = 0;

            c.Member = creator;

            Result result = commentService.CreateNoNotification(c);

            // 修复comment额外的replies更新
            IForumTopicService topicService = ObjectContext.Create <IForumTopicService>(typeof(ForumTopicService));

            topic.Replies = topicService.CountReply(post.TopicId);
            topic.update("Replies");

            // 同步表
            CommentSync x = new CommentSync();

            x.Post    = post;
            x.Comment = result.Info as OpenComment;
            x.insert();
        }
Exemplo n.º 5
0
        private void addPost(object[] args, object target)
        {
            OpenComment comment = args[0] as OpenComment;

            if (comment == null || comment.Id <= 0)
            {
                return;
            }

            // 只监控论坛评论,其他所有评论跳过
            if (comment.TargetDataType != typeof(ForumTopic).FullName)
            {
                return;
            }

            // 附属信息
            ForumTopic topic   = commentService.GetTarget(comment) as ForumTopic;
            User       creator = comment.Member;
            IMember    owner   = getOwner(topic);
            IApp       app     = ForumApp.findById(topic.AppId);

            // 内容
            ForumPost post = new ForumPost();

            post.ForumBoardId = topic.ForumBoard.Id;
            post.TopicId      = topic.Id;
            post.ParentId     = getParentId(comment, topic);
            post.Title        = "re:" + topic.Title;
            post.Content      = comment.Content;
            post.Ip           = comment.Ip;


            // 保存
            // 因为comment本身已有通知,所以论坛不再发通知
            postService.InsertNoNotification(post, creator, owner, app);

            // 同步表
            CommentSync objSync = new CommentSync();

            objSync.Post    = post;
            objSync.Comment = comment;
            objSync.insert();
        }
Exemplo n.º 6
0
        private void deletePost(object[] args, object target)
        {
            OpenComment comment = args[0] as OpenComment;

            CommentSync objSync = CommentSync.find("CommentId=" + comment.Id).first();

            if (objSync == null)
            {
                return;
            }

            // 删除帖子
            postService.DeleteToTrash(objSync.Post, comment.Member, "");

            // 删除同步表
            objSync.delete();

            // 删除 ForumPost 对应的 Microblog
        }
Exemplo n.º 7
0
        private int getParentId(OpenComment comment, ForumTopic topic)
        {
            ForumPost post = postService.GetPostByTopic(topic.Id);

            // 获取topic对应的post的Id
            if (comment.ParentId == 0)
            {
                return(post.Id);
            }
            else
            {
                CommentSync objSync = CommentSync.find("CommentId=" + comment.ParentId).first();
                if (objSync == null || objSync.Post == null)
                {
                    return(post.Id);
                }

                return(objSync.Post.Id);
            }
        }
Exemplo n.º 8
0
        private void addComment( object[] args, object target )
        {
            ForumPost post = args[0] as ForumPost;
            ForumTopic topic = ForumTopic.findById( post.TopicId );
            User creator = args[1] as User;
            IMember owner = args[2] as IMember;
            IApp app = args[3] as IApp;

            OpenComment c = new OpenComment();
            c.Content = strUtil.ParseHtml( post.Content );
            c.TargetUrl = alink.ToAppData( topic );

            c.TargetDataType = typeof( ForumTopic ).FullName;
            c.TargetDataId = topic.Id;
            c.TargetTitle = topic.Title;
            c.TargetUserId = topic.Creator.Id;

            c.OwnerId = owner.Id;
            c.AppId = app.Id;
            c.FeedId = getFeedId( topic );

            c.Ip = post.Ip;
            c.Author = creator.Name;
            c.ParentId = 0;
            c.AtId = 0;

            c.Member = creator;

            Result result = commentService.Create( c );

            // 同步表
            CommentSync x = new CommentSync();
            x.Post = post;
            x.Comment = result.Info as OpenComment;
            x.insert();
        }