void SetStatusInvitationnForJoinGroupEventModule_After(Invitation sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
     {
         InvitationService invitationService = DIContainer.Resolve <InvitationService>();
         Invitation        invitation        = invitationService.Get(sender.Id);
         if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().InviteJoinGroup() && invitation.Status == InvitationStatus.Accept)
         {
             GroupService groupService = new GroupService();
             GroupMember  member       = GroupMember.New();
             member.GroupId   = sender.RelativeObjectId;
             member.UserId    = sender.UserId;
             member.IsManager = false;
             groupService.CreateGroupMember(member);
         }
         else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Accept)
         {
             GroupService groupService = new GroupService();
             GroupMember  member       = GroupMember.New();
             member.GroupId   = sender.RelativeObjectId;
             member.UserId    = sender.SenderUserId;
             member.IsManager = false;
             groupService.CreateGroupMember(member);
             IEnumerable <long> a = groupService.GetGroupMemberApplies(sender.RelativeObjectId, GroupMemberApplyStatus.Pending, 20, 1).Where(n => n.UserId == sender.SenderUserId).Select(m => m.Id);
             groupService.ApproveGroupMemberApply(a, true);
         }
         else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Refuse)
         {
             GroupService       groupService = new GroupService();
             IEnumerable <long> a            = groupService.GetGroupMemberApplies(sender.RelativeObjectId, GroupMemberApplyStatus.Pending, 20, 1).Where(n => n.UserId == sender.SenderUserId).Select(m => m.Id);
             groupService.ApproveGroupMemberApply(a, false);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 应用初始化
        /// </summary>
        /// <param name="containerBuilder">容器构建器</param>
        public override void Initialize(ContainerBuilder containerBuilder)
        {
            //注册标识图设置
            TenantLogoSettings.RegisterSettings(tenantLogoSettingsElement);

            //注册ResourceAccessor的应用资源
            ResourceAccessor.RegisterApplicationResourceManager(ApplicationId, "Spacebuilder.Group.Resources.Resource", typeof(Spacebuilder.Group.Resources.Resource).Assembly);
            InvitationType.Register(new InvitationType {
                Key = InvitationTypeKeys.Instance().InviteJoinGroup(), Name = "邀请参加群组", Description = ""
            });
            InvitationType.Register(new InvitationType {
                Key = InvitationTypeKeys.Instance().ApplyJoinGroup(), Name = "申请加入群组", Description = ""
            });
            containerBuilder.Register(c => new GroupActivityReceiverGetter()).Named <IActivityReceiverGetter>(ActivityOwnerTypes.Instance().Group().ToString()).SingleInstance();
            //groupId与groupKey的查询器
            containerBuilder.Register(c => new DefaultGroupIdToGroupKeyDictionary()).As <GroupIdToGroupKeyDictionary>().SingleInstance();

            //注册全文检索搜索器
            containerBuilder.Register(c => new GroupSearcher("群组", "~/App_Data/IndexFiles/Group", true, 7)).As <ISearcher>().Named <ISearcher>(GroupSearcher.CODE).SingleInstance();

            ThemeService.RegisterThemeResolver(PresentAreaKeysOfBuiltIn.GroupSpace, new GroupSpaceThemeResolver());

            //群组推荐
            containerBuilder.Register(c => new GroupApplicationStatisticDataGetter()).Named <IApplicationStatisticDataGetter>(this.ApplicationKey).SingleInstance();
            containerBuilder.Register(c => new GroupTenantAuthorizationHandler()).As <ITenantAuthorizationHandler>().SingleInstance();
        }
Esempio n. 3
0
 void SetStatusInvitationnForJoinGroupEventModule_After(Invitation sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
     {
         InvitationService invitationService = DIContainer.Resolve <InvitationService>();
         Invitation        invitation        = invitationService.Get(sender.Id);
         if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().InviteJoinGroup() && invitation.Status == InvitationStatus.Accept)
         {
             GroupService groupService = new GroupService();
             GroupMember  member       = GroupMember.New();
             member.GroupId   = sender.RelativeObjectId;
             member.UserId    = sender.UserId;
             member.IsManager = false;
             groupService.CreateGroupMember(member);
         }
         else if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().ApplyJoinGroup() && invitation.Status == InvitationStatus.Accept)
         {
             GroupService groupService = new GroupService();
             GroupMember  member       = GroupMember.New();
             member.GroupId   = sender.RelativeObjectId;
             member.UserId    = sender.SenderUserId;
             member.IsManager = false;
             groupService.CreateGroupMember(member);
         }
     }
 }
 void SetStatusInvitationEventModule_After(Invitation sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
     {
         InvitationService invitationService = DIContainer.Resolve <InvitationService>();
         Invitation        invitation        = invitationService.Get(sender.Id);
         if (invitation != null && invitation.InvitationTypeKey == InvitationTypeKeys.Instance().InviteFollow() && invitation.Status == InvitationStatus.Accept)
         {
             FollowService followService = new FollowService();
             followService.Follow(invitation.UserId, invitation.SenderUserId);
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 发送加入群组邀请
        /// </summary>
        /// <param name="group"><see cref="GroupEntity"/></param>
        /// <param name="sender">发送人</param>
        /// <param name="userIds">邀请接收人</param>
        /// <param name="remark">附言</param>
        public void SendInvitations(GroupEntity group, IUser sender, string remark, IEnumerable <long> userIds)
        {
            //调用InvitationService的发送请求的方法
            InvitationService invitationService = new InvitationService();

            foreach (var userId in userIds)
            {
                if (!IsMember(group.GroupId, userId))
                {
                    Invitation invitation = Invitation.New();
                    invitation.ApplicationId      = GroupConfig.Instance().ApplicationId;
                    invitation.InvitationTypeKey  = InvitationTypeKeys.Instance().InviteJoinGroup();
                    invitation.UserId             = userId;
                    invitation.SenderUserId       = sender.UserId;
                    invitation.Sender             = sender.DisplayName;
                    invitation.SenderUrl          = SiteUrls.Instance().SpaceHome(sender.UserId);
                    invitation.RelativeObjectId   = group.GroupId;
                    invitation.RelativeObjectName = group.GroupName;
                    invitation.RelativeObjectUrl  = SiteUrls.Instance().GroupHome(group.GroupKey);
                    invitation.Remark             = remark;
                    invitationService.Create(invitation);
                }
            }
        }
        /// <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);
        }