12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #if DESIGNER
- using FastReport.Web.Services;
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Net;
- using System.Threading.Tasks;
- using FastReport.Web.Infrastructure;
- using Microsoft.AspNetCore.Http;
- using System.Net.Mime;
- namespace FastReport.Web.Controllers
- {
- static partial class Controllers
- {
- [HttpGet("/designer.objects/mschart/template")]
- public static IResult GetMSChartTemplate(string name, IDesignerUtilsService designerUtilsService)
- {
- string response;
- try
- {
- response = designerUtilsService.GetMSChartTemplateXML(name);
- }
- catch (Exception ex)
- {
- return Results.NotFound();
- }
- return Results.Content(response, "application/xml");
- }
- [HttpGet("/designer.getComponentProperties")]
- public static IResult GetComponentProperties(string name, IDesignerUtilsService designerUtilsService)
- {
- var response = designerUtilsService.GetPropertiesJSON(name);
- return response.IsNullOrEmpty()
- ? Results.NotFound()
- : Results.Content(response, "application/json");
- }
- [HttpGet("/designer.getConfig")]
- public static IResult GetConfig(string reportId, IReportService reportService, IDesignerUtilsService designerUtilsService)
- {
- if (!reportService.TryFindWebReport(reportId, out var webReport))
- return Results.NotFound();
- var content = designerUtilsService.GetConfig(webReport);
- return Results.Content(content, "application/json");
- }
- [HttpGet("/designer.getFunctions")]
- public static IResult GetFunctions(string reportId,
- IReportService reportService,
- IDesignerUtilsService designerUtilsService)
- {
- if (!reportService.TryFindWebReport(reportId, out var webReport))
- return Results.NotFound();
- var buff = designerUtilsService.GetFunctions(webReport.Report);
- return Results.Content(buff, "application/xml");
- }
- [HttpPost("/designer.objects/preview")]
- public static async Task<IResult> GetDesignerObjectPreview(string reportId,
- IReportService reportService,
- IReportDesignerService reportDesignerService,
- IDesignerUtilsService designerUtilsService,
- HttpRequest request)
- {
- if (!reportService.TryFindWebReport(reportId, out var webReport))
- return Results.NotFound();
- try
- {
- var reportObj = await reportDesignerService.GetPOSTReportAsync(request.Body);
- var response = designerUtilsService.DesignerObjectPreview(webReport, reportObj);
- return Results.Content(response, MediaTypeNames.Text.Html);
- }
- catch (Exception ex)
- {
- var content = webReport.Debug ? ex.Message : "";
- return Results.BadRequest(content);
- }
- }
- }
- }
- #endif
|