private void CreateSystemNoteMessage(MsgSubmitSystem submitSystem) { DbResult <bool> transResult = null; if (submitSystem.systemNoteTarget == SystemNoteTarget.Single) { EMsgInfo_System msg = new EMsgInfo_System { CreatedDateTime = DateTime.Now, ContentId = submitSystem.contentId, ReceiveUserId = submitSystem.receiveUserId, }; transResult = _msgReplyRepository.Db.Ado.UseTran(() => { //新消息 _msgSystemRepository.AddNoIdentity_Sync(msg); //总数 _msgInfoOverviewRepository.UpdateNotificateToUnRead(NotificationType.system, msg.ReceiveUserId); }); } else { List <UserSimple> userList = _userRepository.queryNotificationGroup(submitSystem.receiveGroupId); List <EMsgInfo_System> msgList = new List <EMsgInfo_System>(); foreach (var u in userList) { EMsgInfo_System msg = new EMsgInfo_System { CreatedDateTime = DateTime.Now, ContentId = submitSystem.contentId, ReceiveUserId = u.UserId, }; msgList.Add(msg); } transResult = _msgReplyRepository.Db.Ado.UseTran(() => { //新消息 _msgSystemRepository.AddRange(msgList); //总数 _msgInfoOverviewRepository.UpdateGroupToUnRead(submitSystem.receiveGroupId); }); } if (transResult != null && !transResult.IsSuccess) { throw new Exception(transResult.ErrorMessage); } }
public void CreateNotification_System(MsgSubmitSystem submitSystem) { EMsgContent_System existContent = _msgSystemRepository.GetContentSystem_Sync(submitSystem.contentId); if (existContent == null) { existContent = new EMsgContent_System() { htmlContent = submitSystem.htmlContent, htmlTitle = submitSystem.htmlTitle, Id = submitSystem.contentId }; _msgSystemRepository.AddContentSystem(existContent); } this.CreateSystemNoteMessage(submitSystem); //EMsgInfo_System msg = new EMsgInfo_System(); }
public ResultNormal CreateSystemNotificationToGroup(MsgSubmitSystem submitData) { ResultNormal result = new ResultNormal(); try { var userId = this.getUserId(); if (string.IsNullOrEmpty(userId) || this.getUserAccount() != "jacky") { result.ErrorMsg = "非法发送系统通知"; } else { _messageServices.CreateNotification_System(submitData); } } catch (Exception ex) { result.ErrorMsg = ex.Message; } return(result); }