Ejemplo n.º 1
0
        public ActionResult ManageLogin(LoginEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            Authorizer authorizer = new Authorizer();

            User            user            = model.AsUser();
            UserLoginStatus userLoginStatus = membershipService.ValidateUser(user.UserName, user.Password);

            if (userLoginStatus == UserLoginStatus.InvalidCredentials)
            {
                IUser userByEmail = userService.FindUserByEmail(user.UserName);
                if (userByEmail != null)
                {
                    user            = userByEmail as User;
                    userLoginStatus = membershipService.ValidateUser(userByEmail.UserName, model.Password);
                }
            }
            else
            {
                user = userService.GetFullUser(model.UserName);
            }

            if (userLoginStatus == UserLoginStatus.InvalidCredentials)
            {
                ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "帐号或密码错误,请重新输入!");
            }
            if (userLoginStatus == UserLoginStatus.Success)
            {
                if (user.IsAllowEntryControlPannel())
                {
                    HttpCookie adminCookie = new HttpCookie("SpacebuilderAdminCookie");
                    adminCookie.Value = Utility.EncryptTokenForAdminCookie(true.ToString());
                    if (!string.IsNullOrEmpty(FormsAuthentication.CookieDomain))
                    {
                        adminCookie.Domain = FormsAuthentication.CookieDomain;
                    }
                    adminCookie.HttpOnly = true;
                    Response.Cookies.Add(adminCookie);
                    FormsAuthentication.SetAuthCookie(model.UserName, false);
                }
                else
                {
                    return(Redirect(SiteUrls.Instance().ManageLogin()));
                }

                string redirectUrl = null;
                if (!string.IsNullOrEmpty(model.ReturnUrl))
                {
                    redirectUrl = model.ReturnUrl;
                }
                else
                {
                    redirectUrl = SiteUrls.Instance().ManageHome();
                }
                return(Redirect(redirectUrl));
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Home()
        {
            pageResourceManager.InsertTitlePart("后台首页");

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

            var authorizer         = new 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;

            //增加有多少个待审核评论
            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;

            //待激活的用户
            UserQuery userQuery = new UserQuery();

            userQuery.IsActivated          = false;
            ViewData["activatedUserCount"] = userService.GetUsers(userQuery, 20, 1).TotalRecords;

            //24小时新增用户数
            ViewData["userCount24H"] = userService.GetUser24H();

            //总用户数
            UserQuery usersQuery = new UserQuery();

            ViewData["userCount"] = userService.GetUsers(usersQuery, 20, 1).TotalRecords;

            //获取系统信息

            SystemInfo systemInfo = new SystemInfo();

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

            var authorizer         = new 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));
        }