/// <summary> /// 动态处理程序 /// </summary> /// <param name="groupMember"></param> /// <param name="eventArgs"></param> private void GroupMemberActivityModule_After(GroupMember groupMember, CommonEventArgs eventArgs) { ActivityService activityService = new ActivityService(); if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { //生成动态 if (groupMember == null) { return; } var group = new GroupService().Get(groupMember.GroupId); if (group == null) { return; } //生成Owner为群组的动态 Activity actvityOfGroup = Activity.New(); actvityOfGroup.ActivityItemKey = ActivityItemKeys.Instance().CreateGroupMember(); actvityOfGroup.ApplicationId = GroupConfig.Instance().ApplicationId; actvityOfGroup.IsOriginalThread = true; actvityOfGroup.IsPrivate = !group.IsPublic; actvityOfGroup.UserId = groupMember.UserId; actvityOfGroup.ReferenceId = group.GroupId; actvityOfGroup.ReferenceTenantTypeId = TenantTypeIds.Instance().Group(); actvityOfGroup.SourceId = groupMember.UserId; actvityOfGroup.TenantTypeId = TenantTypeIds.Instance().User(); actvityOfGroup.OwnerId = group.GroupId; actvityOfGroup.OwnerName = group.GroupName; actvityOfGroup.OwnerType = ActivityOwnerTypes.Instance().Group(); activityService.Generate(actvityOfGroup, false); //生成Owner为用户的动态 Activity actvityOfUser = Activity.New(); actvityOfUser.ActivityItemKey = ActivityItemKeys.Instance().JoinGroup(); actvityOfUser.ApplicationId = actvityOfGroup.ApplicationId; actvityOfUser.HasImage = actvityOfGroup.HasImage; actvityOfUser.HasMusic = actvityOfGroup.HasMusic; actvityOfUser.HasVideo = actvityOfGroup.HasVideo; actvityOfUser.IsOriginalThread = actvityOfGroup.IsOriginalThread; actvityOfUser.IsPrivate = actvityOfGroup.IsPrivate; actvityOfUser.UserId = actvityOfGroup.UserId; actvityOfUser.ReferenceId = actvityOfGroup.ReferenceId; actvityOfGroup.ReferenceTenantTypeId = actvityOfGroup.ReferenceTenantTypeId; actvityOfUser.SourceId = actvityOfGroup.SourceId; actvityOfUser.TenantTypeId = actvityOfGroup.TenantTypeId; actvityOfUser.OwnerId = groupMember.UserId; actvityOfUser.OwnerName = groupMember.User.DisplayName; actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(actvityOfUser, false); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) //删除动态 { activityService.DeleteSource(TenantTypeIds.Instance().User(), groupMember.UserId); } }
/// <summary> /// 设置/取消管理员通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void SetManagerNoticeEventModule_After(GroupMember sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType != EventOperationType.Instance().SetGroupManager() && eventArgs.EventOperationType != EventOperationType.Instance().CancelGroupManager()) { return; } GroupService groupService = new GroupService(); GroupEntity entity = groupService.Get(sender.GroupId); if (entity == null) { return; } User senderUser = DIContainer.Resolve <IUserService>().GetFullUser(sender.UserId); if (senderUser == null) { return; } NoticeService noticeService = DIContainer.Resolve <NoticeService>(); Notice notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActorUserId = 0; notice.LeadingActor = string.Empty; notice.LeadingActorUrl = string.Empty; notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); if (eventArgs.EventOperationType == EventOperationType.Instance().SetGroupManager()) { notice.TemplateName = NoticeTemplateNames.Instance().SetGroupManager(); } else { notice.TemplateName = NoticeTemplateNames.Instance().CannelGroupManager(); } noticeService.Create(notice); }
/// <summary> /// 群组操作文章事件处理 /// </summary> private void GroupOperationLogEventModule_After(GroupEntity senders, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() || eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved() || eventArgs.EventOperationType == EventOperationType.Instance().SetEssential() || eventArgs.EventOperationType == EventOperationType.Instance().SetSticky() || eventArgs.EventOperationType == EventOperationType.Instance().CancelEssential() || eventArgs.EventOperationType == EventOperationType.Instance().CancelSticky()) { OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo); entry.ApplicationId = entry.ApplicationId; entry.Source = GroupConfig.Instance().ApplicationName; entry.OperationType = eventArgs.EventOperationType; entry.OperationObjectName = senders.GroupName; entry.OperationObjectId = senders.GroupId; entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType, entry.ApplicationId), "群组", entry.OperationObjectName); OperationLogService logService = Tunynet.DIContainer.Resolve <OperationLogService>(); logService.Create(entry); } }
/// <summary> /// 动态处理程序 /// </summary> /// <param name="group"></param> /// <param name="eventArgs"></param> private void GroupEntityActivityModule_After(GroupEntity group, AuditEventArgs eventArgs) { //生成动态 ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //生成动态 { if (group == null) { return; } //生成Owner为用户的动态 Activity actvityOfBar = Activity.New(); actvityOfBar.ActivityItemKey = ActivityItemKeys.Instance().CreateGroup(); actvityOfBar.ApplicationId = GroupConfig.Instance().ApplicationId; actvityOfBar.IsOriginalThread = true; actvityOfBar.IsPrivate = !group.IsPublic; actvityOfBar.UserId = group.UserId; actvityOfBar.ReferenceId = 0;//没有涉及到的实体 actvityOfBar.ReferenceTenantTypeId = string.Empty; actvityOfBar.SourceId = group.GroupId; actvityOfBar.TenantTypeId = TenantTypeIds.Instance().Group(); actvityOfBar.OwnerId = group.UserId; actvityOfBar.OwnerName = group.User.DisplayName; actvityOfBar.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(actvityOfBar, true); } else if (auditDirection == false) //删除动态 { activityService.DeleteSource(TenantTypeIds.Instance().Group(), group.GroupId); } }
public ActionResult UserCreatedGroups(string spaceKey) { string title = "我创建的群组"; IUserService userService = DIContainer.Resolve <IUserService>(); User spaceUser = userService.GetFullUser(spaceKey); if (spaceUser == null) { return(HttpNotFound()); } bool ignoreAudit = false; var currentUser = UserContext.CurrentUser; if (currentUser != null) { if (currentUser.UserId == spaceUser.UserId || new Authorizer().IsAdministrator(GroupConfig.Instance().ApplicationId)) { ignoreAudit = true; } if (currentUser.UserId != spaceUser.UserId) { title = spaceUser.DisplayName + "创建的群组"; } } else { title = spaceUser.DisplayName + "创建的群组"; } pageResourceManager.InsertTitlePart(title); var groups = groupService.GetMyCreatedGroups(spaceUser.UserId, ignoreAudit); if (Request.IsAjaxRequest()) { return(PartialView("_List", groups)); } ViewData["spaceUser"] = spaceUser; ViewData["currentUser"] = currentUser; return(View(groups)); }
/// <summary> /// 通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void GroupMemberNoticeModule_After(GroupMember sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType != EventOperationType.Instance().Delete() && eventArgs.EventOperationType != EventOperationType.Instance().Create() && sender != null) { return; } GroupService groupService = new GroupService(); GroupEntity entity = groupService.Get(sender.GroupId); if (entity == null) { return; } User senderUser = DIContainer.Resolve <IUserService>().GetFullUser(sender.UserId); if (senderUser == null) { return; } NoticeService noticeService = DIContainer.Resolve <NoticeService>(); Notice notice; List <long> toUserIds = new List <long>(); toUserIds.Add(entity.UserId); toUserIds.AddRange(entity.GroupManagers.Select(n => n.UserId)); //删除群组成员通知群管理员 if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { foreach (var toUserId in toUserIds) { if (toUserId == sender.UserId) { continue; } notice = Notice.New(); notice.UserId = toUserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActorUserId = sender.UserId; notice.LeadingActor = senderUser.DisplayName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); notice.TemplateName = NoticeTemplateNames.Instance().MemberQuit(); noticeService.Create(notice); } } else if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) //添加群成员时向群管理员发送通知 { foreach (var toUserId in toUserIds) { if (toUserId == sender.UserId) { continue; } notice = Notice.New(); notice.UserId = toUserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActorUserId = sender.UserId; notice.LeadingActor = senderUser.DisplayName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); notice.TemplateName = NoticeTemplateNames.Instance().MemberJoin(); noticeService.Create(notice); } //向加入者发送通知 notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = GroupConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActorUserId = sender.UserId; notice.LeadingActor = senderUser.DisplayName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); notice.RelativeObjectId = sender.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); notice.TemplateName = NoticeTemplateNames.Instance().MemberApplyApproved(); noticeService.Create(notice); } }
/// <summary> /// 通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void GroupMemberApplyNoticeModule_After(GroupMemberApply sender, CommonEventArgs eventArgs) { GroupService groupService = new GroupService(); GroupEntity entity = groupService.Get(sender.GroupId); 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 == GroupMemberApplyStatus.Pending) { List <long> toUserIds = new List <long>(); toUserIds.Add(entity.UserId); toUserIds.AddRange(entity.GroupManagers.Select(n => n.UserId)); foreach (var toUserId in toUserIds) { //申请加入群组的请求 if (!groupService.IsMember(sender.GroupId, sender.UserId)) { invitation = Invitation.New(); invitation.ApplicationId = GroupConfig.Instance().ApplicationId; invitation.InvitationTypeKey = InvitationTypeKeys.Instance().ApplyJoinGroup(); invitation.UserId = toUserId; invitation.SenderUserId = sender.UserId; invitation.Sender = senderUser.DisplayName; invitation.SenderUrl = SiteUrls.Instance().SpaceHome(sender.UserId); invitation.RelativeObjectId = sender.GroupId; invitation.RelativeObjectName = entity.GroupName; invitation.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); invitation.Remark = sender.ApplyReason; invitationService.Create(invitation); } } } } string noticeTemplateName = string.Empty; if (eventArgs.EventOperationType == EventOperationType.Instance().Approved()) { if (sender.ApplyStatus == GroupMemberApplyStatus.Approved) { noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyApproved(); } } else if (eventArgs.EventOperationType == EventOperationType.Instance().Disapproved()) { if (sender.ApplyStatus == GroupMemberApplyStatus.Disapproved) { noticeTemplateName = NoticeTemplateNames.Instance().MemberApplyDisapproved(); } } if (string.IsNullOrEmpty(noticeTemplateName)) { return; } notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = GroupConfig.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.GroupId; notice.RelativeObjectName = StringUtility.Trim(entity.GroupName, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().GroupHome(entity.GroupKey)); notice.TemplateName = noticeTemplateName; noticeService.Create(notice); }