コード例 #1
0
        public ActionResult Home()
        {
            pageResourceManager.InsertTitlePart("后台首页");

            //获得所有应用的应用名
            IEnumerable <ApplicationBase> applications = applicationService.GetAll();
            //初始化待处理应用数组
            List <ApplicationStatisticData> allManageableDatas = new List <ApplicationStatisticData>();
            //初始化数据统计项实体数组
            List <ApplicationStatisticItem> statisticItems = new List <ApplicationStatisticItem>();

            var isApplicationAdmin = !UserContext.CurrentUser.IsInRoles(RoleNames.Instance().SuperAdministrator(), RoleNames.Instance().ContentAdministrator());

            //遍历应用名
            foreach (var application in applications)
            {
                if (isApplicationAdmin)
                {
                    if (!authorizer.IsAdministrator(application.ApplicationId))
                    {
                        continue;
                    }
                }
                //获取所有待处理数据实体
                IEnumerable <ApplicationStatisticData> manageableDatas = DIContainer.ResolveNamed <IApplicationStatisticDataGetter>(application.ApplicationKey).GetManageableDatas();
                //获取所有数据统计应用数据实体
                IEnumerable <ApplicationStatisticData> applicationStatisticDatas = DIContainer.ResolveNamed <IApplicationStatisticDataGetter>(application.ApplicationKey).GetStatisticDatas();
                //将所有待处理数据实体添加到未处理应用数组
                allManageableDatas.AddRange(manageableDatas);
                //遍历所有应用简称
                foreach (string shortName in applicationStatisticDatas.Select(n => n.ShortName))
                {
                    //如果数组中已存在该应用则继续
                    var item = statisticItems.Where(n => n.ShortName == shortName).FirstOrDefault();
                    if (statisticItems.Contains(item))
                    {
                        continue;
                    }
                    //获取该简称下的应用数组
                    IEnumerable <ApplicationStatisticData> datas = applicationStatisticDatas.Where(n => n.ShortName == shortName);
                    //获取该简称下的总数应用
                    ApplicationStatisticData applicationStatisticDataTotal = datas.Where(n => n.DataKey == ApplicationStatisticDataKeys.Instance().TotalCount()).FirstOrDefault();
                    //初始化总数
                    long totalCount = 0;
                    //初始化URL
                    string itemUrl = null;
                    //如果存在总数应用
                    if (applicationStatisticDataTotal != null)
                    {
                        //为数据统计项实体总数和url赋值
                        totalCount = applicationStatisticDataTotal.Value;
                        itemUrl    = applicationStatisticDataTotal.Url;
                    }
                    //获取该简称下的24小时新增数应用
                    var applicationStatisticDataLast24H = datas.Where(n => n.DataKey == ApplicationStatisticDataKeys.Instance().Last24HCount()).FirstOrDefault();
                    //初始化24小时新增数
                    long Last24H = 0;
                    //如果存在24小时新增数应用
                    if (applicationStatisticDataLast24H != null)
                    {
                        //为总数项实体24小时新增数赋值
                        Last24H = applicationStatisticDataLast24H.Value;
                    }
                    //实例化数据统计项实体
                    ApplicationStatisticItem appItem = new ApplicationStatisticItem(shortName, totalCount, Last24H);
                    appItem.Url = itemUrl;
                    //添加到数组
                    statisticItems.Add(appItem);
                }
            }
            //获取待处理事项实体数组
            ViewData["allManageableDatas"] = allManageableDatas;

            //增加有多少个待审核评论
            PagingDataSet <Comment> comments = new CommentService().GetComments(PubliclyAuditStatus.Pending, null, null, null, null, 20, 1);

            ViewData["commentsCount"] = comments.TotalRecords;

            //多少未读客服消息
            ViewData["customMessageCount"] = new MessageService().GetUnreadCount((long)BuildinMessageUserId.CustomerService);

            //待处理用户举报
            ViewData["impeachCount"] = new ImpeachReportService().GetsForAdmin(false, null).TotalRecords;

            //待激活的用户
            var userManageableCounts = userService.GetManageableCounts(false, false, false);

            ViewData["activatedUserCount"] = userManageableCounts[UserManageableCountType.IsActivated];

            //24小时新增用户数
            ViewData["userCount24H"] = userManageableCounts[UserManageableCountType.IsLast24];

            //总用户数
            ViewData["userCount"] = userManageableCounts[UserManageableCountType.IsAll];

            //获取系统信息

            SystemInfo systemInfo = new SystemInfo();

            ViewData["systemInfo"] = systemInfo;
            return(View(statisticItems));
        }
コード例 #2
0
        public ActionResult Home()
        {
            //获得所有应用的应用名
            IEnumerable <ApplicationBase> applications = applicationService.GetAll();
            //初始化待处理应用数组
            List <ApplicationStatisticData> allManageableDatas = new List <ApplicationStatisticData>();
            //初始化数据统计项实体数组
            List <ApplicationStatisticItem> statisticItems = new List <ApplicationStatisticItem>();

            var authorizer         = DIContainer.Resolve <Authorizer>();
            var isApplicationAdmin = !UserContext.CurrentUser.IsInRoles(RoleNames.Instance().SuperAdministrator(), RoleNames.Instance().ContentAdministrator());

            //遍历应用名
            foreach (var application in applications)
            {
                if (isApplicationAdmin)
                {
                    if (!authorizer.IsAdministrator(application.ApplicationId))
                    {
                        continue;
                    }
                }
                //获取所有待处理数据实体
                IEnumerable <ApplicationStatisticData> manageableDatas = DIContainer.ResolveNamed <IApplicationStatisticDataGetter>(application.ApplicationKey).GetManageableDatas();
                //获取所有数据统计应用数据实体
                IEnumerable <ApplicationStatisticData> applicationStatisticDatas = DIContainer.ResolveNamed <IApplicationStatisticDataGetter>(application.ApplicationKey).GetStatisticDatas();
                //将所有待处理数据实体添加到未处理应用数组
                allManageableDatas.AddRange(manageableDatas);
                //遍历所有应用简称
                foreach (string shortName in applicationStatisticDatas.Select(n => n.ShortName))
                {
                    //如果数组中已存在该应用则继续
                    var item = statisticItems.Where(n => n.ShortName == shortName).FirstOrDefault();
                    if (statisticItems.Contains(item))
                    {
                        continue;
                    }
                    //获取该简称下的应用数组
                    IEnumerable <ApplicationStatisticData> datas = applicationStatisticDatas.Where(n => n.ShortName == shortName);
                    //获取该简称下的总数应用
                    ApplicationStatisticData applicationStatisticDataTotal = datas.Where(n => n.DataKey == ApplicationStatisticDataKeys.Instance().TotalCount()).FirstOrDefault();
                    //初始化总数
                    long totalCount = 0;
                    //初始化URL
                    string itemUrl = null;
                    //如果存在总数应用
                    if (applicationStatisticDataTotal != null)
                    {
                        //为数据统计项实体总数和url赋值
                        totalCount = applicationStatisticDataTotal.Value;
                        itemUrl    = applicationStatisticDataTotal.Url;
                    }
                    //获取该简称下的24小时新增数应用
                    var applicationStatisticDataLast24H = datas.Where(n => n.DataKey == ApplicationStatisticDataKeys.Instance().Last24HCount()).FirstOrDefault();
                    //初始化24小时新增数
                    long Last24H = 0;
                    //如果存在24小时新增数应用
                    if (applicationStatisticDataLast24H != null)
                    {
                        //为总数项实体24小时新增数赋值
                        Last24H = applicationStatisticDataLast24H.Value;
                    }
                    //实例化数据统计项实体
                    ApplicationStatisticItem appItem = new ApplicationStatisticItem(shortName, totalCount, Last24H);
                    appItem.Url = itemUrl;
                    //添加到数组
                    statisticItems.Add(appItem);
                }
            }
            //获取待处理事项实体数组
            ViewData["allManageableDatas"] = allManageableDatas;

            return(View(statisticItems));
        }