Repository navigation
Expand file tree
/
Copy pathGetReportController.cs
More file actions
66 lines (51 loc) · 1.74 KB
/
Copy pathGetReportController.cs
File metadata and controls
66 lines (51 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using FastReport.Web.Cache;
using FastReport.Web.Services;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using static System.Net.Mime.MediaTypeNames;
namespace FastReport.Web.Controllers
{
public sealed class GetReportController : ApiControllerBase
{
private readonly IReportService _reportService;
public GetReportController(IReportService reportService)
{
_reportService = reportService;
}
public sealed class GetReportParams
{
public string ReportId { get; set; }
public string RenderBody { get; set; }
//public bool RenderBody { get; set; } = false;
public string SkipPrepare { get; set; }
public string ForceRefresh { get; set; }
}
[HttpPost]
[Route("/_fr/preview.getReport")]
public IActionResult GetReport(string reportId, [FromQuery] GetReportServiceParams query)
{
if (!_reportService.TryFindWebReport(reportId, out WebReport webReport))
return new NotFoundResult();
query.ParseRequest(Request);
string render = _reportService.GetReport(webReport, query);
if (render.IsNullOrEmpty())
return new OkResult();
return new ContentResult()
{
StatusCode = (int)HttpStatusCode.OK,
ContentType = "text/html",
Content = render,
};
}
[HttpPost]
[Route("/_fr/preview.touchReport")]
public IActionResult TouchReport(string reportId)
{
_reportService.Touch(reportId);
return Ok();
}
}
}