Added View, Recipe Paramaters and Export
This commit is contained in:
39
Server/ApiControllers/ExportController.cs
Normal file
39
Server/ApiControllers/ExportController.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OI.Metrology.Server.ApiControllers;
|
||||
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using System.Text.Json;
|
||||
|
||||
[Route("api/[controller]")]
|
||||
public class ExportController : Controller, IExportController<IActionResult>
|
||||
{
|
||||
|
||||
private readonly IExportRepository _ExportRepository;
|
||||
|
||||
public ExportController(IExportRepository exportRepository) =>
|
||||
_ExportRepository = exportRepository;
|
||||
|
||||
[HttpGet]
|
||||
[Route("export")]
|
||||
public IActionResult GetExport(HeaderCommon headerCommon) =>
|
||||
Content(_ExportRepository.GetExport(headerCommon));
|
||||
|
||||
[HttpGet]
|
||||
[Route("headers")]
|
||||
public IActionResult GetHeaders(HeaderCommon headerCommon) =>
|
||||
Json(_ExportRepository.GetHeaders(headerCommon), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
||||
|
||||
[HttpGet]
|
||||
[Route("logistics")]
|
||||
public IActionResult GetLogistics(HeaderCommon headerCommon) =>
|
||||
Json(_ExportRepository.GetLogistics(headerCommon), new JsonSerializerOptions { PropertyNamingPolicy = null, WriteIndented = true });
|
||||
|
||||
[HttpGet]
|
||||
[Route("pdsf")]
|
||||
[Route("processDataStandardFormat")]
|
||||
public IActionResult GetProcessDataStandardFormat(HeaderCommon headerCommon) =>
|
||||
Content(_ExportRepository.GetProcessDataStandardFormat(headerCommon));
|
||||
|
||||
}
|
@ -32,7 +32,7 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
|
||||
|
||||
[HttpPost]
|
||||
[Route("{tooltype}")]
|
||||
public IActionResult Data(string tooltype, [FromBody] JToken jsonbody)
|
||||
public IActionResult Post(string tooltype, [FromBody] JToken jsonbody)
|
||||
{
|
||||
IPAddress? remoteIP = HttpContext.Connection.RemoteIpAddress;
|
||||
if (!_InboundRepository.IsIPAddressAllowed(_AppSettings.InboundApiAllowedIPList, remoteIP))
|
||||
@ -42,6 +42,18 @@ public partial class InboundController : ControllerBase, IInboundController<IAct
|
||||
}
|
||||
else
|
||||
{
|
||||
if (jsonbody is null || !jsonbody.Any())
|
||||
{
|
||||
if (!Request.Body.CanRead)
|
||||
jsonbody = JToken.Parse("{}");
|
||||
else
|
||||
{
|
||||
using Stream stream = Request.Body;
|
||||
_ = stream.Seek(0, SeekOrigin.Begin);
|
||||
string json = new StreamReader(stream).ReadToEnd();
|
||||
jsonbody = JToken.Parse(json);
|
||||
}
|
||||
}
|
||||
DataResponse dataResponse = _InboundRepository.Data(_MetrologyRepository, _InboundDataService, tooltype, jsonbody);
|
||||
if (!dataResponse.Errors.Any())
|
||||
return Ok(dataResponse);
|
||||
|
Reference in New Issue
Block a user