/// <summary> /// [内容] -- 回复信息 /// </summary> private EMsgContent_ReplyRes replyToContent(MsgSubmitReply msgSubmitReply, ResSimple resSimple) { var submit = msgSubmitReply.SubmitReply; var bi = _bookRepository.getBookSimple_ByCode(submit.bookCode); if (bi == null) { throw new Exception("消息服务[replyToContent]:没有找到书本Code"); } //评论原始内容 // EComment_Res comment = _commentRepository.GetByKey(submit.commentId).Result; EMsgContent_ReplyRes msgContent = new EMsgContent_ReplyRes { BookCode = bi.Code, BookName = bi.Title, BookUrl = bi.CoverUrl, ResCode = resSimple.Code, ResName = resSimple.ShowName }; //资源信息 //var res = _resourceReponsitory.getSimpleByCommentId(submit.commentId); //msgContent.ResCode = res.Code; //msgContent.ResName = res.ShowName; //if (submit.replyId > 0) //{ // //回复信息 // ECommentReply_Res reply = _commentReplyRepository.GetByKey(submit.replyId).Result; // msgContent.OrigReplyContent = reply.content //} return(msgContent); }
public long AddContentReplyRes_Sync(EMsgContent_ReplyRes content) { var insertable = Db.Insertable(content); return(insertable.ExecuteReturnBigIdentity()); }
/// <summary> /// 创建回复消息 /// </summary> /// <param name="msgSubmitReply"></param> public void CreateNotification_Reply(MsgSubmitReply msgSubmitReply) { var submit = msgSubmitReply.SubmitReply; //没有新的回复需要通知 if (msgSubmitReply.ReplyId <= 0) { return; } if (string.IsNullOrEmpty(submit.userId)) { throw new CCException("非法人员 userId is null "); } if (submit.commentId < 0) { throw new CCException("commentId is null"); } //检查消息内容 var res = _resourceReponsitory.getSimpleByCommentId(submit.commentId); if (res == null) { throw new Exception("消息服务[CreateNotification_Reply]:没有找到资源"); } EMsgContent_ReplyRes existContent = _msgReplyRepository.GetContentReplyRes_Sync(res.Code); if (existContent == null) //不存在 { //新内容 existContent = replyToContent(msgSubmitReply, res); existContent.Id = _msgReplyRepository.AddContentReplyRes_Sync(existContent); } EMsgInfo_ReplyRes msg = replyToMsg(msgSubmitReply, res); if (msg == null) { return; } // //检查发送者和接受者是否同一人 if (msg.ReceiveUserId == msg.SendUserId) { return; } var transResult = _msgReplyRepository.Db.Ado.UseTran(() => { //新消息 _msgReplyRepository.AddNoIdentity_Sync(msg); //总数 _msgInfoOverviewRepository.UpdateNotificateToUnRead(NotificationType.reply, msg.ReceiveUserId); }); if (!transResult.IsSuccess) { throw new Exception(transResult.ErrorMessage); } }