public async Task <ModelPager <VueMsgInfoNotification> > queryUserReply(QMsgUser query) { ModelPager <VueMsgInfoNotification> result = new ModelPager <VueMsgInfoNotification>(query.pageIndex, query.pageSize); var mainSql = Db.Queryable <EMsgInfo_ReplyRes, EMsgContent_ReplyRes>((m, c) => new object[] { JoinType.Left, m.resCode == c.ResCode }) .Where((m, c) => m.ReceiveUserId == query.userId) .OrderBy((m, c) => m.CreatedDateTime, OrderByType.Desc) .Select((m, c) => new VueMsgInfoNotification { dbDateTime = m.CreatedDateTime, senderHeaderUrl = m.SendHeaderUrl, senderId = m.SendUserId, senderName = m.SendName, bookCode = c.BookCode, bookUrl = c.BookUrl, resCode = c.ResCode, resName = c.ResName, commentId = m.CommentId, replyId = m.ReplyId, receiveContent = m.ReceiveContent, NotificationStatus = m.NotificationStatus, msgId = m.Id }); RefAsync <int> totalNumber = new RefAsync <int>(); result.datas = await mainSql.ToPageListAsync(query.pageIndex, query.pageSize, totalNumber); result.totalCount = totalNumber; return(result); }
public ModelPager <VueMsgInfoNotification> QueryUserNotifictaion(QMsgUser query) { if (string.IsNullOrEmpty(query.userId)) { throw new CCException("非法请求"); } ModelPager <VueMsgInfoNotification> result = null; switch (query.notificationType) { case NotificationType.praize: result = _msgPraizeRepository.queryUserPraize(query).Result; break; case NotificationType.comment: result = _msgCommentResRepository.queryUserComment(query).Result; break; case NotificationType.reply: result = _msgReplyRepository.queryUserReply(query).Result; break; } //异步更新消息数据 if (query.updateMsgToRead) { Async_MsgToReadAfterQuery(query, result.datas); } return(result == null? new ModelPager <VueMsgInfoNotification>():result); }
public ModelPager <VueSystemNotification> querySystemNotification(QMsgUser query) { ModelPager <VueSystemNotification> result = new ModelPager <VueSystemNotification>(query.pageIndex, query.pageSize); var mainSql = Db.Queryable <EMsgInfo_System, EMsgContent_System>((m, c) => new object[] { JoinType.Left, m.ContentId == c.Id, }) .Where((m, c) => m.ReceiveUserId == query.userId) .OrderBy((m, c) => m.CreatedDateTime, OrderByType.Desc) .Select((m, c) => new VueSystemNotification { dbDateTime = m.CreatedDateTime, htmlContent = c.htmlContent, htmlTitle = c.htmlTitle, NotificationStatus = m.NotificationStatus, msgId = m.Id, contentId = c.Id }); int totalNumber = 0; result.datas = mainSql.ToPageList(query.pageIndex, query.pageSize, ref totalNumber); result.totalCount = totalNumber; return(result); }
public ModelPager <VueSystemNotification> QuerySystemNotifictaion(QMsgUser query) { if (string.IsNullOrEmpty(query.userId)) { throw new CCException("非法请求"); } ModelPager <VueSystemNotification> result = _msgSystemRepository.querySystemNotification(query); if (query.updateMsgToRead) { Async_MsgToReadAfterQuery(query, null, result.datas); } return(result); }
public ResultPager <VueSystemNotification> QuerySystemNotification(QMsgUser query) { ResultPager <VueSystemNotification> result = new ResultPager <VueSystemNotification>(); try { query.userId = this.getUserId(); result.PageData = _messageServices.QuerySystemNotifictaion(query); } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }
//异步方法 查询后获取未读消息转成已读 public void Async_MsgToReadAfterQuery(QMsgUser query, List <VueMsgInfoNotification> queryResult = null, List <VueSystemNotification> systemResult = null //由于系统消息对象不同,暂时只能这样写。。。 ) { Task.Run(() => { try { SubmitUnReadMsgIdList unReadList = new SubmitUnReadMsgIdList(); if (query.notificationType == NotificationType.system) { foreach (var msg in systemResult) { if (msg.NotificationStatus != NotificationStatus.read) { unReadList.msgIdList.Add(msg.msgId); } } } else { foreach (var msg in queryResult) { if (msg.NotificationStatus != NotificationStatus.read) { unReadList.msgIdList.Add(msg.msgId); } } } if (unReadList.msgIdList.Count > 0) { unReadList.notificationType = query.notificationType; unReadList.targetStatus = NotificationStatus.read; unReadList.userId = query.userId; this.updateMsgToRead(unReadList); } } catch (Exception ex) { NLogUtil.cc_ErrorTxt("[MessageService]MsgToReadAfterQuery_Async:" + ex.Message); } }); }