コード例 #1
0
        /// <summary>
        /// 获取问答用户统计数据
        /// </summary>
        /// <remarks>
        /// 需统计:问题数、回答数、回答被采纳数、赞同数
        /// 无需缓存
        /// </remarks>
        /// <param name="userId">用户id</param>
        /// <returns>用户统计数据</returns>
        public Dictionary <string, long> GetUserStatisticData(long userId)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            Dictionary <string, long> userStatisticData = new Dictionary <string, long>();

            userStatisticData.Add(OwnerDataKeys.Instance().QuestionCount(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().QuestionCount()));
            userStatisticData.Add(OwnerDataKeys.Instance().AnswerCount(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().AnswerCount()));
            userStatisticData.Add(OwnerDataKeys.Instance().AnswerAcceptCount(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().AnswerAcceptCount()));
            userStatisticData.Add(OwnerDataKeys.Instance().AnswerSupportCount(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().AnswerSupportCount()));
            userStatisticData.Add(OwnerDataKeys.Instance().UserAskReputation(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().UserAskReputation()));

            return(userStatisticData);
        }
コード例 #2
0
        /// <summary>
        /// 用户排行列表
        /// </summary>
        public ActionResult _UserRank(int topNum = 5)
        {
            IEnumerable <long>      userIds         = ownerDataService.GetTopOwnerIds(OwnerDataKeys.Instance().ThreadCount(), topNum, OwnerData_SortBy.LongValue_DESC);
            IEnumerable <IUser>     users           = userService.GetFullUsers(userIds);
            Dictionary <long, long> userThreadCount = new Dictionary <long, long>();

            foreach (long userId in userIds)
            {
                //用户日志数
                long threadCount = ownerDataService.GetLong(userId, OwnerDataKeys.Instance().ThreadCount());
                userThreadCount[userId] = threadCount;
            }

            ViewData["userThreadCount"] = userThreadCount;
            return(View(users));
        }
コード例 #3
0
        /// <summary>
        /// 用户空间日志左侧控制面板
        /// </summary>
        /// <param name="menu">菜单项标识</param>
        public ActionResult _Panel(string spaceKey, string menu = null)
        {
            User user = userService.GetFullUser(spaceKey);
            ViewData["user"] = user;

            //用户日志数
            long threadCount = ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().ThreadCount());
            ViewData["threadCount"] = threadCount;

            IUser currentUser = UserContext.CurrentUser;
            if (currentUser != null && currentUser.UserId != user.UserId)
            {
                bool followed = new FollowService().IsFollowed(currentUser.UserId, user.UserId);
                ViewData["followed"] = followed;
            }

            return View();
        }
コード例 #4
0
        /// <summary>
        /// 用户数据
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="displayTemplate">用户数据内容块显示模板</param>
        /// <returns></returns>
        public ActionResult _UserData(long userId, DisplayTemplate_UserData displayTemplate = DisplayTemplate_UserData.Side)
        {
            User user = userService.GetFullUser(userId);
            if (user == null)
                return HttpNotFound();
            if (displayTemplate == DisplayTemplate_UserData.Side)
            {
                IEnumerable<long> sectionIds = subscribeService.GetAllObjectIds(userId);
                IEnumerable<BarSection> barSections = barSectionService.GetBarsections(sectionIds);
                ViewData["barSections"] = barSections;
            }
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ViewData["userThreadCount"] = ownerDataService.GetLong(userId, OwnerDataKeys.Instance().ThreadCount());
            ViewData["userPostCount"] = ownerDataService.GetLong(userId, OwnerDataKeys.Instance().PostCount());
            ViewData["userFollowSectionCount"] = ownerDataService.GetLong(userId, OwnerDataKeys.Instance().FollowSectionCount());

            #region 身份认证
            List<Identification> identifications = identificationService.GetUserIdentifications(user.UserId);
            if (identifications.Count() > 0)
            {
                ViewData["identificationTypeVisiable"] = true;
            }
            #endregion

            return PartialView("_UserData_" + displayTemplate.ToString(), user);
        }
コード例 #5
0
        /// <summary>
        /// 加入的专题数
        /// </summary>
        public static long JoinedTopicCount(this User user)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            return(ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().JoinedTopicCount()));
        }
コード例 #6
0
 /// <summary>
 /// 加入的专题数
 /// </summary>
 public static long JoinedTopicCount(this User user)
 {
     OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
     return ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().JoinedTopicCount());
 }
コード例 #7
0
ファイル: ChannelCmsController.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 他的资讯/我的资讯
        /// </summary>
        public ActionResult CmsUser(string spaceKey, int?contentFolderId = null, AuditStatus?auditStatus = null, int pageSize = 50, int pageIndex = 1)
        {
            IUser user = null;

            if (string.IsNullOrEmpty(spaceKey))
            {
                user = UserContext.CurrentUser;
                if (user == null)
                {
                    return(Redirect(SiteUrls.Instance().Login(true)));
                }
                pageResourceManager.InsertTitlePart("我的资讯");
            }
            else
            {
                user = userService.GetFullUser(spaceKey);
                if (user == null)
                {
                    return(HttpNotFound());
                }

                if (!new PrivacyService().Validate(user.UserId, UserContext.CurrentUser != null ? UserContext.CurrentUser.UserId : 0, PrivacyItemKeys.Instance().VisitUserSpace()))
                {
                    if (UserContext.CurrentUser == null)
                    {
                        return(Redirect(SiteUrls.Instance().Login(true)));
                    }
                    else
                    {
                        return(Redirect(SiteUrls.Instance().PrivacyHome(user.UserName)));
                    }
                }

                if (UserContext.CurrentUser != null && user.UserId == UserContext.CurrentUser.UserId)
                {
                    pageResourceManager.InsertTitlePart("我的资讯");
                }
                else
                {
                    pageResourceManager.InsertTitlePart(user.DisplayName + "的资讯");
                }
            }
            ViewData["user"] = user;
            bool hasManagePermission = UserContext.CurrentUser != null && UserContext.CurrentUser.UserId == user.UserId;

            if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
            {
                hasManagePermission = true;
            }
            PubliclyAuditStatus?publiclyAuditStatus = null;

            if (hasManagePermission)
            {
                if (auditStatus.HasValue)
                {
                    switch (auditStatus.Value)
                    {
                    case AuditStatus.Again:
                        publiclyAuditStatus = PubliclyAuditStatus.Again;
                        break;

                    case AuditStatus.Fail:
                        publiclyAuditStatus = PubliclyAuditStatus.Fail;
                        break;

                    case AuditStatus.Success:
                        publiclyAuditStatus = PubliclyAuditStatus.Success;
                        break;

                    case AuditStatus.Pending:
                    default:
                        publiclyAuditStatus = PubliclyAuditStatus.Pending;
                        break;
                    }
                }
            }
            else
            {
                publiclyAuditStatus = new AuditService().GetPubliclyAuditStatus(CmsConfig.Instance().ApplicationId);
            }

            PagingDataSet <ContentItem> contentItems = contentItemService.GetUserContentItems(user.UserId, contentFolderId, publiclyAuditStatus, pageSize, pageIndex);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_UserContentItems", contentItems));
            }
            ViewData["hasManagePermission"] = hasManagePermission;
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ViewData["contributeCount"] = ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().ContributeCount());

            return(View(contentItems));
        }
コード例 #8
0
ファイル: UserExtensionByGroup.cs プロジェクト: x1987624/SNS
        /// <summary>
        /// 创建的群组数
        /// </summary>
        public static long CreatedGroupCount(this User user)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            return(ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().CreatedGroupCount()));
        }
コード例 #9
0
        /// <summary>
        /// 他的资讯/我的资讯
        /// </summary>
        public ActionResult CmsUser(string spaceKey, int? contentFolderId = null, AuditStatus? auditStatus = null, int pageSize = 50, int pageIndex = 1)
        {
            IUser user = null;
            if (string.IsNullOrEmpty(spaceKey))
            {
                user = UserContext.CurrentUser;
                if (user == null)
                {
                    return Redirect(SiteUrls.Instance().Login(true));
                }
                pageResourceManager.InsertTitlePart("我的资讯");
            }
            else
            {
                user = userService.GetFullUser(spaceKey);
                if (user == null)
                {
                    return HttpNotFound();
                }

                if (!new PrivacyService().Validate(user.UserId, UserContext.CurrentUser != null ? UserContext.CurrentUser.UserId : 0, PrivacyItemKeys.Instance().VisitUserSpace()))
                {
                    if (UserContext.CurrentUser == null)
                        return Redirect(SiteUrls.Instance().Login(true));
                    else
                        return Redirect(SiteUrls.Instance().PrivacyHome(user.UserName));
                }

                if (UserContext.CurrentUser != null && user.UserId == UserContext.CurrentUser.UserId)
                {
                    pageResourceManager.InsertTitlePart("我的资讯");
                }
                else
                {
                    pageResourceManager.InsertTitlePart(user.DisplayName + "的资讯");
                }
            }
            ViewData["user"] = user;
            bool hasManagePermission = UserContext.CurrentUser != null && UserContext.CurrentUser.UserId == user.UserId;
            if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
                hasManagePermission = true;
            PubliclyAuditStatus? publiclyAuditStatus = null;
            if (hasManagePermission)
            {
                if (auditStatus.HasValue)
                    switch (auditStatus.Value)
                    {
                        case AuditStatus.Again:
                            publiclyAuditStatus = PubliclyAuditStatus.Again;
                            break;
                        case AuditStatus.Fail:
                            publiclyAuditStatus = PubliclyAuditStatus.Fail;
                            break;
                        case AuditStatus.Success:
                            publiclyAuditStatus = PubliclyAuditStatus.Success;
                            break;
                        case AuditStatus.Pending:
                        default:
                            publiclyAuditStatus = PubliclyAuditStatus.Pending;
                            break;
                    }
            }
            else
                publiclyAuditStatus = new AuditService().GetPubliclyAuditStatus(CmsConfig.Instance().ApplicationId);

            PagingDataSet<ContentItem> contentItems = contentItemService.GetUserContentItems(user.UserId, contentFolderId, publiclyAuditStatus, pageSize, pageIndex);
            if (Request.IsAjaxRequest())
                return PartialView("_UserContentItems", contentItems);
            ViewData["hasManagePermission"] = hasManagePermission;
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ViewData["contributeCount"] = ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().ContributeCount());

            return View(contentItems);
        }
コード例 #10
0
ファイル: UserExtensionByGroup.cs プロジェクト: hbulzy/SYS
 /// <summary>
 /// 创建的群组数
 /// </summary>
 public static long CreatedGroupCount(this User user)
 {
     OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
     return ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().CreatedGroupCount());
 }