ServicesParamsModels.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using Microsoft.AspNetCore.Http;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Net;
  7. using System.Text;
  8. namespace FastReport.Web.Services
  9. {
  10. public class SaveReportResponseModel
  11. {
  12. public int Code { get; set; }
  13. public string Msg { get; set; }
  14. public bool IsError { get; set; }
  15. }
  16. public class SaveReportServiceParams
  17. {
  18. public Stream RequestBody { get; set; }
  19. public string Scheme { get; set; }
  20. public string Host { get; set; }
  21. public int? Port { get; set; }
  22. public IRequestCookieCollection Cookies { get; set; }
  23. public static SaveReportServiceParams ParseRequest(HttpRequest request)
  24. {
  25. var @params = new SaveReportServiceParams()
  26. {
  27. Scheme = request.Scheme,
  28. Host = request.Host.Host,
  29. Port = request.Host.Port,
  30. RequestBody = request.Body,
  31. Cookies = request.Cookies
  32. };
  33. return @params;
  34. }
  35. }
  36. public sealed class CustomViewModel
  37. {
  38. public string TableName { get; set; }
  39. public string SqlQuery { get; set; }
  40. }
  41. #region GetReportServiceParams
  42. public class GetReportServiceParams
  43. {
  44. public ClickParams ClickParams { get; set; }
  45. public DialogParams DialogParams { get; set; }
  46. public ReportTabParams ReportTabParams { get; set; }
  47. public ReportPageParams ReportPageParams { get; set; }
  48. public string RenderBody { get; set; }
  49. public string SkipPrepare { get; set; }
  50. public string ForceRefresh { get; set; }
  51. public string Zoom { get; set; }
  52. public static GetReportServiceParams ParseRequest(HttpRequest request)
  53. {
  54. var reportServiceParams = new GetReportServiceParams
  55. {
  56. SkipPrepare = request.Query["skipPrepare"].ToString(),
  57. ForceRefresh = request.Query["forceRefresh"].ToString(),
  58. RenderBody = request.Query["renderBody"].ToString(),
  59. };
  60. reportServiceParams.Zoom = request.Query["zoom"].ToString();
  61. reportServiceParams.DialogParams = new DialogParams();
  62. reportServiceParams.ReportPageParams = new ReportPageParams
  63. {
  64. GoTo = request.Query["goto"].ToString(),
  65. Bookmark = request.Query["bookmark"].ToString(),
  66. DetailedReport = request.Query["detailed_report"].ToString(),
  67. DetailedPage = request.Query["detailed_page"].ToString()
  68. };
  69. reportServiceParams.ReportTabParams = new ReportTabParams
  70. {
  71. SetTab = request.Query["settab"].ToString(),
  72. CloseTab = request.Query["closetab"].ToString()
  73. };
  74. reportServiceParams.ClickParams = new ClickParams
  75. {
  76. Click = request.Query["click"].ToString(),
  77. CheckBoxClick = request.Query["checkbox_click"].ToString(),
  78. TextEdit = request.Query["text_edit"].ToString(),
  79. AdvMatrixClick = request.Query["advmatrix_click"].ToString()
  80. };
  81. if (!reportServiceParams.ClickParams.TextEdit.IsNullOrEmpty())
  82. reportServiceParams.ClickParams.Text = request.Form["text"].ToString();
  83. reportServiceParams.DialogParams.ParseRequest(request);
  84. return reportServiceParams;
  85. }
  86. }
  87. public class ClickParams
  88. {
  89. public string Click { get; set; }
  90. public string CheckBoxClick { get; set; }
  91. public string TextEdit { get; set; }
  92. public string Text { get; set; }
  93. public string AdvMatrixClick { get; set; }
  94. }
  95. public class DialogParams
  96. {
  97. public string DialogN { get; set; }
  98. public string DialogControlName { get; set; }
  99. public string DialogEventName { get; set; }
  100. public string DialogData { get; set; }
  101. public void ParseRequest(HttpRequest request)
  102. {
  103. DialogN = request.Query["dialog"].ToString();
  104. DialogControlName = request.Query["control"].ToString();
  105. DialogEventName = request.Query["event"].ToString();
  106. DialogData = request.Query["data"].ToString();
  107. }
  108. }
  109. public class ReportTabParams
  110. {
  111. public string SetTab { get; set; }
  112. public string CloseTab { get; set; }
  113. }
  114. public class ReportPageParams
  115. {
  116. public string GoTo { get; set; }
  117. public string Bookmark { get; set; }
  118. public string DetailedReport { get; set; }
  119. public string DetailedPage { get; set; }
  120. }
  121. #endregion
  122. }