Exemple #1
0
        /// <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);
            }
        }
        /// <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);
                }
            }
        }
Exemple #3
0
 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);
     }
 }
Exemple #4
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);
                }
            }
        }
Exemple #5
0
        /// <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);

            }
        }
Exemple #6
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);
        }