예제 #1
0
        public ActionResult CreateReport(ReportViewModel reportViewModel)
        {
            try
            {
                var newReport = reportViewModel.MapTo<ReportViewModel, Report>();

                //Checking consistency between column Name and Labels
                CheckColumnsConfig(reportViewModel.Query, reportViewModel.ColumnLabels, reportViewModel.OutPut);

                newReport.ColumnLabels = AdjustColumnLabels(reportViewModel).GetCommaSeparatedTokens();
                newReport.SubReports = ParseSubReports(reportViewModel.SubReportIds, reportViewModel.SubReportColumns, reportViewModel.IndexParamNames);

                _virtualOfficeToolManager.AddReport(newReport);

                return RedirectToAction("Index");

            }
            catch (Exception exception)
            {
                ModelState.AddModelError("", string.Format("Errors while trying to add a new Report. Please, try again! More details:{0}", exception.Message));

                return View("CreateReport", reportViewModel);
            }
        }
예제 #2
0
        public ActionResult RemoveReport(ReportViewModel reportViewModel)
        {
            try
            {
                _virtualOfficeToolManager.RemoveReport(reportViewModel.Id);

                return RedirectToAction("Index");

            }
            catch (Exception exception)
            {
                return null;
            }
        }
예제 #3
0
        private IEnumerable<string> AdjustColumnLabels(ReportViewModel report)
        {
            var originalOutPut = _virtualOfficeToolManager.GetReportColumnNamesExt(report.Query).ToList();

            var outPut = report.OutPut;

            var columnLabels = report.ColumnLabels;

            return from column in outPut select originalOutPut.FindIndex(col => col == column) into index where index >= 0 select columnLabels[index];
        }
예제 #4
0
        public ActionResult ExecuteEditReport(ReportViewModel reportViewModel)
        {
            try
            {
                ////Removing the Parsing on Column Names
                //reportViewModel.OutPut = UnParseColumnName(reportViewModel.OutPut);
                //reportViewModel.UserFilters = UnParseColumnName(reportViewModel.UserFilters);

                var newReport = reportViewModel.MapTo<ReportViewModel, Report>();

                //Checking consistency between column Name and Labels
                CheckColumnsConfig(reportViewModel.Query, reportViewModel.ColumnLabels, reportViewModel.OutPut);

                newReport.ColumnLabels = AdjustColumnLabels(reportViewModel).GetCommaSeparatedTokens();
                newReport.SubReports = ParseSubReports(reportViewModel.SubReportIds, reportViewModel.SubReportColumns, reportViewModel.IndexParamNames);

                //If the columns are completely empty it's because they were not modified so the old one is kept
                if (string.IsNullOrEmpty(newReport.OutPut))
                {
                    var report = _virtualOfficeToolManager.GetReport(newReport.Id);

                    newReport.OutPut = report.OutPut;
                }

                _virtualOfficeToolManager.UpdateReport(newReport);

                return RedirectToAction("Index");

            }
            catch (Exception exception)
            {
                ModelState.AddModelError("", string.Format("Errors while trying to add a new Report. Please, try again! More details:{0}", exception.Message));

                return View("EditReport", reportViewModel);
            }
        }