コード例 #1
0
ファイル: CmsEventModule.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ContentItemNoticeModule_After(ContentItem sender, AuditEventArgs eventArgs)
        {
            AuditService auditService   = new AuditService();
            bool?        auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true)
            {
                long toUserId = sender.UserId;

                NoticeService noticeService = Tunynet.DIContainer.Resolve <NoticeService>();
                Notice        notice        = Notice.New();

                notice.UserId             = toUserId;
                notice.ApplicationId      = CmsConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Manage();
                notice.LeadingActorUserId = sender.UserId;
                notice.LeadingActor       = sender.Author;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId));
                notice.RelativeObjectId   = sender.ContentItemId;
                notice.RelativeObjectName = sender.Title;
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().ContentItemDetail(sender.ContentItemId));
                notice.TemplateName       = NoticeTemplateNames.Instance().ContributeAccepted();
                noticeService.Create(notice);
            }
        }
コード例 #2
0
        void UserInRole_BatchAfter(IEnumerable <UserInRole> sender, CommonEventArgs eventArgs)
        {
            if (sender == null || sender.Count() == 0)
            {
                return;
            }
            NoticeService noticeService = Tunynet.DIContainer.Resolve <NoticeService>();
            RoleService   roleService   = new RoleService();
            Notice        notice        = Notice.New();

            notice.UserId       = sender.First().UserId;
            notice.TypeId       = NoticeTypeIds.Instance().Hint();
            notice.TemplateName = "RolesChanged";
            List <Role> roles = new List <Role>();

            foreach (var s in sender)
            {
                var role = roleService.Get(s.RoleName);
                if (role == null)
                {
                    continue;
                }
                roles.Add(role);
            }
            notice.RelativeObjectName = string.Join("、", roles.Select(n => n.FriendlyRoleName));
            noticeService.Create(notice);
        }
コード例 #3
0
        /// <summary>
        /// 处理加精操作加积分
        /// </summary>
        /// <param name="blogThread">日志</param>
        /// <param name="eventArgs">事件</param>
        private void BlogThreadPointModuleForManagerOperation_After(BlogThread blogThread, CommonEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();
            string        pointItemKey  = string.Empty;

            if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential())
            {
                pointItemKey = PointItemKeys.Instance().EssentialContent();

                PointService pointService = new PointService();
                string       description  = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "日志", blogThread.ResolvedSubject);
                pointService.GenerateByRole(blogThread.UserId, pointItemKey, description);
                if (blogThread.UserId > 0)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = blogThread.UserId;
                    notice.ApplicationId      = BlogConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = blogThread.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(blogThread.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(blogThread.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().BlogDetail(blogThread.User.UserName, blogThread.ThreadId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().ManagerSetEssential();
                    noticeService.Create(notice);
                }
            }
        }
コード例 #4
0
ファイル: PhotoEventModule.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 照片圈人通知
        /// </summary>
        /// <param name="photoLabel"></param>
        /// <param name="eventArgs"></param>
        public void PhotoLabelNotice_After(PhotoLabel photoLabel, CommonEventArgs eventArgs)
        {
            if (photoLabel.Photo == null)
            {
                return;
            }
            //圈人的操作人
            IUser user = DIContainer.Resolve <UserService>().GetUser(photoLabel.UserId);

            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //排除掉照片主人自己
                if (photoLabel.UserId == photoLabel.Photo.UserId)
                {
                    return;
                }
                //通知照片作者
                Notice notice = Notice.New();
                notice.UserId             = photoLabel.Photo.UserId;
                notice.ApplicationId      = PhotoConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Hint();
                notice.LeadingActor       = user.DisplayName;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().Home(user.UserName));
                notice.RelativeObjectName = photoLabel.Photo.Description;
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().PhotoDetail(photoLabel.Photo.PhotoId));
                notice.TemplateName       = NoticeTemplateNames.Instance().PhotoLabelNotice();
                noticeService.Create(notice);
            }
        }
コード例 #5
0
ファイル: UserEventModule.cs プロジェクト: x1987624/SNS
        private void RewardAndPunishmentUser_After(IUser sender, RewardAndPunishmentUserEventArgs eventArgs)
        {
            PointSettings pointSettings = pointSettingsManger.Get();
            int           totalPoints   = pointSettings.CalculateIntegratedPoint(sender.ExperiencePoints, sender.ReputationPoints);

            //更新用户等级
            //if (eventArgs.ExperiencePoints <= 0 && eventArgs.ReputationPoints <= 0)
            //    return;
            IUserService               userService     = DIContainer.Resolve <IUserService>();
            UserRankService            userRankService = new UserRankService();
            SortedList <int, UserRank> userRanks       = userRankService.GetAll();
            UserRank maxUserRank = null;

            if (userRanks != null && userRanks.Count > 0)
            {
                maxUserRank = userRanks.First().Value;
            }
            foreach (KeyValuePair <int, UserRank> userRank in userRanks)
            {
                if (totalPoints > userRank.Value.PointLower && userRank.Value.PointLower > maxUserRank.PointLower)
                {
                    maxUserRank = userRank.Value;
                }
            }
            userService.UpdateRank(sender.UserId, maxUserRank.Rank);

            //自动解除管制
            var user = userService.GetFullUser(sender.UserId);

            if (user.IsModerated && !user.IsForceModerated)
            {
                UserSettings userSettings = userSettingsManager.Get();
                if (totalPoints > userSettings.NoModeratedUserPoint)
                {
                    userService.NoModeratedUser(user.UserId);
                }
            }

            //发送通知
            if (sender == null)
            {
                return;
            }
            Notice notice = Notice.New();

            notice.UserId        = sender.UserId;
            notice.ApplicationId = 0;
            notice.TypeId        = NoticeTypeIds.Instance().Hint();
            if (eventArgs.ExperiencePoints < 0 || eventArgs.ReputationPoints < 0 || eventArgs.TradePoints < 0)
            {
                notice.Body = "您被系统扣除经验:" + -eventArgs.ExperiencePoints + "、威望:" + -eventArgs.ReputationPoints + "、金币:" + -eventArgs.TradePoints;
            }
            else
            {
                notice.Body = "您收到系统奖励经验:" + eventArgs.ExperiencePoints + "、威望:" + eventArgs.ReputationPoints + "、金币:" + eventArgs.TradePoints;
            }
            notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().ListNotices(sender.UserName, null, null));
            noticeService.Create(notice);
        }
コード例 #6
0
ファイル: PointMallEventModule.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 兑换商品时处理积分,动态
        /// </summary>
        /// <param name="record">兑换申请</param>
        /// <param name="eventArgs"></param>
        public void RecordAcitivityEventModule_After(PointGiftExchangeRecord record, CommonEventArgs eventArgs)
        {
            //生成动态
            ActivityService activityService = new ActivityService();

            if (eventArgs.EventOperationType == EventOperationType.Instance().Approved())
            {
                //初始化Owner为用户的动态
                Activity activity = Activity.New();
                activity.ActivityItemKey       = ActivityItemKeys.Instance().ExchangeGift();
                activity.ApplicationId         = PointMallConfig.Instance().ApplicationId;
                activity.HasImage              = true;
                activity.HasMusic              = false;
                activity.HasVideo              = false;
                activity.IsOriginalThread      = true;
                activity.IsPrivate             = false;
                activity.UserId                = record.PayerUserId;
                activity.ReferenceId           = record.GiftId;
                activity.ReferenceTenantTypeId = TenantTypeIds.Instance().PointGift();
                activity.SourceId              = record.RecordId;
                activity.TenantTypeId          = TenantTypeIds.Instance().PointGiftExchangeRecord();
                activity.OwnerId               = record.PayerUserId;
                activity.OwnerName             = record.Payer;
                activity.OwnerType             = ActivityOwnerTypes.Instance().User();

                activityService.Generate(activity, true);

                //通知
                Notice notice = Notice.New();
                notice.UserId             = record.PayerUserId;
                notice.ApplicationId      = PointMallConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Hint();
                notice.LeadingActor       = record.Payer;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(record.PayerUserId));
                notice.RelativeObjectName = record.GiftName;
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().GiftDetail(record.GiftId));
                notice.TemplateName       = NoticeTemplateNames.Instance().ApplyRecord();
                noticeService.Create(notice);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                //通知
                Notice notice = Notice.New();
                notice.UserId             = record.PayerUserId;
                notice.ApplicationId      = PointMallConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Hint();
                notice.LeadingActor       = record.Payer;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(record.PayerUserId));
                notice.RelativeObjectName = record.GiftName;
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().GiftDetail(record.GiftId));
                notice.TemplateName       = NoticeTemplateNames.Instance().CancelRecord();
                noticeService.Create(notice);
            }
        }
コード例 #7
0
        /// <summary>
        /// 通知处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        void CommentNoticeEventModule_After(Comment sender, AuditEventArgs eventArgs)
        {
            AuditService auditService   = new AuditService();
            bool?        auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true)
            {
                var urlGetter       = CommentUrlGetterFactory.Get(sender.TenantTypeId);
                var commentedObject = urlGetter.GetCommentedObject(sender.CommentedObjectId);
                var senderUser      = sender.User();
                if (urlGetter == null || commentedObject == null)
                {
                    return;
                }
                //文章有新评论时,自动通知原作者
                var toUserIds = new List <long>();
                //评论相关的atuserid
                List <long> userids = new AtUserService(TenantTypeIds.Instance().Comment()).GetAtUserIds(sender.Id);

                if (!userids.Contains(commentedObject.UserId))
                {
                    toUserIds.Add(commentedObject.UserId);
                }

                if (sender.ParentId > 0 && !userids.Contains(sender.ToUserId))
                {
                    toUserIds.Add(sender.ToUserId);
                }

                foreach (var toUserId in toUserIds)
                {
                    //通知的对象排除掉自己
                    if (toUserId == sender.UserId)
                    {
                        continue;
                    }


                    Notice notice = Notice.New();
                    notice.UserId          = toUserId;
                    notice.ApplicationId   = 0;
                    notice.TypeId          = NoticeTypeIds.Instance().Reply();
                    notice.LeadingActor    = senderUser != null ? senderUser.DisplayName : "匿名用户";
                    notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(UserIdToUserNameDictionary.GetUserName(sender.UserId)));

                    notice.RelativeObjectName = StringUtility.Trim(commentedObject.Name, 60);
                    notice.RelativeObjectId   = sender.Id;
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(urlGetter.GetCommentDetailUrl(sender.CommentedObjectId, sender.Id, commentedObject.UserId)) ?? string.Empty;
                    notice.TemplateName       = sender.ParentId > 0 ? NoticeTemplateNames.Instance().NewReply() : NoticeTemplateNames.Instance().NewComment();
                    new NoticeService().Create(notice);
                }
            }
        }
コード例 #8
0
ファイル: BarThreadEventModule.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 处理加精、置顶等操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void BarThreadPointModuleForManagerOperation_After(BarThread sender, CommonEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();

            if (eventArgs.OperatorInfo == null)
            {
                return;
            }
            string pointItemKey = string.Empty;

            if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential())
            {
                pointItemKey = PointItemKeys.Instance().EssentialContent();
                if (sender.UserId > 0 && sender.UserId != eventArgs.OperatorInfo.OperatorUserId)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = sender.UserId;
                    notice.ApplicationId      = BarConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = sender.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(sender.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetail(sender.ThreadId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().ManagerSetEssential();
                    noticeService.Create(notice);
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().SetSticky())
            {
                pointItemKey = PointItemKeys.Instance().StickyContent();
                if (sender.UserId > 0 && sender.UserId != eventArgs.OperatorInfo.OperatorUserId)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = sender.UserId;
                    notice.ApplicationId      = BarConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = sender.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(sender.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetail(sender.ThreadId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().ManagerSetSticky();
                    noticeService.Create(notice);
                }
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                PointService pointService = new PointService();
                string       description  = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "帖子", sender.Subject);
                pointService.GenerateByRole(sender.UserId, pointItemKey, description);
            }
        }
コード例 #9
0
        /// <summary>
        /// 通知处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void BarPostNoticeModule_After(BarPost sender, AuditEventArgs eventArgs)
        {
            AuditService auditService   = new AuditService();
            bool?        auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //创建回帖发通知
            {
                BarThreadService barThreadService = new BarThreadService();
                BarThread        barThread        = barThreadService.Get(sender.ThreadId);
                if (barThread == null)
                {
                    return;
                }

                long toUserId = barThread.UserId;

                //自己给自己的帖子进行回帖,不必通知
                if (sender.UserId == barThread.UserId)
                {
                    return;
                }

                if (sender.ParentId > 0)
                {
                    BarPostService barPostService = new BarPostService();
                    BarPost        parentPost     = barPostService.Get(sender.ParentId);

                    if (parentPost == null || (parentPost.UserId == sender.UserId))
                    {
                        return;
                    }
                    toUserId = parentPost.UserId;
                }

                NoticeService noticeService = Tunynet.DIContainer.Resolve <NoticeService>();
                Notice        notice        = Notice.New();

                notice.UserId             = toUserId;
                notice.ApplicationId      = BarConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Reply();
                notice.LeadingActorUserId = sender.UserId;
                notice.LeadingActor       = sender.Author;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId));
                notice.RelativeObjectId   = sender.PostId;
                notice.RelativeObjectName = HtmlUtility.TrimHtml(barThread.Subject, 64);
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetailGotoPost(sender.PostId));
                notice.TemplateName       = NoticeTemplateNames.Instance().NewReply();
                noticeService.Create(notice);
            }
        }
コード例 #10
0
ファイル: RegisterEventModule.cs プロジェクト: x1987624/SNS
 void NoEmailNotice(User sender, CreateUserEventArgs eventArgs)
 {
     if (string.IsNullOrEmpty(sender.AccountEmail))
     {
         NoticeService noticeService = new NoticeService();
         Notice        notice        = Notice.New();
         notice.TemplateName    = "NoEmailNotice";
         notice.TypeId          = NoticeTypeIds.Instance().Hint();
         notice.LeadingActorUrl = SiteUrls.Instance().EditUserProfile(sender.UserName);
         notice.UserId          = sender.UserId;
         notice.Status          = NoticeStatus.Unhandled;
         noticeService.Create(notice);
     }
 }
コード例 #11
0
ファイル: UserEventModule.cs プロジェクト: x1987624/SNS
 /// <summary>
 /// 首次上传头像加分
 /// </summary>
 /// <param name="sender">用户实体</param>
 /// <param name="eventArgs">事件参数</param>
 public void AutoNoModeratedUserNoticeEventModule_After(User sender, CommonEventArgs eventArgs)
 {
     if (eventArgs.EventOperationType == EventOperationType.Instance().AutoNoModeratedUser())
     {
         Notice notice = Notice.New();
         notice.UserId             = sender.UserId;
         notice.ApplicationId      = 0;
         notice.TypeId             = NoticeTypeIds.Instance().Hint();
         notice.TemplateName       = "AutoNoModeratedUser";
         notice.RelativeObjectName = "我的权限";
         notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().UserModerated(sender.UserName));
         notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().ListNotices(sender.UserName, null, null));
         noticeService.Create(notice);
     }
 }
コード例 #12
0
        /// <summary>
        /// 推荐积分处理
        /// </summary>
        /// <param name="sender">推荐实体</param>
        /// <param name="eventArgs">事件参数</param>
        void RecommendPointModule_After(RecommendItem sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType != EventOperationType.Instance().Create())
            {
                return;
            }
            string            pointItemKey      = string.Empty;
            PointService      pointService      = new PointService();
            string            description       = string.Empty;
            TenantTypeService tenantTypeService = new TenantTypeService();

            var urlGetter = RecommendUrlGetterFactory.Get(sender.TenantTypeId);

            NoticeService noticeService = new NoticeService();
            Notice        notice        = Notice.New();

            notice.TypeId = NoticeTypeIds.Instance().Hint();

            //notice.TemplateName = "FollowUser";
            notice.UserId             = sender.UserId;
            notice.LeadingActorUserId = sender.ReferrerId;
            notice.LeadingActor       = sender.ReferrerName;
            notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.ReferrerId));
            notice.RelativeObjectId   = sender.UserId;
            notice.RelativeObjectName = sender.ItemName;
            notice.RelativeObjectUrl  = sender.DetailUrl;

            if (sender.TenantTypeId == TenantTypeIds.Instance().User())
            {
                pointItemKey        = PointItemKeys.Instance().RecommendUser();
                description         = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendUser"));
                notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommendedUser();
            }
            else
            {
                pointItemKey = PointItemKeys.Instance().RecommendContent();
                TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId);
                if (tenantType == null)
                {
                    return;
                }
                description         = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendContent"), tenantType.Name, sender.ItemName);
                notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommended();
            }

            noticeService.Create(notice);
            pointService.GenerateByRole(sender.UserId, pointItemKey, description);
        }
コード例 #13
0
ファイル: FollowEventModule.cs プロジェクト: yaotyl/spb4mono
        /// <summary>
        /// 生成通知
        /// </summary>
        /// <param name="sender">关注实体</param>
        /// <param name="eventArgs">事件参数</param>
        void FollowNoticeModule_After(FollowEntity sender, CommonEventArgs eventArgs)
        {
            if (EventOperationType.Instance().Create() == eventArgs.EventOperationType)
            {
                if (sender.IsQuietly)
                {
                    return;
                }
                IUserService userService = DIContainer.Resolve <IUserService>();

                //关注用户
                IUser user = userService.GetUser(sender.UserId);
                if (user == null)
                {
                    return;
                }

                IUser followedUser = userService.GetUser(sender.FollowedUserId);
                if (followedUser == null)
                {
                    return;
                }

                NoticeService service = new NoticeService();
                Notice        notice  = Notice.New();
                notice.TypeId             = NoticeTypeIds.Instance().Hint();
                notice.TemplateName       = "FollowUser";
                notice.UserId             = followedUser.UserId;
                notice.LeadingActorUserId = user.UserId;
                notice.LeadingActor       = user.DisplayName;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(user.UserName));
                notice.RelativeObjectId   = followedUser.UserId;
                notice.RelativeObjectName = followedUser.DisplayName;
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(followedUser.UserName));

                service.Create(notice);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                NoticeService        service = new NoticeService();
                IEnumerable <Notice> notices = service.GetTops(sender.FollowedUserId, 20).Where(n => n.TemplateName == "FollowUser").Where(n => n.LeadingActorUserId == sender.UserId);
                foreach (var notice in notices)
                {
                    service.Delete(notice.Id);
                }
            }
        }
コード例 #14
0
        /// <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);
        }
コード例 #15
0
        /// <summary>
        /// 帖吧申请处理结果通知
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        void BarSectionNoticeEventModule_After(BarSection sender, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Approved() || eventArgs.EventOperationType == EventOperationType.Instance().Disapproved())
            {
                IUserService  userService   = DIContainer.Resolve <IUserService>();
                NoticeService noticeService = DIContainer.Resolve <NoticeService>();
                User          toUser        = userService.GetFullUser(sender.UserId);
                if (toUser == null)
                {
                    return;
                }
                Notice notice = Notice.New();
                notice.UserId             = sender.UserId;
                notice.ApplicationId      = BarConfig.Instance().ApplicationId;
                notice.TypeId             = NoticeTypeIds.Instance().Reply();
                notice.LeadingActorUserId = sender.UserId;
                notice.LeadingActor       = toUser.DisplayName;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(toUser.UserName));
                notice.RelativeObjectId   = sender.SectionId;
                notice.RelativeObjectName = HtmlUtility.TrimHtml(sender.Name, 64);
                if (eventArgs.EventOperationType == EventOperationType.Instance().Approved())
                {
                    //通知吧主,其申请的帖吧通过了审核
                    notice.TemplateName = NoticeTemplateNames.Instance().ManagerApproved();
                }
                else
                {
                    //通知吧主,其申请的帖吧未通过审核
                    notice.TemplateName = NoticeTemplateNames.Instance().ManagerDisapproved();
                }

                notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().SectionDetail(sender.SectionId));
                noticeService.Create(notice);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                SubscribeService   subscribeService = new SubscribeService(TenantTypeIds.Instance().BarSection());
                IEnumerable <long> userIds          = subscribeService.GetTopUserIdsOfObject(sender.SectionId, int.MaxValue);

                foreach (long userId in userIds)
                {
                    subscribeService.CancelSubscribe(sender.SectionId, userId);
                }
            }
        }
コード例 #16
0
        void UserInRole_After(UserInRole sender, CommonEventArgs eventArgs)
        {
            RoleService roleService = new RoleService();
            var         role        = roleService.Get(sender.RoleName);

            if (role == null)
            {
                return;
            }
            NoticeService noticeService = Tunynet.DIContainer.Resolve <NoticeService>();
            Notice        notice        = Notice.New();

            notice.UserId             = sender.UserId;
            notice.TypeId             = NoticeTypeIds.Instance().Hint();
            notice.TemplateName       = "RoleAdd";
            notice.RelativeObjectName = role.FriendlyRoleName;
            noticeService.Create(notice);
        }
コード例 #17
0
ファイル: AtUserEventModule.cs プロジェクト: yaotyl/spb4mono
        /// <summary>
        /// At用户通知
        /// </summary>
        /// <param name="sender">用户名集合</param>
        /// <param name="eventArgs">事件参数</param>
        private void AtUserNoticeEventModule_After(IEnumerable <long> sender, AtUserEventArgs eventArgs)
        {
            if (sender.Count() == 0)
            {
                return;
            }

            NoticeService service     = new NoticeService();
            IUserService  userService = DIContainer.Resolve <IUserService>();

            User eventArgsUser = userService.GetFullUser(eventArgs.UserId);

            foreach (var userId in sender)
            {
                //关注用户
                IUser user = userService.GetUser(userId);
                if (user == null || user.UserId == eventArgs.UserId)
                {
                    continue;
                }

                IAtUserAssociatedUrlGetter urlGetter = AtUserAssociatedUrlGetterFactory.Get(eventArgs.TenantTypeId);
                if (urlGetter == null)
                {
                    continue;
                }
                AssociatedInfo ai = urlGetter.GetAssociatedInfo(eventArgs.AssociateId);

                Notice notice = Notice.New();
                notice.TypeId             = NoticeTypeIds.Instance().Hint();
                notice.UserId             = user.UserId;
                notice.LeadingActorUserId = eventArgs.UserId;
                notice.LeadingActor       = eventArgsUser.DisplayName;
                notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(eventArgs.UserId));
                notice.RelativeObjectId   = eventArgs.AssociateId;
                notice.RelativeObjectName = HtmlUtility.TrimHtml(ai.Subject, 12);
                notice.RelativeObjectUrl  = SiteUrls.FullUrl(ai.DetailUrl);
                notice.Owner        = urlGetter.GetOwner();
                notice.TemplateName = "AtUser";

                service.Create(notice);
            }
        }
コード例 #18
0
ファイル: CmsEventModule.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 处理置顶操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ContentItemPointModuleForManagerOperation_After(ContentItem sender, CommonEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();
            string        pointItemKey  = string.Empty;

            if (eventArgs.EventOperationType == EventOperationType.Instance().SetGlobalSticky() || eventArgs.EventOperationType == EventOperationType.Instance().SetFolderSticky())
            {
                pointItemKey = PointItemKeys.Instance().CMS_StickyNews();
                if (sender.UserId > 0)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = sender.UserId;
                    notice.ApplicationId      = CmsConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = sender.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId));
                    notice.RelativeObjectName = sender.Title;
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().ContentItemDetail(sender.ContentItemId));
                    if (eventArgs.EventOperationType == EventOperationType.Instance().SetGlobalSticky())
                    {
                        notice.TemplateName = NoticeTemplateNames.Instance().ContributeGlobalStickied();
                    }
                    else
                    {
                        notice.TemplateName = NoticeTemplateNames.Instance().ContributeFolderStickied();
                    }
                    noticeService.Create(notice);
                }
            }

            if (!string.IsNullOrEmpty(pointItemKey))
            {
                PointService pointService = new PointService();
                string       description  = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "资讯", sender.Title);
                pointService.GenerateByRole(sender.UserId, pointItemKey, description);
            }
        }
コード例 #19
0
        /// <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);
            }
        }
コード例 #20
0
        /// <summary>
        /// 问题增删改等触发的事件
        /// </summary>
        private void AskQuestionEventModule_After(AskQuestion question, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //冻结用户的积分
                if (question.AddedReward > 0)
                {
                    userService.FreezeTradePoints(question.UserId, question.AddedReward);
                }

                //向定向提问的目标用户发送通知
                if (question.AskUserId > 0)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = question.AskUserId;
                    notice.ApplicationId      = AskConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = question.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(question.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().AskUser();
                    noticeService.Create(notice);
                }

                //自动关注(提问者自动关注[订阅]该问题)
                if (!subscribeService.IsSubscribed(question.QuestionId, question.UserId))
                {
                    subscribeService.Subscribe(question.QuestionId, question.UserId);

                    //问题关注数计数,用于“可能感兴趣的问题”关联表查询
                    countService.ChangeCount(CountTypes.Instance().QuestionFollowerCount(), question.QuestionId, question.UserId, 1, false);
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                //已解决问题的积分不返还,未解决/已取消的问题应该解除冻结积分
                if (question.Reward > 0 && question.Status != QuestionStatus.Resolved)
                {
                    userService.UnfreezeTradePoints(question.UserId, question.Reward);
                }

                //删除所有用户对该问题的关注(订阅)
                IEnumerable <long> userIds = subscribeService.GetUserIdsOfObject(question.QuestionId);
                foreach (var userId in userIds)
                {
                    subscribeService.CancelSubscribe(question.QuestionId, userId);
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                //冻结用户的积分
                if (question.AddedReward != 0)
                {
                    userService.FreezeTradePoints(question.UserId, question.AddedReward);
                }
                if (question.Status == QuestionStatus.Canceled)
                {
                    subscribeService.CancelSubscribe(question.QuestionId, question.UserId);
                    int pageSize = 100;
                    for (int i = 1; i <= question.AnswerCount; i = i + pageSize)
                    {
                        PagingDataSet <AskAnswer> answers = askService.GetAnswersByQuestionId(question.QuestionId, SortBy_AskAnswer.DateCreated_Desc, pageSize, i);
                        foreach (AskAnswer answer in answers)
                        {
                            subscribeService.CancelSubscribe(question.QuestionId, answer.UserId);
                        }
                    }
                }
            }
            //加精时处理积分和威望并产生通知
            else if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential())
            {
                string pointItemKey = PointItemKeys.Instance().EssentialContent();
                string description  = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "问题", question.Subject);
                pointService.GenerateByRole(question.UserId, pointItemKey, description);

                if (question.UserId > 0)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = question.UserId;
                    notice.ApplicationId      = AskConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = question.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(question.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().ManagerSetEssential();
                    noticeService.Create(notice);
                }
                //记录用户的威望
                PointItem pointItem = pointService.GetPointItem(pointItemKey);
                ownerDataService.Change(question.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem.ReputationPoints);
            }
        }
コード例 #21
0
        /// <summary>
        /// 回答增删改等触发的事件
        /// </summary>
        private void AskAnswerEventModule_After(AskAnswer answer, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //向关注该问题的用户发送通知
                IEnumerable <long> userIds  = subscribeService.GetUserIdsOfObject(answer.QuestionId);
                AskQuestion        question = answer.Question;
                foreach (var userId in userIds)
                {
                    //通知的对象排除掉自己
                    if (userId == answer.UserId)
                    {
                        continue;
                    }

                    Notice notice = Notice.New();
                    notice.UserId             = userId;
                    notice.ApplicationId      = AskConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Reply();
                    notice.LeadingActor       = answer.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(answer.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().NewAnswer();
                    noticeService.Create(notice);
                }

                //自动关注(回答者自动关注[订阅]该问题)
                if (!subscribeService.IsSubscribed(question.QuestionId, answer.UserId))
                {
                    subscribeService.Subscribe(question.QuestionId, answer.UserId);

                    //问题关注数计数,用于“可能感兴趣的问题”关联表查询
                    countService.ChangeCount(CountTypes.Instance().QuestionFollowerCount(), question.QuestionId, question.UserId, 1, false);
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                //删除回答者对问题的关注
                subscribeService.CancelSubscribe(answer.QuestionId, answer.UserId);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                AskQuestion question = new AskService().GetQuestion(answer.QuestionId);

                if (answer.IsBest && question.Status == QuestionStatus.Resolved && !question.IsTrated)
                {
                    //如果问题有悬赏则悬赏分值转移到回答者的帐户(如有交易税,需要扣除)
                    if (question.Reward > 0)
                    {
                        pointService.Trade(question.UserId, answer.UserId, question.Reward, string.Format(Resource.PointRecord_Pattern_QuestionReward, question.Subject), false);
                    }
                    askService.SetTradeStatus(question, true);

                    //处理采纳回答相关的积分和威望
                    string pointItemKey_AcceptedAnswer = PointItemKeys.Instance().Ask_AcceptedAnswer();

                    //采纳回答时产生积分
                    string description_AcceptedAnswer = string.Format(Resource.PointRecord_Pattern_AcceptedAnswer, question.Subject);
                    pointService.GenerateByRole(question.UserId, pointItemKey_AcceptedAnswer, description_AcceptedAnswer);

                    //记录用户的威望
                    PointItem pointItem_AcceptedAnswer = pointService.GetPointItem(pointItemKey_AcceptedAnswer);
                    ownerDataService.Change(question.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem_AcceptedAnswer.ReputationPoints);


                    //处理回答被采纳相关的积分和威望
                    string pointItemKey_AnswerWereAccepted = PointItemKeys.Instance().Ask_AnswerWereAccepted();

                    //回答被采纳时产生积分
                    string description_AnswerWereAccepted = string.Format(Resource.PointRecord_Pattern_AnswerWereAccepted, question.Subject);
                    pointService.GenerateByRole(answer.UserId, pointItemKey_AnswerWereAccepted, description_AnswerWereAccepted);

                    //记录用户的威望
                    PointItem pointItem_AnswerWereAccepted = pointService.GetPointItem(pointItemKey_AnswerWereAccepted);
                    ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem_AnswerWereAccepted.ReputationPoints);

                    //向关注该问题的用户发送通知
                    IEnumerable <long> userIds = subscribeService.GetUserIdsOfObject(answer.QuestionId);
                    foreach (var userId in userIds)
                    {
                        //通知的对象排除掉自己
                        if (userId == question.UserId)
                        {
                            continue;
                        }

                        Notice notice = Notice.New();
                        notice.UserId             = userId;
                        notice.ApplicationId      = AskConfig.Instance().ApplicationId;
                        notice.TypeId             = NoticeTypeIds.Instance().Hint();
                        notice.LeadingActor       = question.Author;
                        notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(question.UserId)));
                        notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
                        notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
                        notice.TemplateName       = NoticeTemplateNames.Instance().SetBestAnswer();
                        noticeService.Create(notice);
                    }
                }
            }
        }
コード例 #22
0
        /// <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);
        }