Esempio n. 1
0
        public ActionResult List()
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
            {
                return(AccessDeniedView());
            }

            var customers = _customerService.GetOnlineCustomers(DateTime.UtcNow.AddMinutes(-_customerSettings.OnlineCustomerMinutes),
                                                                null, 0, _adminAreaSettings.GridPageSize);

            var model = new GridModel <OnlineCustomerModel>
            {
                Data = customers.Select(x =>
                {
                    return(new OnlineCustomerModel()
                    {
                        Id = x.Id,
                        CustomerInfo = x.IsRegistered() ? x.Email : _localizationService.GetResource("Admin.Customers.Guest"),
                        LastIpAddress = x.LastIpAddress,
                        Location = _geoCountryLookup.LookupCountryName(x.LastIpAddress),
                        LastActivityDate = _dateTimeHelper.ConvertToUserTime(x.LastActivityDateUtc, DateTimeKind.Utc),
                        LastVisitedPage = x.GetAttribute <string>(SystemCustomerAttributeNames.LastVisitedPage)
                    });
                }),
                Total = customers.TotalCount
            };

            return(View(model));
        }
Esempio n. 2
0
        public ActionResult List(DataTablesParam dataTableParam)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageUsers))
            {
                return(AccessDeniedView());
            }

            var users = _userService.GetOnlineUsers(DateTime.UtcNow.AddMinutes(-_userSettings.OnlineUserMinutes),
                                                    null, dataTableParam.PageIndex, dataTableParam.PageSize);

            var total  = users.Count();
            var result = new DataTablesData
            {
                iTotalRecords        = total,
                iTotalDisplayRecords = total,
                sEcho  = dataTableParam.sEcho,
                aaData = users.Select(x =>
                {
                    return(new OnlineUserModel()
                    {
                        Id = x.Id,
                        UserInfo = x.IsRegistered() ? x.Email : _localizationService.GetResource("Admin.Users.Guest"),
                        LastIpAddress = x.LastIpAddress,
                        Location = _geoCountryLookup.LookupCountryName(x.LastIpAddress),
                        LastActivityDate = _dateTimeHelper.ConvertToUserTime(x.LastActivityDateUtc, DateTimeKind.Utc),
                        LastVisitedPage = x.GetAttribute <string>(SystemUserAttributeNames.LastVisitedPage)
                    });
                }).Cast <object>().ToArray(),
            };

            return(new JsonResult
            {
                Data = result
            });
        }