/// <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();
        }
        /// <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);
        }
示例#3
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();
        }
示例#4
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();
        }
 /// <summary>
 /// 发送加入群组邀请
 /// </summary>
 /// <param name="group"><see cref="GroupEntity"/></param>
 /// <param name="sender">发送人</param>
 /// <param name="userIds">邀请接收人</param>
 /// <param name="remark">附言</param>
 public void SendInvitations(GroupEntity group, IUser sender, string remark, IEnumerable<long> userIds)
 {
     //调用InvitationService的发送请求的方法
     InvitationService invitationService = new InvitationService();
     foreach (var userId in userIds)
     {
         if (!IsMember(group.GroupId, userId))
         {
             Invitation invitation = Invitation.New();
             invitation.ApplicationId = GroupConfig.Instance().ApplicationId;
             invitation.InvitationTypeKey = InvitationTypeKeys.Instance().InviteJoinGroup();
             invitation.UserId = userId;
             invitation.SenderUserId = sender.UserId;
             invitation.Sender = sender.DisplayName;
             invitation.SenderUrl = SiteUrls.Instance().SpaceHome(sender.UserId);
             invitation.RelativeObjectId = group.GroupId;
             invitation.RelativeObjectName = group.GroupName;
             invitation.RelativeObjectUrl = SiteUrls.Instance().GroupHome(group.GroupKey);
             invitation.Remark = remark;
             invitationService.Create(invitation);
         }
     }
 }
示例#6
0
 /// <summary>
 /// 获取所有用户提醒信息集合
 /// </summary>
 /// <returns>用户提醒信息集合</returns>
 public IEnumerable<UserReminderInfo> GetUserReminderInfos()
 {
     InvitationService messageService = new InvitationService();
     return messageService.GetUserReminderInfos();
 }
        /// <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();
        }
        /// <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();
        }
        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
        }