last commit before adding libs to test out report rendering, this is the snapshot to reset back to after testing if things get mangled up
This commit is contained in:
66
server/AyaNova/Controllers/ReportController.cs
Normal file
66
server/AyaNova/Controllers/ReportController.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Routing;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using AyaNova.Models;
|
||||||
|
using AyaNova.Api.ControllerHelpers;
|
||||||
|
using AyaNova.Biz;
|
||||||
|
|
||||||
|
|
||||||
|
namespace AyaNova.Api.Controllers
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[ApiVersion("8.0")]
|
||||||
|
[Route("api/v{version:apiVersion}/report")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
[Authorize]
|
||||||
|
public class ReportController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly AyContext ct;
|
||||||
|
private readonly ILogger<ReportController> log;
|
||||||
|
private readonly ApiServerState serverState;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ctor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dbcontext"></param>
|
||||||
|
/// <param name="logger"></param>
|
||||||
|
/// <param name="apiServerState"></param>
|
||||||
|
public ReportController(AyContext dbcontext, ILogger<ReportController> logger, ApiServerState apiServerState)
|
||||||
|
{
|
||||||
|
ct = dbcontext;
|
||||||
|
log = logger;
|
||||||
|
serverState = apiServerState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("render/{test}")]
|
||||||
|
public async Task<IActionResult> GetTestReport([FromRoute] string test)
|
||||||
|
{
|
||||||
|
if (!serverState.IsOpen)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
|
|
||||||
|
switch(test){
|
||||||
|
case "chrome-reddit-to-pdf":
|
||||||
|
//first test, just render a web page to pdf and return it
|
||||||
|
//return PhysicalFile(filePath, mimetype, dbObject.DisplayFileName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return NotFound(test);
|
||||||
|
|
||||||
|
//return PhysicalFile(filePath, mimetype, dbObject.DisplayFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//https://github.com/hardkoded/puppeteer-sharp
|
||||||
|
|
||||||
|
//------------
|
||||||
|
|
||||||
|
|
||||||
|
}//eoc
|
||||||
|
}//eons
|
||||||
Reference in New Issue
Block a user