示例#1
0
 public ActionResult SqlReport(OrgSearchModel m, string report, DateTime?dt1 = null, DateTime?dt2 = null)
 {
     try
     {
         var orgs = m.FetchOrgs();
         var oids = string.Join(",", orgs.Select(oo => oo.OrganizationId));
         ViewBag.ExcelUrl    = $"/OrgSearch/SqlReportExcel/{report}";
         ViewBag.DisplayName = report.SpaceCamelCase();
         ViewBag.OrgIds      = oids;
         ViewBag.dt1         = dt1;
         ViewBag.dt2         = dt2;
         var content = CurrentDatabase.ContentOfTypeSql(report);
         if (content.Contains("pagebreak", ignoreCase: true))
         {
             var p = m.GetSqlParameters(oids, dt1, dt2, content);
             ViewBag.Results = PythonModel.PageBreakTables(CurrentDatabase, content, p);
             return(View());
         }
         ViewBag.Results = m.SqlTable(report, oids, dt1, dt2);
         return(View());
     }
     catch (Exception ex)
     {
         return(Message(ex));
     }
 }