コード例 #1
0
ファイル: ReportController.cs プロジェクト: ShuHuiC/BlobShare
        public ActionResult UserActivity(UserActivityViewModel model)
        {
            model.LoginEvent = Request.Form["LoginEvent"] != "false";
            model.CreateUserEvent = Request.Form["CreateUserEvent"] != "false";
            model.ActivateUserEvent = Request.Form["ActivateUserEvent"] != "false";
            model.DeactivateUserEvent = Request.Form["DeactivateUserEvent"] != "false";
            model.ViewSetEvent = Request.Form["ViewSetEvent"] != "false";
            model.ViewResourceEvent = Request.Form["ViewResourceEvent"] != "false";
            model.DownloadResourceEvent = Request.Form["DownloadResourceEvent"] != "false";

            this.UserActivityGetEvents(model);

            return View(model);
        }
コード例 #2
0
ファイル: ReportController.cs プロジェクト: ShuHuiC/BlobShare
        private void UserActivityGetEvents(UserActivityViewModel model)
        {
            IList<int> userEventTypes = new List<int>();

            if (model.LoginEvent)
            {
                userEventTypes.Add((int)UserEventType.Login);
            }

            if (model.CreateUserEvent)
            {
                userEventTypes.Add((int)UserEventType.Create);
            }

            if (model.ActivateUserEvent)
            {
                userEventTypes.Add((int)UserEventType.Activation);
            }

            if (model.DeactivateUserEvent)
            {
                userEventTypes.Add((int)UserEventType.Deactivation);
            }

            IList<int> setEventTypes = new List<int>();

            if (model.ViewSetEvent)
            {
                setEventTypes.Add((int)EventType.View);
            }

            IList<int> resourceEventTypes = new List<int>();

            if (model.ViewResourceEvent)
            {
                resourceEventTypes.Add((int)EventType.View);
            }

            if (model.DownloadResourceEvent)
            {
                resourceEventTypes.Add((int)EventType.Download);
            }

            User user = null;

            if (!string.IsNullOrEmpty(model.SelectedUserName))
            {
                user = this.userService.SearchUsers(model.SelectedUserName).FirstOrDefault();

                if (user == null)
                {
                    this.ModelState.AddModelError("SelectedUserName", "Unknown User");
                }
            }

            if (this.ModelState.IsValid)
            {
                DateTime fromdate = DateTimeHelper.FromLocalTime(model.FromDate);
                DateTime todate = DateTimeHelper.FromLocalTime(NormalizeToDate(model.ToDate));

                var totalPages = 0;
                if (user == null)
                {
                    model.GenericEvents = this.reportService.GetUserEvents(fromdate, todate, userEventTypes, setEventTypes, resourceEventTypes, DefaultPageSize, model.CurrentPage, out totalPages);
                }
                else
                {
                    model.GenericEvents = this.reportService.GetUserEventsByUser(fromdate, todate, userEventTypes, setEventTypes, resourceEventTypes, user.UserId, DefaultPageSize, model.CurrentPage, out totalPages);
                }

                model.TotalPages = totalPages;
            }
        }
コード例 #3
0
ファイル: ReportController.cs プロジェクト: ShuHuiC/BlobShare
        public ActionResult UserActivity()
        {
            var model = new UserActivityViewModel();

            DateTime now = DateTime.UtcNow;
            DateTime localnow = DateTimeHelper.ToLocalTime(now);

            model.FromDate = localnow.AddDays(-7);
            model.ToDate = localnow;

            model.LoginEvent = true;
            model.CreateUserEvent = true;
            model.ActivateUserEvent = true;
            model.DeactivateUserEvent = true;
            model.ViewSetEvent = true;
            model.ViewResourceEvent = true;
            model.DownloadResourceEvent = true;

            model.CurrentPage = 1;

            this.UserActivityGetEvents(model);

            return View(model);
        }