66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
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 |