public ActionResult GetReport(int id) { var reportInfo = ReportService.GetReportInfoById(id); BaseReportViewModel viewModel = null; var viewModelType = reportInfo == null ? null : Type.GetType(reportInfo.ViewModelName); if (viewModelType != null && viewModelType == typeof(StatisticalReportViewModel)) { var reportData = ReportService.GetReportById(reportInfo.ReportId, new ReportParameter { TableName = reportInfo.TableName, ColumnList = reportInfo.ColumnList ?? "a.*" }); viewModel = new StatisticalReportViewModel(reportInfo.ReportId, (StandardReport)reportData, (StandardReport) ReportService.GetReportById(reportInfo.ReportId, new ReportParameter { RowName = "1", TableName = reportInfo.TableName, ColumnList = reportInfo.ColumnList })); } else { viewModel = new BasicReportViewModel(reportInfo.ReportId, new StandardReport(id)); } viewModel.Name = reportInfo.DisplayName; viewModel.Initialization(); if (viewModel is StatisticalReportViewModel) { ViewData["IsStatisticReport_" + reportInfo.ReportId] = false; var themeName = ThemeHelper.GetTheme(Request); ((StatisticalReportViewModel)viewModel).TopChartModel.Theme = themeName; ((StatisticalReportViewModel)viewModel).BottomChartModel.Theme = themeName; } return(View(reportInfo == null ? "BasicReport" : reportInfo.ViewName, viewModel)); }
public ActionResult GetDetailedReportByRowName(int reportId, string startDate, string endDate, string unit, string rowName) { if (string.IsNullOrEmpty(rowName)) { return(new EmptyResult()); } var rowId = 0; if (!int.TryParse(rowName, out rowId)) { return(new EmptyResult()); } var reportInfo = ReportService.GetReportInfoById(reportId); var reportData = ReportService.GetReportById(reportId, new ReportParameter { StartDate = string.IsNullOrEmpty(startDate) ? (DateTime?)null : DateTime.Parse(startDate), EndDate = string.IsNullOrEmpty(endDate) ? (DateTime?)null : DateTime.Parse(endDate), Unit = unit, RowName = rowName.Trim(), TableName = reportInfo.TableName, ColumnList = string.IsNullOrEmpty(endDate) ? null : reportInfo.ColumnList }); var viewModel = new StatisticalReportViewModel(reportId, (StandardReport)reportData); viewModel.Name = reportInfo.DisplayName; viewModel.Unit = GetUnit(unit); viewModel.Initialization(); var themeName = ThemeHelper.GetTheme(Request); viewModel.TopChartModel.Theme = themeName; viewModel.BottomChartModel.Theme = themeName; ViewData["StartDate_" + reportId] = startDate; ViewData["EndDate_" + reportId] = endDate; ViewData["Unit_" + reportId] = unit; ViewData["RowName_" + reportId] = rowName.Trim(); return(View("_StatisticalReportDetailTable", viewModel)); }