DesignerSettings.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. namespace FastReport.Web
  5. {
  6. public class DesignerSettings
  7. {
  8. public static DesignerSettings Default => new DesignerSettings();
  9. /// <summary>
  10. /// Gets or sets the locale of Designer
  11. /// </summary>
  12. public string Locale { get; set; } = "";
  13. /// <summary>
  14. /// Enable code editor in the Report Designer
  15. /// </summary>
  16. public bool ScriptCode { get; set; } = false;
  17. /// <summary>
  18. /// Gets or sets the text of configuration of Online Designer
  19. /// </summary>
  20. public string Config { get; set; } = "";
  21. /// <summary>
  22. /// Gets or sets path to the Report Designer
  23. /// </summary>
  24. public string Path { get; set; } = "/WebReportDesigner/index.html";
  25. /// <summary>
  26. /// Callback method for saving an edited report by Online Designer
  27. /// Params: reportID, report file name, report, out - message
  28. /// </summary>
  29. /// <example>
  30. /// <code>
  31. /// webReport.Designer.SaveMethod = (string reportID, string filename, string report) =>
  32. /// {
  33. /// string webRootPath = _hostingEnvironment.WebRootPath;
  34. /// string pathToSave = Path.Combine(webRootPath, filename);
  35. /// System.IO.File.WriteAllText(pathToSave, report);
  36. ///
  37. /// return "OK";
  38. /// };
  39. /// </code>
  40. /// </example>
  41. public Func<string, string, string, string> SaveMethod { get; set; }
  42. /// <summary>
  43. /// Async callback method for saving an edited report by Online Designer
  44. /// <example>
  45. /// <code>
  46. ///webReport.Designer.SaveMethodAsync = async (reportID, filename, report, token) =>
  47. ///{
  48. /// string webRootPath = _hostingEnvironment.WebRootPath;
  49. ///
  50. /// string pathToSave = Path.Combine(webRootPath, "DesignedReports", "AsyncReports", filename);
  51. /// if (!Directory.Exists(pathToSave))
  52. /// Directory.CreateDirectory(Path.GetDirectoryName(pathToSave));
  53. ///
  54. /// await System.IO.File.WriteAllTextAsync(pathToSave, report, token);
  55. /// return "OK";
  56. ///};
  57. /// </code>
  58. /// </example>
  59. /// </summary>
  60. public Func<string, string, string, CancellationToken , Task<string>> SaveMethodAsync { get; set; }
  61. /// <summary>
  62. /// Gets or sets path to a folder for save designed reports
  63. /// If value is empty then designer posts saved report in variable ReportFile on call the DesignerSaveCallBack // TODO
  64. /// </summary>
  65. public string SavePath { get; set; } = "";
  66. /// <summary>
  67. /// Gets or sets path to callback page after Save from Designer
  68. /// </summary>
  69. [Obsolete("Designer.SaveCallBack is obsolete, please use Designer.SaveMethod instead.")]
  70. public string SaveCallBack { get; set; } = "";
  71. }
  72. }