Exemplo n.º 1
0
        /// <summary>
        /// 修改消息
        /// ================================
        /// 公告
        /// 1. 可以修改的字段有:标题,内容,附件, 状态
        /// ================================
        /// 消息
        /// 2. 可以修改的字段有:标题,内容,附件, 状态
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task UpdateMessage(UpdateMessageInput input)
        {
            var entity = await _manager.MessageRepository.GetAsync(input.Id);

            entity.Title     = input.Title;
            entity.Content   = input.Content;
            entity.FileArray = input.Files;
            entity.Status    = EMessageStatusTypeUtils.GetValue(input.Status);
            await _manager.UpdateAsync(entity);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="Delivery"></param>
        /// <returns></returns>
        public virtual async Task CreateAsync(Delivery entity)
        {
            var homeOwer = await _homeOwerManager.HomeOwerRepository.FirstOrDefaultAsync(entity.HomeOwerId);

            if (homeOwer != null)
            {
                //title
                entity.Title = L("DeliveryTitleString", CultureInfo.CurrentUICulture, homeOwer.Name);
                //content
                entity.Content = L("DeliveryContentString", CultureInfo.CurrentUICulture, entity.Token);

                await DeliveryRepository.InsertAsync(entity);

                //添加消息通知
                var message = new Message(CurrentUnitOfWork.GetTenantId(), L("DeliveryTitleMessage", CultureInfo.CurrentUICulture, homeOwer.Name), L("DeliveryContentMessage", CultureInfo.CurrentUICulture, homeOwer.Name), null, EMessageStatusTypeUtils.GetValue("Sent"), homeOwer.CommunityId, entity.BuildingId, entity.FlatNoId, entity.HomeOwerId, entity.CommunityName, entity.BuildingName, entity.FlatNo);
                await _messageManager.CreateAsync(message);

                var userId      = _abpSession.UserId;
                var currentUser = _userManager.Users.FirstOrDefault(user => user.Id == userId);
                if (currentUser != null)
                {
                    Logger.InfoFormat("Admin {0} Create Delivery {1}", currentUser.UserName, entity.Title);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加信息
        /// ================================
        /// 业主通知:选择具体业主然后添加信息
        /// 1. 记录CommunityId, BuildingId, FlatNoId, HomeOwerId
        /// 2. IsPublic = false
        /// 3. IsRead = false
        /// ================================
        /// 公告:选择单元楼然后添加信息
        /// 1. 记录CommunityId, BuildingId
        /// 2. FlatNoId, HomeOwerId为Null
        /// 3. IsPublic = true
        /// 4. IsRead = null
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task CreateMessage(CreateMessageInput input)
        {
            #region 公告
            if (input.BuildingIds != null)
            {
                foreach (long buildingId in input.BuildingIds)
                {
                    var building = await _buildingManager.BuildingRepository.GetAsync(buildingId);

                    if (building != null)
                    {
                        var entity = new Message(CurrentUnitOfWork.GetTenantId(), input.Title, input.Content, input.FileArray, EMessageStatusTypeUtils.GetValue(input.Status), building.CommunityId, buildingId);
                        await _manager.CreateAsync(entity);
                    }
                }
            }
            #endregion

            #region 消息
            if (input.BuildingIds != null)
            {
                foreach (var homeOwerDto in input.HomeOwerIds)
                {
                    var community = await _communityManager.CommunityRepository.GetAsync(homeOwerDto.CommunityId);

                    var building = await _buildingManager.BuildingRepository.GetAsync(homeOwerDto.BuildingId);

                    var flatNo = await _flatNoManager.FlatNumberRepository.GetAsync(homeOwerDto.FlatNoId);

                    if (community != null && building != null && flatNo != null)
                    {
                        var entity = new Message(CurrentUnitOfWork.GetTenantId(), input.Title, input.Content, input.FileArray, EMessageStatusTypeUtils.GetValue(input.Status), homeOwerDto.CommunityId, homeOwerDto.BuildingId, homeOwerDto.FlatNoId, homeOwerDto.HomeOwerId, community.Name, building.BuildingName, flatNo.FlatNo);
                        await _manager.CreateAsync(entity);
                    }
                }
            }
            #endregion
        }