public ActionResult _EditApply(long groupId, string applyReason) { StatusMessageData message = null; TopicEntity group = topicService.Get(groupId); if (group == null) { return(Json(new StatusMessageData(StatusMessageType.Error, "找不到专题!"))); } IUser currentUser = UserContext.CurrentUser; if (currentUser == null) { return(Json(new StatusMessageData(StatusMessageType.Error, "您尚未登录!"))); } if (group.JoinWay != TopicJoinWay.ByApply) { return(Json(new StatusMessageData(StatusMessageType.Error, "当前加入方式不是需要申请"))); } //已修改 bool isApplied = topicService.IsApplied(currentUser.UserId, group.TopicId); if (!isApplied) { TopicMemberApply apply = TopicMemberApply.New(); apply.ApplyReason = applyReason; apply.ApplyStatus = TopicMemberApplyStatus.Pending; apply.TopicId = group.TopicId; apply.UserId = UserContext.CurrentUser.UserId; topicService.CreateTopicMemberApply(apply); message = new StatusMessageData(StatusMessageType.Success, "申请已发出,请等待!"); } else { message = new StatusMessageData(StatusMessageType.Hint, "您已给该专题发送过申请!"); } return(Json(message)); }
/// <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); }