/// <summary> /// 回复帖子的回复 /// </summary> /// <param name="model">回复模型</param> public void ReplyToRepliedMessage(ReplyRepliedMsgModel model) { //IForumThreadRepository forumThreadRep = FBS.Factory.Factory<IForumThreadRepository>.GetConcrete(); //IAccountRepository accountRep = FBS.Factory.Factory<IAccountRepository>.GetConcrete(); //IForumsRepository forumsRep = FBS.Factory.Factory<IForumsRepository>.GetConcrete(); //IForumMessageRepository msgRep = FBS.Factory.Factory<IForumMessageRepository>.GetConcrete(); IForumThreadRepository threadRep = Factory.Factory <IForumThreadRepository> .GetConcrete(); IRepository <ForumThread> threadWriteRep = Factory.Factory <IRepository <ForumThread> > .GetConcrete <ForumThread>(); IRepository <ForumMessageReply> msgRep = Factory.Factory <IRepository <ForumMessageReply> > .GetConcrete <ForumMessageReply>(); IRepository <Forum> forumRep = Factory.Factory <IRepository <Forum> > .GetConcrete <Forum>(); IRepository <Account> accountRep = Factory.Factory <IRepository <Account> > .GetConcrete <Account>(); //获取欲回复的回复 ForumMessageReply readyToReply = msgRep.GetByKey(model.ReadyToReplyMessageID); ForumThread thread = threadRep.GetByKey(model.ThreadID); Forum forum = forumRep.GetByKey(thread.ForumID); //板块 //Forum forum = forumsRep.GetByKey(readyToReply.Forum); //消息对象 MessageVO mVO = new MessageVO(); switch (model.ReplyType) { case ReplyType.Quote: mVO.Body = "<div class=\"quote\">" + "@<a href='" + FBS.Utils.UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, readyToReply.Account.ToString()) + "' target='_blank'>" + accountRep.GetByKey(readyToReply.Account).UserName + "</a><br />" + readyToReply.MessageVO.Body + "</div>" + model.Body; break; default: mVO.Body = "<div class=\"reply\">" + "@<a href='" + FBS.Utils.UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, readyToReply.Account.ToString()) + "' target='_blank'>" + accountRep.GetByKey(readyToReply.Account).UserName + "</a><br />" + readyToReply.MessageVO.Body + "</div>" + model.Body; break; } ForumMessageReply newReply = new ForumMessageReply(mVO, model.User.UserID, forum.Id, model.ReadyToReplyMessageID, model.ThreadID); //更新"吧"的帖子数 forum.AddNewMessage(newReply); forumRep.Update(forum); forumRep.PersistAll(); //更新主题的最后更新时间 thread.ModifiedDate = newReply.CreationDate; thread.AddMessageCount(); threadWriteRep.Update(thread); threadWriteRep.PersistAll(); //向库中增加回帖 msgRep.Add(newReply); msgRep.PersistAll(); }
/// <summary> /// 对主题进行回复 /// </summary> /// <param name="forumThread">主题实体</param> /// <param name="forumMessageReply">回复消息实体</param> public void ReplyThread(ReplyThreadModel model) { //IForumThreadRepository forumThreadRep = FBS.Factory.Factory<IForumThreadRepository>.GetConcrete(); //IAccountRepository accountRep = FBS.Factory.Factory<IAccountRepository>.GetConcrete(); //IForumsRepository forumsRep = FBS.Factory.Factory<IForumsRepository>.GetConcrete(); //IForumMessageRepository msgRep = FBS.Factory.Factory<IForumMessageRepository>.GetConcrete(); IRepository <ForumMessage> msgRep = Factory.Factory <IRepository <ForumMessage> > .GetConcrete <ForumMessage>(); IForumThreadRepository threadRep = Factory.Factory <IForumThreadRepository> .GetConcrete(); IRepository <Forum> forumRep = Factory.Factory <IRepository <Forum> > .GetConcrete <Forum>(); IRepository <ForumThread> threadWriteRep = Factory.Factory <IRepository <ForumThread> > .GetConcrete <ForumThread>(); ForumMessageReply reply = null; ThreadRootMessage rootmsg = null; Forum forum = null; ForumThread thread = null; MessageVO mVO = new MessageVO(); mVO.Body = model.Body; try { thread = threadRep.GetByKey(model.ThreadID); rootmsg = thread.RootMessage; forum = forumRep.GetByKey(model.ForumID); //主题回复数增加 thread.AddMessageCount(); //forum = forumsRep.GetByKey(rootmsg.Forum); //poster = accountRep.GetByKey(model.AccountID); //回复 reply = new ForumMessageReply(mVO, model.AccountID, model.ForumID, rootmsg.Id, thread.Id); //加入板块的最后发表并对板块回复计数 forum.AddNewMessage(reply); //更新帖子 thread.ModifiedDate = reply.CreationDate; //thread.CreationDate = reply.CreationDate; //给主题增加回复 msgRep.Add(reply); msgRep.PersistAll(); threadWriteRep.Update(thread); threadWriteRep.PersistAll(); forumRep.Update(forum); forumRep.PersistAll(); //forumThreadRep.Update(thread); //forumThreadRep.PersistAll(); } catch (Exception error) { throw new ReplyForumThreadException("回复失败,原因为:", error); } }