Commit inicial: ITCA_API_SAP_WMS (.NET Core 3.1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
2b82744eb8
168 files changed
+11066
No files matched your search
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "5.0.8",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Business.DTO;
|
||||
using Net.Business.DTO.Authenticate;
|
||||
using Net.Data;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
public class AuthenticateController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public AuthenticateController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Obtiene Token de Acceso
|
||||
/// </summary>
|
||||
/// <param name="value">Parametros de filtros</param>
|
||||
/// <returns>Devuelve Token de Acceso</returns>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> Token([FromBody] Dto_AuthenticateRequest value)
|
||||
{
|
||||
|
||||
var objectGetAll = await _repository.Authenticate.GetToken(value.RetornaModelo());
|
||||
|
||||
if (objectGetAll.StatusCode == -1)
|
||||
{
|
||||
return BadRequest(objectGetAll);
|
||||
}
|
||||
|
||||
return Ok(objectGetAll.Data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Business.DTO.WMS.HojaRuta;
|
||||
using Net.Business.DTO.WMS.Picking;
|
||||
using Net.Business.Services.Log;
|
||||
using Net.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
public class HojaRutaController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public HojaRutaController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> POST([FromBody] Dto_HojaRutaCreate value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Master object is null"), "Hoja Ruta", "", "", "0", "0");
|
||||
return BadRequest("Master object is null");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Invalid model object"), "Hoja Ruta", "", "", "0", "0");
|
||||
return BadRequest("Invalid model object");
|
||||
}
|
||||
|
||||
var ObjectNew = await _repository.HR.SetCreateHojaRuta(value.RetornaModelo());
|
||||
|
||||
if (ObjectNew.StatusCode != 200)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Hoja Ruta", "", "", "0", "0");
|
||||
return BadRequest(ObjectNew);
|
||||
}
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Hoja Ruta", "", "", ObjectNew?.DocNum.ToString(), ObjectNew?.DocEntry.ToString());
|
||||
return Ok(ObjectNew);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Business.DTO.WMS.Inventario;
|
||||
using Net.Business.Services.Log;
|
||||
using Net.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
public class InventarioController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public InventarioController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registra Proceso de Inventario
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> Inventario([FromBody] Dto_Inventario value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Master object is null"), "Inventario", "0", "0", "0", "0");
|
||||
return BadRequest("Master object is null");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Invalid model object"), "Inventario", "0", "0", "0", "0");
|
||||
return BadRequest("Invalid model object");
|
||||
}
|
||||
|
||||
var ObjectNew = await _repository.Inventario.Create(value.RetornaModelo());
|
||||
|
||||
if (ObjectNew.StatusCode != 200)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Inventario", "0", "0", "0", "0");
|
||||
return BadRequest(ObjectNew);
|
||||
}
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Inventario", "0", "0", ObjectNew?.DocNum.ToString(), ObjectNew?.DocEntry.ToString());
|
||||
return Ok(ObjectNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Data;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
public class ItemController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public ItemController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> Stock()
|
||||
{
|
||||
var ObjectNew = await _repository.Items.GetStockItem();
|
||||
|
||||
if (ObjectNew.StatusCode != 0)
|
||||
{
|
||||
return BadRequest(ObjectNew);
|
||||
}
|
||||
return Ok(ObjectNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Business.DTO.WMS.HojaRuta;
|
||||
using Net.Business.DTO.WMS.Picking;
|
||||
using Net.Business.Services.Log;
|
||||
using Net.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
public class PickingController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public PickingController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> POST([FromBody] Dto_PickingRequest value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Master object is null"), "Picking", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest("Master object is null");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Invalid model object"), "Picking", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest("Invalid model object");
|
||||
}
|
||||
|
||||
var ObjectNew = await _repository.Picking.Create(value.RetornaModelo());
|
||||
|
||||
if (ObjectNew.StatusCode != 200)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Picking", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest(ObjectNew);
|
||||
}
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Picking", value.NumOrden, value.DocEntry.ToString(), ObjectNew?.DocNum.ToString(), ObjectNew?.DocEntry.ToString());
|
||||
return Ok(ObjectNew);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("[action]")]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> Ruta([FromBody] Dto_HojaRuta value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Master object is null"), "Hoja Ruta", value.DocEntry.ToString(), value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest("Master object is null");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Invalid model object"), "Hoja Ruta", value.DocEntry.ToString(), value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest("Invalid model object");
|
||||
}
|
||||
|
||||
var ObjectNew = await _repository.Picking.CreateHojaRuta(value.RetornaModelo());
|
||||
|
||||
if (ObjectNew.StatusCode != 200)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Hoja Ruta", value.DocEntry.ToString(), value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest(ObjectNew);
|
||||
}
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Hoja Ruta", value.DocEntry.ToString(), value.DocEntry.ToString(), ObjectNew?.DocNum.ToString(), ObjectNew?.DocEntry.ToString());
|
||||
return Ok(ObjectNew);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("HojaRuta/{docEntry}/Cerrar")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> CerrarHojaRuta(int docEntry)
|
||||
{
|
||||
var ObjectNew = await _repository.Picking.CerrarHojaRuta(docEntry);
|
||||
|
||||
if (ObjectNew.StatusCode != 200)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { docEntry })), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Hoja Ruta", docEntry.ToString(), docEntry.ToString(), "0", "0");
|
||||
return BadRequest(ObjectNew);
|
||||
}
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { docEntry })), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Hoja Ruta", docEntry.ToString(), docEntry.ToString(), ObjectNew?.DocNum.ToString(), ObjectNew?.DocEntry.ToString());
|
||||
return Ok(ObjectNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Business.DTO.WMS.Recibo;
|
||||
using Net.Business.Services.Log;
|
||||
using Net.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
public class ReciboController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public ReciboController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> POST([FromBody] Dto_ReciboRequest value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Master object is null"), "Recibo", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest("Master object is null");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Invalid model object"), "Recibo", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest("Invalid model object");
|
||||
}
|
||||
|
||||
var ObjectNew = await _repository.Recibo.Create(value.RetornaModelo());
|
||||
|
||||
if (ObjectNew.StatusCode != 200)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Recibo", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest(ObjectNew);
|
||||
}
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Recibo", value.NumOrden, value.DocEntry.ToString(), ObjectNew?.DocNum.ToString(), ObjectNew?.DocEntry.ToString());
|
||||
return Ok(ObjectNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Business.DTO.WMS.SolicitudTransferencia;
|
||||
using Net.Business.Entities;
|
||||
using Net.Business.Services.Log;
|
||||
using Net.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
// Modulo 100% nuevo (sin equivalente en el .NET original) - ver
|
||||
// docs/SOLICITUD_TRANSFERENCIA.md para el contrato completo.
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
public class SolicitudTransferenciaController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public SolicitudTransferenciaController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
// Responde 200 con el BE_ResultadoTransaccion completo en vez de 204 -
|
||||
// decision deliberada: un 204 no puede llevar body (RFC 7231 §6.3.5) y
|
||||
// muchos clientes HTTP, incluido HttpClient de .NET, no lo leen si el
|
||||
// status es 204 - ver docs/SOLICITUD_TRANSFERENCIA.md.
|
||||
[HttpPatch]
|
||||
[Route("{docEntry}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> Patch(int docEntry, [FromBody] Dto_SolicitudTransferenciaPatchRequest value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Master object is null"), "SolicitudTraslado", "0", docEntry.ToString(), "0", "0");
|
||||
return BadRequest("Master object is null");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Invalid model object"), "SolicitudTraslado", value.NumOrden, docEntry.ToString(), "0", "0");
|
||||
return BadRequest("Invalid model object");
|
||||
}
|
||||
|
||||
var error = await _repository.SolicitudTransferencia.Update(docEntry, value.RetornaModelo());
|
||||
|
||||
var result = error ?? new BE_ResultadoTransaccion<object>
|
||||
{
|
||||
DocEntry = docEntry,
|
||||
StatusCode = 200,
|
||||
Message = "Registrado Correctamente",
|
||||
AppName = "SolicitudTransferenciaRepository",
|
||||
MethodName = "Update",
|
||||
Data = value,
|
||||
};
|
||||
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(result)), "SolicitudTraslado", value.NumOrden, docEntry.ToString(), result.DocNum, result.DocEntry?.ToString());
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("{docEntry}/cerrar")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> Cerrar(int docEntry)
|
||||
{
|
||||
var error = await _repository.SolicitudTransferencia.Cerrar(docEntry);
|
||||
|
||||
var result = error ?? new BE_ResultadoTransaccion<object>
|
||||
{
|
||||
DocEntry = docEntry,
|
||||
StatusCode = 200,
|
||||
Message = "Cerrado Correctamente",
|
||||
AppName = "SolicitudTransferenciaRepository",
|
||||
MethodName = "Cerrar",
|
||||
};
|
||||
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { docEntry })), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(result)), "SolicitudTraslado", "0", docEntry.ToString(), result.DocNum, result.DocEntry?.ToString());
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
return BadRequest(result);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Net.Business.DTO.WMS.Transferencia;
|
||||
using Net.Business.Services.Log;
|
||||
using Net.Data;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ApiExplorerSettings(GroupName = "ApiSAPWMS")]
|
||||
[Authorize(AuthenticationSchemes = "Bearer")]
|
||||
public class TransferenciaController : ControllerBase
|
||||
{
|
||||
private readonly IRepositoryWrapper _repository;
|
||||
public TransferenciaController(IRepositoryWrapper repository)
|
||||
{
|
||||
this._repository = repository;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> POST([FromBody] Dto_TransferenciaRequest value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Master object is null"), "Transferencia", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest("Master object is null");
|
||||
}
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes("Invalid model object"), "Transferencia", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest("Invalid model object");
|
||||
}
|
||||
|
||||
var ObjectNew = await _repository.Transferencia.Create(value.RetornaModelo());
|
||||
|
||||
if (ObjectNew.StatusCode != 200)
|
||||
{
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Transferencia", value.NumOrden, value.DocEntry.ToString(), "0", "0");
|
||||
return BadRequest(ObjectNew);
|
||||
}
|
||||
B_Log.Add("Cubico", Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(ObjectNew)), "Transferencia", value.NumOrden, value.DocEntry.ToString(), ObjectNew?.DocNum.ToString(), ObjectNew?.DocEntry.ToString());
|
||||
return Ok(ObjectNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
|
||||
namespace Net.Business.Services
|
||||
{
|
||||
public static class ExceptionMiddlewareExtensions
|
||||
{
|
||||
public static void ConfigureExceptionHandler(this IApplicationBuilder app)
|
||||
{
|
||||
app.UseExceptionHandler(appError =>
|
||||
{
|
||||
appError.Run(async context =>
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||
context.Response.ContentType = "application/json";
|
||||
|
||||
var contextFeature = context.Features.Get<IExceptionHandlerFeature>();
|
||||
if (contextFeature != null)
|
||||
{
|
||||
|
||||
await context.Response.WriteAsync(new DtoErrorDetails()
|
||||
{
|
||||
StatusCode = context.Response.StatusCode,
|
||||
ErrorMessage = contextFeature.Error.Message.ToString()
|
||||
}.ToString());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DtoErrorDetails
|
||||
{
|
||||
public int StatusCode { get; set; }
|
||||
public string ErrorMessage { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Net.Connection;
|
||||
using Net.Data;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Net.Business.Services
|
||||
{
|
||||
public static class ServiceExtensions
|
||||
{
|
||||
|
||||
public static void ConfigureCors(this IServiceCollection services)
|
||||
{
|
||||
services.AddCors(opt =>
|
||||
{
|
||||
opt.AddPolicy("CorsPolicy",
|
||||
builder => builder.WithOrigins("http://192.168.1.4", "http://localhost:4200")
|
||||
.AllowAnyHeader()
|
||||
.WithMethods("GET", "POST", "PUT", "PATH")
|
||||
.AllowCredentials());
|
||||
});
|
||||
}
|
||||
|
||||
public static void ConfigureIISIntegration(this IServiceCollection services)
|
||||
{
|
||||
services.Configure<IISOptions>(options =>
|
||||
{
|
||||
});
|
||||
}
|
||||
|
||||
public static void ConfigureSQLConnection(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IConnectionSQL, ConnectionSQL>();
|
||||
}
|
||||
|
||||
public static void ConfigureRepositoryWrapper(this IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IRepositoryWrapper, RepositoryWrapper>();
|
||||
}
|
||||
|
||||
public static void ConfigureHttpClientServiceLayer(this IServiceCollection services)
|
||||
{
|
||||
services.AddHttpClient("bypass-ssl-validation")
|
||||
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = (
|
||||
httpRequestMessage, cert, certChain, policyErrors) =>
|
||||
{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>ITCA_API_SAP_WMS</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="M:Net.Business.Services.Controllers.AuthenticateController.Token(Net.Business.DTO.Authenticate.Dto_AuthenticateRequest)">
|
||||
<summary>
|
||||
Obtiene Token de Acceso
|
||||
</summary>
|
||||
<param name="value">Parametros de filtros</param>
|
||||
<returns>Devuelve Token de Acceso</returns>
|
||||
</member>
|
||||
<member name="M:Net.Business.Services.Controllers.InventarioController.Inventario(Net.Business.DTO.WMS.Inventario.Dto_Inventario)">
|
||||
<summary>
|
||||
Registra Proceso de Inventario
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -0,0 +1,35 @@
|
||||
using Sap.Data.Hana;
|
||||
using System;
|
||||
|
||||
namespace Net.Business.Services.Log
|
||||
{
|
||||
public class B_Log
|
||||
{
|
||||
public static string Add(string Origen, byte[] Trama_Origen, byte[] Trama_Respuesta, string Proceso, string Nro_Orden, string DocEntry, string DocNumSAP, string DocEntrySAP)
|
||||
{
|
||||
string DB = "ITCA_LOG_INTEGRACION";
|
||||
string Code = System.Guid.NewGuid().ToString();
|
||||
string Fecha = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
HanaConnection hana = new HanaConnection(Net.Data.LocalData.ConnectionString);
|
||||
hana.Open();
|
||||
HanaCommand hanaCommand = hana.CreateCommand();
|
||||
hanaCommand.CommandText = $"INSERT INTO \"ITC_WMS_SAP\".\"{DB}\" (\"CODIGO\", \"ORIGEN\", \"TRAMA_ORIGEN\" , \"TRAMA_RESPUESTA\", \"PROCESO\", \"FECHA\", \"NRO_ORDEN\", \"DOCENTRY\", \"DOCNUMSAP\", \"DOCENTRYSAP\", \"HORA\") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
hanaCommand.Parameters.Add("CODIGO", HanaDbType.VarChar).Value = Code;
|
||||
hanaCommand.Parameters.Add("ORIGEN", HanaDbType.VarChar).Value = Origen;
|
||||
hanaCommand.Parameters.Add("TRAMA_ORIGEN", HanaDbType.Blob).Value = Trama_Origen;
|
||||
hanaCommand.Parameters.Add("TRAMA_RESPUESTA", HanaDbType.Blob).Value = Trama_Respuesta;
|
||||
hanaCommand.Parameters.Add("PROCESO", HanaDbType.VarChar).Value = Proceso;
|
||||
hanaCommand.Parameters.Add("FECHA", HanaDbType.Date).Value = Fecha;
|
||||
hanaCommand.Parameters.Add("NRO_ORDEN", HanaDbType.VarChar).Value = Nro_Orden;
|
||||
hanaCommand.Parameters.Add("DOCENTRY", HanaDbType.VarChar).Value = DocEntry;
|
||||
hanaCommand.Parameters.Add("DOCNUMSAP", HanaDbType.VarChar).Value = DocNumSAP;
|
||||
hanaCommand.Parameters.Add("DOCENTRYSAP", HanaDbType.VarChar).Value = DocEntrySAP;
|
||||
hanaCommand.Parameters.Add("HORA", HanaDbType.VarChar).Value = DateTime.Now.ToString("HH:mm:ss");
|
||||
hanaCommand.CommandType = System.Data.CommandType.Text;
|
||||
hanaCommand.ExecuteNonQuery();
|
||||
hana.Close();
|
||||
|
||||
return Code;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AssemblyName>ITCA_API_SAP_WMS</AssemblyName>
|
||||
<UserSecretsId>24763424-3300-4c85-87e3-503f8fdebd14</UserSecretsId>
|
||||
<!-- Antes solo estaba condicionado a Debug|AnyCPU - un "dotnet publish -c Release"
|
||||
(lo normal para IIS) se quedaba sin este archivo, y Startup.cs revienta con
|
||||
FileNotFoundException al armar Swagger (IncludeXmlComments) si no existe. -->
|
||||
<NoWarn>1701;1702;1591</NoWarn>
|
||||
<DocumentationFile>ITCA_API_SAP_WMS.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.8" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Net.Business.DTO\Net.Business.DTO.csproj" />
|
||||
<ProjectReference Include="..\Net.Connection\Net.Connection.csproj" />
|
||||
<ProjectReference Include="..\Net.Data\Net.Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="resources\img\" />
|
||||
<Folder Include="resources\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Sap.Data.Hana.Core.v2.1">
|
||||
<HintPath>..\..\..\..\..\..\..\..\Program Files\sap\hdbclient\dotnetcore\v2.1\Sap.Data.Hana.Core.v2.1.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,47 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Net.Business.Services
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
|
||||
//public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
// Host.CreateDefaultBuilder(args)
|
||||
// .ConfigureWebHostDefaults(webBuilder =>
|
||||
// {
|
||||
// webBuilder.
|
||||
// UseStartup<Startup>()
|
||||
// .UseContentRoot(Directory.GetCurrentDirectory())
|
||||
// .UseKestrel(options =>
|
||||
// {
|
||||
// options.Limits.MaxRequestBodySize = long.MaxValue;
|
||||
// })
|
||||
// .UseIISIntegration();
|
||||
// //.UseKestrel(options =>
|
||||
// //{
|
||||
// // options.Limits.MaxRequestBodySize = long.MaxValue;
|
||||
// //})
|
||||
|
||||
// });
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Debug\netcoreapp3.1\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<ProjectGuid>b4be6148-6e1f-4bb9-b399-424c4e6bf4c0</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Debug\netcoreapp3.1\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<ProjectGuid>b4be6148-6e1f-4bb9-b399-424c4e6bf4c0</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Debug\netcoreapp3.1\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<ProjectGuid>b4be6148-6e1f-4bb9-b399-424c4e6bf4c0</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Net.Business.Services": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
},
|
||||
"IIS Desarrollo": {
|
||||
"commandName": "IIS",
|
||||
"workingDirectory": "C:\\inetpub\\wwwroot\\integracion",
|
||||
"launchUrl": "http://localhost/integracion"
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iis": {
|
||||
"applicationUrl": "http://localhost/integracion",
|
||||
"sslPort": 0
|
||||
},
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:54791",
|
||||
"sslPort": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Net.Business.Services
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
Net.Data.LocalData.Configure(configuration);
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.ConfigureCors();
|
||||
services.ConfigureIISIntegration();
|
||||
services.ConfigureSQLConnection();
|
||||
services.ConfigureHttpClientServiceLayer();
|
||||
|
||||
/*Linea con el cual obtenemos datos de la cabecera*/
|
||||
services.AddSingleton<Microsoft.AspNetCore.Http.IHttpContextAccessor, Microsoft.AspNetCore.Http.HttpContextAccessor>();
|
||||
|
||||
//Autenticacion
|
||||
string semilla = Configuration.GetSection("ParametrosTokenConfig").GetValue<string>("Semilla");
|
||||
string emisor = Configuration.GetSection("ParametrosTokenConfig").GetValue<string>("Emisor");
|
||||
string destinatario = Configuration.GetSection("ParametrosTokenConfig").GetValue<string>("Destinatario");
|
||||
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(semilla));
|
||||
|
||||
services.AddAuthentication
|
||||
(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddJwtBearer(opt => {
|
||||
opt.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateLifetime = true,
|
||||
ValidIssuer = emisor,
|
||||
ValidAudience = destinatario,
|
||||
IssuerSigningKey = key
|
||||
};
|
||||
|
||||
});
|
||||
services.ConfigureRepositoryWrapper();
|
||||
|
||||
/*De aqui en adelante configuracion de documentacion de nuestra API*/
|
||||
services.AddSwaggerGen(options => {
|
||||
options.SwaggerDoc("ApiSAPWMS", new Microsoft.OpenApi.Models.OpenApiInfo()
|
||||
{
|
||||
Title = "API SAP - WMS",
|
||||
Version = "1",
|
||||
Description = "API Integración SAP / WMS",
|
||||
Contact = new Microsoft.OpenApi.Models.OpenApiContact()
|
||||
{
|
||||
Name = "IT Consultores Asociados",
|
||||
},
|
||||
License = new Microsoft.OpenApi.Models.OpenApiLicense()
|
||||
{
|
||||
Name = "MIT License",
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var archivoXmlComentarios = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
var rutaApiComentarios = Path.Combine(AppContext.BaseDirectory, archivoXmlComentarios);
|
||||
|
||||
options.IncludeXmlComments(rutaApiComentarios);
|
||||
|
||||
/*Primero definir el esquema de seguridad*/
|
||||
options.AddSecurityDefinition("Bearer", new Microsoft.OpenApi.Models.OpenApiSecurityScheme
|
||||
{
|
||||
Description = "Autenticacion JWT (Bearer)",
|
||||
Type = Microsoft.OpenApi.Models.SecuritySchemeType.Http,
|
||||
Scheme = "bearer"
|
||||
});
|
||||
|
||||
options.AddSecurityRequirement(new Microsoft.OpenApi.Models.OpenApiSecurityRequirement {
|
||||
{
|
||||
new Microsoft.OpenApi.Models.OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new Microsoft.OpenApi.Models.OpenApiReference
|
||||
{
|
||||
Id = "Bearer",
|
||||
Type = Microsoft.OpenApi.Models.ReferenceType.SecurityScheme
|
||||
}
|
||||
}, new List<string>()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.ConfigureExceptionHandler();
|
||||
|
||||
//Linea para documentacion api
|
||||
app.UseSwagger();
|
||||
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
options.SwaggerEndpoint("swagger/ApiSAPWMS/swagger.json", "API SAP - WMS");
|
||||
options.RoutePrefix = "";
|
||||
});
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseCors("CorsPolicy");
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "",
|
||||
"Microsoft": "",
|
||||
"Microsoft.Hosting.Lifetime": ""
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "",
|
||||
"ConnectionStrings": {
|
||||
"cnnSql": ""
|
||||
},
|
||||
"EntornoConection": {
|
||||
"Entorno": "",
|
||||
"EntornoSAP": ""
|
||||
},
|
||||
"ParametersConectionDev": {
|
||||
"Source": "",
|
||||
"Catalog": "",
|
||||
"User": "",
|
||||
"Password": ""
|
||||
},
|
||||
"ParametersConectionProd": {
|
||||
"Source": "",
|
||||
"Catalog": "",
|
||||
"User": "",
|
||||
"Password": ""
|
||||
},
|
||||
"ParametrosTokenConfig": {
|
||||
"Semilla": "",
|
||||
"Emisor": "",
|
||||
"Destinatario": ""
|
||||
},
|
||||
"SapServiceLayer": {
|
||||
"url": "",
|
||||
"company": "",
|
||||
"user": "",
|
||||
"password": ""
|
||||
},
|
||||
"Hana": {
|
||||
"server": "",
|
||||
"user": "",
|
||||
"password": ""
|
||||
},
|
||||
"EmailSenderOptions": {
|
||||
"Port": "",
|
||||
"Password": "",
|
||||
"EnableSsl": "",
|
||||
"Email": "",
|
||||
"Host": ""
|
||||
},
|
||||
"RutaAnexo": {
|
||||
"UbicacionAdjunto": ""
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<security>
|
||||
<requestFiltering>
|
||||
<requestLimits maxAllowedContentLength="2147483648" />
|
||||
</requestFiltering>
|
||||
</security>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="bin\Debug\netcoreapp3.1\ITCA_API_SAP_WMS.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
</configuration>
|
||||
<!--ProjectGuid: b4be6148-6e1f-4bb9-b399-424c4e6bf4c0-->
|
||||
Reference in new issue
Block a user