예제 #1
0
        public ActionResult BlobActivity()
        {
            var model = new BlobActivityViewModel();

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

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

            model.ViewEvents = true;
            model.DownloadEvents = true;

            model.CurrentPage = 1;

            IList<int> eventtypes = new List<int>();
            eventtypes.Add((int)EventType.View);
            eventtypes.Add((int)EventType.Download);

            DateTime fromdate = DateTimeHelper.FromLocalTime(model.FromDate);
            DateTime todate = DateTimeHelper.FromLocalTime(NormalizeToDate(model.ToDate));

            var totalPages = 0;
            model.BlobEvents = this.reportService.GetBlobEvents(fromdate, todate, eventtypes, DefaultPageSize, model.CurrentPage, out totalPages);
            model.TotalPages = totalPages;

            return View(model);
        }
예제 #2
0
        public ActionResult BlobActivity(BlobActivityViewModel model)
        {
            Blob blob = null;

            if (!string.IsNullOrEmpty(model.SelectedBlobName))
            {
                blob = this.blobService.GetBlobByName(model.SelectedBlobName);

                if (blob == null)
                {
                    this.ModelState.AddModelError("SelectedBlobName", "Unknown Blob");
                }
            }

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

                model.ViewEvents = Request.Form["ViewEvents"] != "false";
                model.DownloadEvents = Request.Form["DownloadEvents"] != "false";

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

                if (model.ViewEvents)
                {
                    eventtypes.Add((int)EventType.View);
                }

                if (model.DownloadEvents)
                {
                    eventtypes.Add((int)EventType.Download);
                }

                var totalPages = 0;

                if (blob == null)
                {
                    model.BlobEvents = this.reportService.GetBlobEvents(fromdate, todate, eventtypes, DefaultPageSize, model.CurrentPage, out totalPages);
                }
                else
                {
                    model.BlobEvents = this.reportService.GetBlobEventsByBlob(fromdate, todate, eventtypes, blob.BlobId, DefaultPageSize, model.CurrentPage, out totalPages);
                }

                model.TotalPages = totalPages;
            }

            return View(model);
        }