/// <summary>
 /// 专题成员申请实体
 /// </summary>
 public static TopicMemberApply New()
 {
     TopicMemberApply groupMemberApplie = new TopicMemberApply()
     {
         ApplyReason = string.Empty,
         ApplyDate = DateTime.UtcNow
     };
     return groupMemberApplie;
 }
        /// <summary>
        /// 专题成员申请实体
        /// </summary>
        public static TopicMemberApply New()
        {
            TopicMemberApply groupMemberApplie = new TopicMemberApply()
            {
                ApplyReason = string.Empty,
                ApplyDate   = DateTime.UtcNow
            };

            return(groupMemberApplie);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除专题加入申请
        /// </summary>
        /// <param name="id">申请Id</param>
        public void DeleteTopicMemberApply(long id)
        {
            TopicMemberApply apply = TopicMemberApplyRepository.Get(id);

            if (apply == null)
            {
                return;
            }

            int affectCount = TopicMemberApplyRepository.Delete(apply);

            if (affectCount > 0)
            {
                EventBus <TopicMemberApply> .Instance().OnAfter(apply, new CommonEventArgs(EventOperationType.Instance().Delete()));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 申请加入专题
        /// </summary>
        /// <param name="TopicMemberApply">专题加入申请</param>
        public void CreateTopicMemberApply(TopicMemberApply TopicMemberApply)
        {
            //设计要点:
            //1、用户对同一个专题不允许有多个待处理的加入申请


            if (TopicMemberApply == null)
            {
                return;
            }
            if (IsApplied(TopicMemberApply.UserId, TopicMemberApply.TopicId))
            {
                return;
            }
            long id = 0;

            long.TryParse(TopicMemberApplyRepository.Insert(TopicMemberApply).ToString(), out id);

            if (id > 0)
            {
                EventBus <TopicMemberApply> .Instance().OnAfter(TopicMemberApply, new CommonEventArgs(EventOperationType.Instance().Create()));
            }
        }
        /// <summary>
        /// 通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void TopicMemberApplyNoticeModule_After(TopicMemberApply sender, CommonEventArgs eventArgs)
        {
            TopicService groupService = new TopicService();
            TopicEntity entity = groupService.Get(sender.TopicId);
            if (entity == null)
                return;

            User senderUser = DIContainer.Resolve<IUserService>().GetFullUser(sender.UserId);
            if (senderUser == null)
                return;
            InvitationService invitationService = new InvitationService();
            Invitation invitation;
            NoticeService noticeService = DIContainer.Resolve<NoticeService>();
            Notice notice;
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                if (sender.ApplyStatus == TopicMemberApplyStatus.Pending)
                {
                    List<long> toUserIds = new List<long>();
                    toUserIds.Add(entity.UserId);
                    toUserIds.AddRange(entity.TopicManagers.Select(n => n.UserId));
                    foreach (var toUserId in toUserIds)
                    {
                        //申请加入专题的请求
                        if (!groupService.IsMember(sender.TopicId, sender.UserId))
                        {
                            invitation = Invitation.New();
                            invitation.ApplicationId = TopicConfig.Instance().ApplicationId;
                            invitation.InvitationTypeKey = InvitationTypeKeys.Instance().ApplyJoinTopic();
                            invitation.UserId = toUserId;
                            invitation.SenderUserId = sender.UserId;
                            invitation.Sender = senderUser.DisplayName;
                            invitation.SenderUrl = SiteUrls.Instance().SpaceHome(sender.UserId);
                            invitation.RelativeObjectId = sender.TopicId;
                            invitation.RelativeObjectName = entity.TopicName;
                            invitation.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().TopicHome(entity.TopicKey));
                            invitation.Remark = sender.ApplyReason;
                            invitationService.Create(invitation);
                        }
                    }
                }
            }

            string noticeTemplateName = string.Empty;
            if (eventArgs.EventOperationType == EventOperationType.Instance().Approved())
            {
                if (sender.ApplyStatus == TopicMemberApplyStatus.Approved)
                {
                    noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyApproved();
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                if (sender.ApplyStatus == TopicMemberApplyStatus.Disapproved)
                {
                    noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyDisapproved();
                }
            }

            if (string.IsNullOrEmpty(noticeTemplateName))
                return;

            notice = Notice.New();

            notice.UserId = sender.UserId;
            notice.ApplicationId = TopicConfig.Instance().ApplicationId;
            notice.TypeId = NoticeTypeIds.Instance().Hint();
            //notice.LeadingActorUserId = UserContext.CurrentUser.UserId;
            //notice.LeadingActor = UserContext.CurrentUser.DisplayName;
            //notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(UserContext.CurrentUser.UserId));
            notice.RelativeObjectId = sender.TopicId;
            notice.RelativeObjectName = StringUtility.Trim(entity.TopicName, 64);
            notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().TopicHome(entity.TopicKey));
            notice.TemplateName = noticeTemplateName;
            noticeService.Create(notice);
        }
        /// <summary>
        /// 申请加入专题
        /// </summary>
        /// <param name="TopicMemberApply">专题加入申请</param>
        public void CreateTopicMemberApply(TopicMemberApply TopicMemberApply)
        {
            //设计要点:
            //1、用户对同一个专题不允许有多个待处理的加入申请


            if (TopicMemberApply == null)
                return;
            if (IsApplied(TopicMemberApply.UserId, TopicMemberApply.TopicId))
                return;
            long id = 0;
            long.TryParse(TopicMemberApplyRepository.Insert(TopicMemberApply).ToString(), out id);

            if (id > 0)
                EventBus<TopicMemberApply>.Instance().OnAfter(TopicMemberApply, new CommonEventArgs(EventOperationType.Instance().Create()));
        }