main.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using FastReport.Web.Infrastructure;
  3. namespace FastReport.Web
  4. {
  5. partial class WebReport
  6. {
  7. string template_FR => $"fr{ID}";
  8. internal string template_ROUTE_BASE_PATH => WebUtils.ToUrl(FastReportGlobal.FastReportOptions.RoutePathBaseRoot, FastReportGlobal.FastReportOptions.RouteBasePath);
  9. internal string template_export_url(string exportFormat) => $"{template_ROUTE_BASE_PATH}/preview.exportReport?reportId={ID}&exportFormat={exportFormat}";
  10. internal string templte_email_export_url => $"{template_ROUTE_BASE_PATH}/preview.sendEmail?reportId={ID}";
  11. internal string template_print_url(string printMode) => $"{template_ROUTE_BASE_PATH}/preview.printReport?reportId={ID}&printMode={printMode}";
  12. //string template_TOOLBAR_HEIGHT_FACTOR => 40px * ToolbarHeight;
  13. internal string GetResource(string resourceName) => ResourceLoader.GetContent(resourceName);
  14. internal string GerResourceBase64(string resourceName) => Convert.ToBase64String(ResourceLoader.GetBytes(resourceName));
  15. string template_render(bool renderBody)
  16. {
  17. #if !OPENSOURCE
  18. var needModal = Toolbar.Exports.EnableSettings || Toolbar.Exports.ShowEmailExport;
  19. #else
  20. var needModal = Toolbar.Exports.EnableSettings;
  21. #endif
  22. return $@"
  23. <div class=""{template_FR}-container"">
  24. <style>
  25. {template_style()}
  26. </style>
  27. <script>
  28. {template_script()}
  29. </script>
  30. <div class=""{template_FR}-spinner"" {(renderBody ? @"style=""display:none""" : "")}>
  31. {GetResource("spinner.svg")}
  32. </div>
  33. {template_toolbar(renderBody)}
  34. {template_body(renderBody)}
  35. {(needModal ? template_modalcontainer() : "")}
  36. ";
  37. }
  38. }
  39. }