Beispiel #1
0
        public ActionResult GenerateReport(AdminReportsViewModel adminReportsViewModel)
        {
            var reportData = _labelService.GetLabelReports(adminReportsViewModel.SideId, adminReportsViewModel.Date);
            Action <Telerik.Reporting.Report> fill = rep =>
            {
                rep.DataSource = reportData.Items;
                rep.ReportParameters["Date"].Value = reportData.Date.ToShortDateString();
            };

            Telerik.Reporting.Report report;
            report = new LabelsReport();

            fill(report);
            var instanceReportSource = new InstanceReportSource {
                ReportDocument = report
            };
            var result       = new ReportProcessor().RenderReport("PDF", instanceReportSource, null);
            var reportFolder = ConfigurationManager.AppSettings["AdminReportFolder"];

            if (!Directory.Exists(reportFolder))
            {
                Directory.CreateDirectory(reportFolder);
            }
            var reportName = string.Concat(reportFolder, reportData.Date.ToString(@"yyyyMMdd"), " - ", "daily report ", ".pdf");

            using (var fileStream = new FileStream(reportName, FileMode.Create))
            {
                fileStream.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
                fileStream.Flush();
            }
            this.ShowNotification(NotificationType.Success, string.Concat(reportName, "successfully  generated."));

            return(Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult Reports()
        {
            var model = new AdminReportsViewModel()
            {
                Date = DateTime.Today
            };

            return(PartialView("_Reports", model));
        }
Beispiel #3
0
        public IActionResult Reports()
        {
            var currentUser = _userService.GetCurrentUser(HttpContext.User);
            var users       = _ctx.ApplicationUsers.Where(u => u.UserName != currentUser.UserName);

            var model = new AdminReportsViewModel
            {
                Users = users
            };

            return(View(model));
        }
Beispiel #4
0
        public async Task <IViewComponentResult> InvokeAsync(string username)
        {
            var reports = await Task.Run(() => _reportService.GetUserReport(username));

            var user = _userService.GetUserByUsername(username);

            //var posts = _postService.GetAllByUsername(username).OrderByDescending(u => u.Reports.Count());

            var model = new AdminReportsViewModel()
            {
                Reports = reports,
                User    = user
            };


            return(View("ReportList", model));
        }