/// <summary>
        /// 页头
        /// </summary>
        /// <returns></returns>
        public ActionResult _Header(string spaceKey)
        {
            if (UserContext.CurrentUser != null)
            {
                MessageService messageService = new MessageService();
                InvitationService invitationService = new InvitationService();
                NoticeService noticeService = new NoticeService();

                long userId = UserIdToUserNameDictionary.GetUserId(UserContext.CurrentUser.UserName);
                int count = 0;
                count = invitationService.GetUnhandledCount(userId);
                count += messageService.GetUnreadCount(userId);
                count += noticeService.GetUnhandledCount(userId);
                ViewData["PromptCount"] = count;
            }

            //获取当前是在哪个应用下搜索
            RouteValueDictionary routeValueDictionary = Request.RequestContext.RouteData.DataTokens;
            string areaName = routeValueDictionary.Get<string>("area", null) + "Search";
            ViewData["search"] = areaName;

            //查询用于快捷搜索的搜索器
            IEnumerable<ISearcher> searchersQuickSearch = SearcherFactory.GetQuickSearchers(4);
            ViewData["searchersQuickSearch"] = searchersQuickSearch;

            NavigationService service = new NavigationService();
            ViewData["Navigations"] = service.GetRootNavigations(PresentAreaKeysOfBuiltIn.Channel).Where(n => n.IsVisible(UserContext.CurrentUser) == true);

            return PartialView();
        }
예제 #2
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);
     }
 }
예제 #3
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);
            }
        }
예제 #4
0
        /// <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);
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 评论日志动态处理程序
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="eventArgs"></param>
        private void BlogCommentActivityEventModule_After(Comment comment, AuditEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();
            BlogThread blogThread = null;

            if (comment.TenantTypeId == TenantTypeIds.Instance().BlogThread())
            {
                //生成动态
                ActivityService activityService = new ActivityService();
                AuditService auditService = new AuditService();
                bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
                if (auditDirection == true)
                {
                    //创建评论的动态[关注评论者的粉丝可以看到该评论]
                    Activity activity = Activity.New();
                    activity.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogComment();
                    activity.ApplicationId = BlogConfig.Instance().ApplicationId;

                    BlogService blogService = new BlogService();
                    blogThread = blogService.Get(comment.CommentedObjectId);
                    if (blogThread == null || blogThread.UserId == comment.UserId)
                    {
                        return;
                    }
                    activity.IsOriginalThread = true;
                    activity.IsPrivate = false;
                    activity.OwnerId = comment.UserId;
                    activity.OwnerName = comment.Author;
                    activity.OwnerType = ActivityOwnerTypes.Instance().User();
                    activity.ReferenceId = blogThread.ThreadId;
                    activity.ReferenceTenantTypeId = TenantTypeIds.Instance().BlogThread();
                    activity.SourceId = comment.Id;
                    activity.TenantTypeId = TenantTypeIds.Instance().Comment();
                    activity.UserId = comment.UserId;

                    //是否是公开的(用于是否推送站点动态)
                    bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false;
                    activityService.Generate(activity, false, isPublic);

                    //创建评论的动态[关注该日志的用户可以看到该评论]
                    Activity activityOfBlogComment = Activity.New();
                    activityOfBlogComment.ActivityItemKey = activity.ActivityItemKey;
                    activityOfBlogComment.ApplicationId = activity.ApplicationId;
                    activityOfBlogComment.IsOriginalThread = activity.IsOriginalThread;
                    activityOfBlogComment.IsPrivate = activity.IsPrivate;
                    activityOfBlogComment.ReferenceId = activity.ReferenceId;
                    activityOfBlogComment.ReferenceTenantTypeId = activity.ReferenceTenantTypeId;
                    activityOfBlogComment.SourceId = activity.SourceId;
                    activityOfBlogComment.TenantTypeId = activity.TenantTypeId;
                    activityOfBlogComment.UserId = activity.UserId;

                    activityOfBlogComment.OwnerId = blogThread.ThreadId;
                    activityOfBlogComment.OwnerName = blogThread.ResolvedSubject;
                    activityOfBlogComment.OwnerType = ActivityOwnerTypes.Instance().Blog();

                    activityService.Generate(activityOfBlogComment, false, isPublic);
                }
                else if (auditDirection == false)
                {
                    activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id);
                }
            }
        }
예제 #6
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);
                }
            }
        }
예제 #7
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);

            }
        }
예제 #8
0
        /// <summary>
        /// 暂停页header
        /// </summary>
        /// <returns></returns>
        public ActionResult PausePageHeader()
        {
            if (UserContext.CurrentUser != null)
            {
                MessageService messageService = new MessageService();
                InvitationService invitationService = new InvitationService();
                NoticeService noticeService = new NoticeService();

                long userId = UserIdToUserNameDictionary.GetUserId(UserContext.CurrentUser.UserName);
                int count = 0;
                count = invitationService.GetUnhandledCount(userId);
                count += messageService.GetUnreadCount(userId);
                count += noticeService.GetUnhandledCount(userId);
                ViewData["PromptCount"] = count;
            }

            //获取当前是在哪个应用下搜索
            RouteValueDictionary routeValueDictionary = Request.RequestContext.RouteData.DataTokens;
            string areaName = routeValueDictionary.Get<string>("area", null) + "Search";
            ViewData["search"] = areaName;

            IEnumerable<Navigation> navigations = navigationService.GetRootNavigations(PresentAreaKeysOfBuiltIn.Channel).Where(n => n.IsVisible(UserContext.CurrentUser) == true).Where(n => n.ApplicationId != 0);

            if (navigations != null)
            {
                ViewData["Navigations"] = navigations.OrderBy(n => n.DisplayOrder);
            }

            return View();
        }
예제 #9
0
        /// <summary>
        /// 页头
        /// </summary>
        /// <returns></returns>
        public ActionResult _Header()
        {
            if (UserContext.CurrentUser != null)
            {
                MessageService messageService = new MessageService();
                InvitationService invitationService = new InvitationService();
                NoticeService noticeService = new NoticeService();

                long userId = UserIdToUserNameDictionary.GetUserId(UserContext.CurrentUser.UserName);
                int count = 0;
                count = invitationService.GetUnhandledCount(userId);
                count += messageService.GetUnreadCount(userId);
                count += noticeService.GetUnhandledCount(userId);
                ViewData["PromptCount"] = count;
            }

            //获取当前是在哪个应用下搜索
            RouteValueDictionary routeValueDictionary = Request.RequestContext.RouteData.DataTokens;
            string areaName = routeValueDictionary.Get<string>("area", null) + "Search";
            ViewData["search"] = areaName;
            IEnumerable<Navigation> navigations = navigationService.GetRootNavigations(PresentAreaKeysOfBuiltIn.Channel);
            if (navigations != null)
            {
                ViewData["Navigations"] = navigations;
                ViewData["navigation"] = navigations.Where(n => n.ApplicationId == 1011).SingleOrDefault();
            }

            bool groupIsEnable = false;
            ApplicationBase groupApplication = applicationService.Get(1011);
            if (groupApplication != null && groupApplication.IsEnabled)
            {
                groupIsEnable = true;
            }
            ViewData["groupIsEnable"] = groupIsEnable;

            return PartialView();
        }
예제 #10
0
        /// <summary>
        /// 页头
        /// </summary>
        /// <returns></returns>
        public ActionResult _Header(string spaceKey)
        {
            #region 消息统计数

            MessageService messageService = new MessageService();
            InvitationService invitationService = new InvitationService();
            NoticeService noticeService = new NoticeService();

            if (UserContext.CurrentUser != null)
            {
                int count = 0;
                count = invitationService.GetUnhandledCount(UserContext.CurrentUser.UserId);
                count += messageService.GetUnreadCount(UserContext.CurrentUser.UserId);
                count += noticeService.GetUnhandledCount(UserContext.CurrentUser.UserId);
                ViewData["PromptCount"] = count;
            }

            #endregion

            NavigationService service = DIContainer.Resolve<NavigationService>();
            IEnumerable<Navigation> navigations = service.GetRootNavigations(PresentAreaKeysOfBuiltIn.Channel).Where(n => n.IsVisible(UserContext.CurrentUser) == true);

            bool groupIsEnable = false;
            ApplicationBase groupApplication = applicationService.Get(1011);
            if (groupApplication != null && groupApplication.IsEnabled)
            {
                groupIsEnable = true;
            }
            ViewData["groupIsEnable"] = groupIsEnable;

            if (navigations != null)
            {
                ViewData["Navigations"] = navigations;
            }

            return View();
        }
예제 #11
0
        /// <summary>
        /// 我的通知、私信、评论等的边栏
        /// </summary>
        /// <param name="subMenu"></param>
        /// <returns></returns>
        public ActionResult _MessageCenter_Menu(MessageCenterMenu subMenu)
        {
            IUser currentUser = UserContext.CurrentUser;
            MessageService messageService = new MessageService();
            InvitationService invitationService = new InvitationService();
            NoticeService noticeService = new NoticeService();

            int invitationCount = invitationService.GetUnhandledCount(currentUser.UserId);
            int messageCount = messageService.GetUnreadCount(currentUser.UserId);
            int noticeCount = noticeService.GetUnhandledCount(currentUser.UserId);
            ViewData["invitationCount"] = invitationCount;
            ViewData["messageCount"] = messageCount;
            ViewData["noticeCount"] = noticeCount;

            ViewData["MessageCenterMenu"] = subMenu;
            return View();
        }
예제 #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
        private void DeleteUserEventMoudle_After(IUser sender, DeleteUserEventArgs eventArgs)
        {
            IUserService userService = DIContainer.Resolve<IUserService>();

            #region 数据
            //清除应用数据
            applicationService.DeleteUser(sender.UserId, eventArgs.TakeOverUserName, eventArgs.TakeOverAll);

            //删除用户信息
            new UserProfileService().Delete(sender.UserId);

            //清除用户内容计数数据
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ownerDataService.ClearOwnerData(sender.UserId);

            //清除用户关于分类的数据
            CategoryService categoryService = new CategoryService();
            categoryService.CleanByUser(sender.UserId);

            //清除用户动态
            ActivityService activityService = new ActivityService();
            activityService.CleanByUser(sender.UserId);

            //清除用户评论
            new CommentService().DeleteUserComments(sender.UserId, false);

            #endregion

            #region 消息

            //清除用户关于私信的数据
            MessageService messageService = new MessageService();
            messageService.ClearSessionsFromUser(sender.UserId);

            //清除请求的用户数据
            InvitationService invitationService = new InvitationService();
            invitationService.CleanByUser(sender.UserId);

            //清除通知的用户数据
            NoticeService noticeService = new NoticeService();
            noticeService.CleanByUser(sender.UserId);

            InviteFriendService inviteFriendService = new InviteFriendService();
            inviteFriendService.CleanByUser(sender.UserId);

            //清除站外提醒的用户数据
            ReminderService reminderService = new ReminderService();
            reminderService.CleanByUser(sender.UserId);

            #endregion

            #region 关注/访客

            //清除用户关于关注用户的数据
            FollowService followService = new FollowService();
            followService.CleanByUser(sender.UserId);

            //清除访客记录的用户数据
            VisitService visitService = new VisitService(string.Empty);
            visitService.CleanByUser(sender.UserId);

            #endregion

            #region 帐号

            //清除帐号绑定数据
            var accountBindingService = new AccountBindingService();
            var accountBindings = new AccountBindingService().GetAccountBindings(sender.UserId);
            foreach (var accountBinding in accountBindings)
            {
                accountBindingService.DeleteAccountBinding(accountBinding.UserId, accountBinding.AccountTypeKey);
            }

            #endregion

            #region 装扮

            //调整皮肤文件使用次数
            var user = userService.GetFullUser(sender.UserId);
            if (user == null)
                return;
            var presentArea = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.UserSpace);
            string defaultThemeAppearance = string.Join(",", presentArea.DefaultThemeKey, presentArea.DefaultAppearanceKey);
            if (!user.IsUseCustomStyle)
                new ThemeService().ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.UserSpace, null, !string.IsNullOrEmpty(user.ThemeAppearance) ? user.ThemeAppearance : defaultThemeAppearance);

            #endregion
        }