protected void UpdateNoticeSync(NoticePublishInput input) { var noticemodel = _noticeTextRepository.GetAll().FirstOrDefault(r => r.Id == input.Id); if (noticemodel == null) { throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "数据异常"); } else { noticemodel.Title = input.Title; noticemodel.MsgConent = input.Content; noticemodel.NoticeDepartmentIds = input.NoticeDepartmentIds; noticemodel.NoticeGroupIds = input.NoticeGroupIds; noticemodel.NoticeUserIds = input.NoticeUserIds; _noticeTextRepository.Update(noticemodel); //var logservice = Abp.AbpBootstrapper.Create<Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve<Logapp.ILogAppService>(); //await logservice.CreateOrUpdateLogV2("更新公告", string.Format("更新公告,标题:{0}", input.Title), SystemLogTypes.日常办公.ToString()); } }
public async Task CreateOrUpdateNoticeAsync(NoticePublishInput input) { var userids = new List <long>(); if (string.IsNullOrWhiteSpace(input.NoticeUserIds) == false) { userids.AddRange(Array.ConvertAll(input.NoticeUserIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), new Converter <string, long>(ite => long.Parse(ite)))); } if (string.IsNullOrWhiteSpace(input.NoticeGroupIds) == false) { var groupids = Array.ConvertAll(input.NoticeGroupIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), new Converter <string, Guid>(ite => Guid.Parse(ite))); //var tmpuserids = _projectAuditGroupUserRepository.GetAll().Where(ite => groupids.Contains(ite.GroupId)).Select(ite => ite.UserId).ToList(); //userids.AddRange(tmpuserids); } if (string.IsNullOrWhiteSpace(input.NoticeDepartmentIds) == false) { var govids = Array.ConvertAll(input.NoticeDepartmentIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), new Converter <string, Guid>(ite => Guid.Parse(ite))); foreach (var g in govids) { int count = 0; //var users = _projectBaseRepository.GetUsersWithCurrentAndUnderOrg(g, 100, 1, out count).Select(ite => ite.Id); //userids.AddRange(users); } } if (userids.Count > 0) { userids = userids.Distinct().ToList(); //var onlineClients = _onlineClientManager.GetAllClients().Where(p => p.UserId.HasValue && userids.Contains(p.UserId.Value)).ToList(); //_noticeCommunicator.SendNoticeToClient(onlineClients, null, input.Title, input.Content, link: "Mpa/DailyOfficeNotice"); } if (input.Id.HasValue) { await UpdateNoticeAsync(input); } else { await CreateNotice(input, userids); } }
protected async Task CreateNotice(NoticePublishInput input, List <long> users = null) { if (input.Id.HasValue) { } var userId = AbpSession.GetUserId(); var textId = await _noticeTextRepository.InsertAndGetIdAsync(new NoticeTexts { CreationTime = DateTime.Now, ExpireTime = new DateTime(2099, 09, 09), MsgConent = input.Content, NoticeType = input.NoticeType, ProjectId = null, Title = input.Title, SendUserId = userId, NoticeDepartmentIds = input.NoticeDepartmentIds, NoticeGroupIds = input.NoticeGroupIds, NoticeUserIds = input.NoticeUserIds, NoticeAllUserIds = users == null ? null : string.Join(",", users) }); ///无论什么类型 只要user.count=0 则为全体员工都接收; zcl 2018.8.31 if (users.Count == 0) { await _noticeLogRepository.InsertAsync(new NoticeLogs { TextId = textId, ReceiveId = userId, Status = 1, NoticeType = input.NoticeType, CreationTime = DateTime.Now }); } else { foreach (var item in users) { await _noticeLogRepository.InsertAsync(new NoticeLogs { TextId = textId, ReceiveId = item, Status = 1, NoticeType = input.NoticeType, CreationTime = DateTime.Now }); } } //日志功能暂时屏蔽 //var logservice = Abp.AbpBootstrapper.Create<Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve<Logapp.ILogAppService>(); //await logservice.CreateOrUpdateLogV2("发布公告", string.Format("发布公告,标题:{0}", input.Title), SystemLogTypes.日常办公.ToString()); await CurrentUnitOfWork.SaveChangesAsync(); var onlineClients = new List <IOnlineClient>(); if (users.Count > 0) { onlineClients = _onlineClientManager.GetAllClients().Where(p => p.UserId.HasValue && p.UserId.Value != userId && users.Contains(p.UserId.Value)).ToList(); } else { onlineClients = _onlineClientManager.GetAllClients().Where(p => p.UserId.HasValue && p.UserId.Value != userId).ToList(); } _noticeCommunicator.SendNoticeToClient(onlineClients, null, input.Title, string.Empty); }