Commit e59eba09 authored by Brayan Sarmiento's avatar Brayan Sarmiento
Browse files

Conexion con el POSBC

parent 9cdff4a9
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
{
public string Referencia { get; set; } = "scsns:AddCustomerBirthdate";
public string NombreElementoXMLDatos { get; set; } = "./AddCustomerBirthdateRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(AddCustomerBirthdateRequest));
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:AddCustomer";
public string NombreElementoXMLDatos { get; set; } = "./AddCustomerRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(AddCustomerRequest));
......
......@@ -22,7 +22,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:AddItem";
public string NombreElementoXMLDatos { get; set; } = "./AddItemRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(AddItemRequestDTO));
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:AddReceiptLines";
public string NombreElementoXMLDatos { get; set; } = "./AddReceiptLinesRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:AddTender";
public string NombreElementoXMLDatos { get; set; } = "./AddTenderRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(AddTenderRequest));
......
......@@ -21,7 +21,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:CancelAction";
public string NombreElementoXMLDatos { get; set; } = "./CancelActionRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:GetTotals";
public string NombreElementoXMLDatos { get; set; } = "./GetTotalsRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(GetTotalsRequest));
......
......@@ -18,7 +18,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:Initialize";
public string NombreElementoXMLDatos { get; set; } = "./InitializeRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
if (nodo == null)
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:PrintCurrentReceipts";
public string NombreElementoXMLDatos { get; set; } = "./PrintCurrentReceiptsRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(PrintCurrentReceiptsRequest));
......
......@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:QueryStatus";
public string NombreElementoXMLDatos { get; set; } = "./QueryStatusRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
if (nodo == null)
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:RemoveReceiptLines";
public string NombreElementoXMLDatos { get; set; } = "./RemoveReceiptLinesRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
......
......@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:ReportStatusEvents";
public string NombreElementoXMLDatos { get; set; } = "./ReportStatusEventsRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
if (nodo == null)
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:ReprintReceipts";
public string NombreElementoXMLDatos { get; set; } = "./ReprintReceiptsRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(ReprintReceiptsRequestDTO));
......
......@@ -17,7 +17,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:SignOff";
public string NombreElementoXMLDatos { get; set; } = "./SignOffRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
if (nodo == null)
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:Suspend";
public string NombreElementoXMLDatos { get; set; } = "./SuspendTransactionRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(SuspendTransactionRequest));
......
......@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:Terminate";
public string NombreElementoXMLDatos { get; set; } = "./TerminateRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(TerminateRequestDTO));
......
......@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
{
public string Referencia { get; set; } = "scsns:VoidTransaction";
public string NombreElementoXMLDatos { get; set; } = "./VoidTransactionRequest";
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml)
public DTOBase ObtieneDTO(int idSesion, TipoMensaje tipoMensaje, XmlElement docXml, string mensajeXml, byte[] bufferEntrada, int cantBytes)
{
XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(VoidTransactionDTO));
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace gatewayGK.POSBC
{
/// <summary>
/// Esta clase almacena valores requeridos
/// para la operación del SCO con la operación de la POSBC,
/// valores que deben ser compartidos entre comandos.
/// </summary>
public class EntornoPOSBC
{
public byte[] BufferEntrada { get; set; } = new byte[0];
/// <summary>
/// Propiedad que toma el buffer de entrada de CHEC para enviarselo al POSBC
/// </summary>
public int CantBytes { get; set; } = 0;
/// <summary>
/// Propiedad que toma la cantidad de bytes que vienen de CHEC
/// </summary>
public string TipoEntorno { get; set; } = "posbc";
/// <summary>
/// tipo de entorno que nos encontramos
/// </summary>
}
}
using EvaPosSrvDTO;
using EvaPosSrvResp;
using GatewaySCO;
using Serilog;
using System;
using System.Collections.Generic;
......@@ -29,14 +30,16 @@ namespace gatewayGK.POSBC
/// </summary>
public Respuestas Ejecutar()
{
string direccionIpPosbc = "10.89.81.102";
string direccionIpPosbc = "127.0.0.1";
int puerto = 6697;
string xmlData = Request.mensajeXml;
// Convertir la trama XML a bytes
byte[] dataToSend = Encoding.UTF8.GetBytes(xmlData);
byte[] bufferRecibido = Entorno<EntornoPOSBC>.Instancia.get().BufferEntrada;
int cantBytes = Entorno<EntornoPOSBC>.Instancia.get().CantBytes;
try
{
// Crear un socket TCP/IP
......@@ -49,17 +52,19 @@ namespace gatewayGK.POSBC
socket.Connect(endPoint);
Log.Information("Conectandose al servidor POSBC");
// Enviar los datos
socket.Send(dataToSend);
Log.Information($"Datos enviados al servidor POSBC {dataToSend}");
// Buffer para recibir la respuesta
byte[] buffer = new byte[1024];
int bytesReceived = socket.Receive(buffer);
// Enviar los datos
socket.Send(bufferRecibido, SocketFlags.None);
Log.Information($"Datos enviados al servidor POSBC {dataToSend}");
// Buffer para recibir la respuesta
byte[] buffer = new byte[1024];
int bytesReceived = socket.Receive(buffer);
// Convertir los datos recibidos a una cadena
string response = Encoding.UTF8.GetString(buffer, 0, bytesReceived);
Log.Information($"Respuesta recibida del POSBC {response}");
// Convertir los datos recibidos a una cadena
string response = Encoding.UTF8.GetString(buffer, 0, bytesReceived);
Log.Information($"Respuesta recibida del POSBC {response}");
// Cerrar el socket
socket.Shutdown(SocketShutdown.Both);
......
......@@ -3,6 +3,7 @@ using Microsoft.Extensions.Configuration;
using EvaPosSCOSrv;
using EvaPosSrvAplicacionImp;
using EvaPosSrvRespImp;
using gatewayGK.POSBC;
namespace GatewaySCO
{
......@@ -55,6 +56,11 @@ namespace GatewaySCO
Entorno<EntornoGK>.Instancia.get().ConfigGk = configGk;
Log.Information($"GK {Entorno<EntornoGK>.Instancia.get().UrlBase}");
}
if(config.POS == "posbc")
{
Entorno<EntornoPOSBC>.Instancia.set(new EntornoPOSBC());
Log.Information($"Inicio del entorno POSBC");
}
return config;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment