/// [内容] --评论消息 private EMsgContent_CommentRes commentToContent(MsgSubmitComment msgSubmitComment) { var submit = msgSubmitComment.SubmitComment; var bi = _bookRepository.getBookSimple_ByCode(submit.parentRefCode); if (bi == null) { throw new Exception("消息服务[commentToContent]:没有找到书本Code"); } //Orig Content(针对哪个资源信息做的消息) var res = _resourceReponsitory.getSimpleByCode(submit.refCode); if (res == null) { throw new Exception("消息服务[commentToContent]:没有找资源"); } //EResourceInfo res = _resourceReponsitory.GetByKey(submit.refCode).Result; //var origContent = res.ResType == ResType.BookOss ? $"[{res.FileType}]{res.OrigFileName}" : $"[URL]-{res.Url}"; EMsgContent_CommentRes msgContent = new EMsgContent_CommentRes { BookCode = bi.Code, BookName = bi.Title, BookUrl = bi.CoverUrl, ResCode = res.Code, ResName = res.ShowName, // OrigContent = submit.content, }; return(msgContent); }
/// <summary> /// 创建评论消息 /// </summary> /// <param name="msgSubmitComment"></param> public void CreateNotification_Comment(MsgSubmitComment msgSubmitComment) { var submit = msgSubmitComment.SubmitComment; if (msgSubmitComment.CommentId <= 0) { return; } if (string.IsNullOrEmpty(submit.userId)) { throw new CCException("非法人员 userId is null "); } if (string.IsNullOrEmpty(submit.refCode)) { throw new CCException("资源不存在,refCode is null"); } //检查消息内容 EMsgContent_CommentRes existContent = _msgCommentResRepository.GetContentCommentRes_Sync(submit.refCode); if (existContent == null) //不存在 { //新内容 existContent = commentToContent(msgSubmitComment); existContent.Id = _msgCommentResRepository.AddContentCommentRes_Sync(existContent); } //评论消息不用检查是否发送过... EMsgInfo_CommentRes msg = commentToMsg(msgSubmitComment); if (msg == null) { return; } // //检查发送者和接受者是否同一人 if (msg.ReceiveUserId == msg.SendUserId) { return; } var transResult = _msgCommentResRepository.Db.Ado.UseTran(() => { //新消息 _msgCommentResRepository.AddNoIdentity_Sync(msg); //总数 _msgInfoOverviewRepository.UpdateNotificateToUnRead(NotificationType.comment, msg.ReceiveUserId); }); if (!transResult.IsSuccess) { throw new Exception(transResult.ErrorMessage); } }
public long AddContentCommentRes_Sync(EMsgContent_CommentRes content) { var insertable = Db.Insertable(content); return(insertable.ExecuteReturnBigIdentity()); }