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 ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
{ {
public string Referencia { get; set; } = "scsns:AddCustomerBirthdate"; public string Referencia { get; set; } = "scsns:AddCustomerBirthdate";
public string NombreElementoXMLDatos { get; set; } = "./AddCustomerBirthdateRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(AddCustomerBirthdateRequest)); XmlSerializer serializer = new XmlSerializer(typeof(AddCustomerBirthdateRequest));
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:AddCustomer"; public string Referencia { get; set; } = "scsns:AddCustomer";
public string NombreElementoXMLDatos { get; set; } = "./AddCustomerRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(AddCustomerRequest)); XmlSerializer serializer = new XmlSerializer(typeof(AddCustomerRequest));
......
...@@ -22,7 +22,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -22,7 +22,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:AddItem"; public string Referencia { get; set; } = "scsns:AddItem";
public string NombreElementoXMLDatos { get; set; } = "./AddItemRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(AddItemRequestDTO)); XmlSerializer serializer = new XmlSerializer(typeof(AddItemRequestDTO));
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:AddReceiptLines"; public string Referencia { get; set; } = "scsns:AddReceiptLines";
public string NombreElementoXMLDatos { get; set; } = "./AddReceiptLinesRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:AddTender"; public string Referencia { get; set; } = "scsns:AddTender";
public string NombreElementoXMLDatos { get; set; } = "./AddTenderRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(AddTenderRequest)); XmlSerializer serializer = new XmlSerializer(typeof(AddTenderRequest));
......
...@@ -21,7 +21,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -21,7 +21,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:CancelAction"; public string Referencia { get; set; } = "scsns:CancelAction";
public string NombreElementoXMLDatos { get; set; } = "./CancelActionRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:GetTotals"; public string Referencia { get; set; } = "scsns:GetTotals";
public string NombreElementoXMLDatos { get; set; } = "./GetTotalsRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(GetTotalsRequest)); XmlSerializer serializer = new XmlSerializer(typeof(GetTotalsRequest));
......
...@@ -18,7 +18,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -18,7 +18,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:Initialize"; public string Referencia { get; set; } = "scsns:Initialize";
public string NombreElementoXMLDatos { get; set; } = "./InitializeRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
if (nodo == null) if (nodo == null)
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:PrintCurrentReceipts"; public string Referencia { get; set; } = "scsns:PrintCurrentReceipts";
public string NombreElementoXMLDatos { get; set; } = "./PrintCurrentReceiptsRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(PrintCurrentReceiptsRequest)); XmlSerializer serializer = new XmlSerializer(typeof(PrintCurrentReceiptsRequest));
......
...@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:QueryStatus"; public string Referencia { get; set; } = "scsns:QueryStatus";
public string NombreElementoXMLDatos { get; set; } = "./QueryStatusRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
if (nodo == null) if (nodo == null)
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:RemoveReceiptLines"; public string Referencia { get; set; } = "scsns:RemoveReceiptLines";
public string NombreElementoXMLDatos { get; set; } = "./RemoveReceiptLinesRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
......
...@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:ReportStatusEvents"; public string Referencia { get; set; } = "scsns:ReportStatusEvents";
public string NombreElementoXMLDatos { get; set; } = "./ReportStatusEventsRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
if (nodo == null) if (nodo == null)
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:ReprintReceipts"; public string Referencia { get; set; } = "scsns:ReprintReceipts";
public string NombreElementoXMLDatos { get; set; } = "./ReprintReceiptsRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(ReprintReceiptsRequestDTO)); XmlSerializer serializer = new XmlSerializer(typeof(ReprintReceiptsRequestDTO));
......
...@@ -17,7 +17,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -17,7 +17,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:SignOff"; public string Referencia { get; set; } = "scsns:SignOff";
public string NombreElementoXMLDatos { get; set; } = "./SignOffRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
if (nodo == null) if (nodo == null)
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:Suspend"; public string Referencia { get; set; } = "scsns:Suspend";
public string NombreElementoXMLDatos { get; set; } = "./SuspendTransactionRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(SuspendTransactionRequest)); XmlSerializer serializer = new XmlSerializer(typeof(SuspendTransactionRequest));
......
...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -20,7 +20,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
public string Referencia { get; set; } = "scsns:Terminate"; public string Referencia { get; set; } = "scsns:Terminate";
public string NombreElementoXMLDatos { get; set; } = "./TerminateRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(TerminateRequestDTO)); XmlSerializer serializer = new XmlSerializer(typeof(TerminateRequestDTO));
......
...@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores ...@@ -19,7 +19,7 @@ namespace EvaPOS_API_FRAME.Adaptadores
{ {
public string Referencia { get; set; } = "scsns:VoidTransaction"; public string Referencia { get; set; } = "scsns:VoidTransaction";
public string NombreElementoXMLDatos { get; set; } = "./VoidTransactionRequest"; 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); XmlNode? nodo = docXml.SelectSingleNode(NombreElementoXMLDatos);
XmlSerializer serializer = new XmlSerializer(typeof(VoidTransactionDTO)); 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 EvaPosSrvDTO;
using EvaPosSrvResp; using EvaPosSrvResp;
using GatewaySCO;
using Serilog; using Serilog;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -29,14 +30,16 @@ namespace gatewayGK.POSBC ...@@ -29,14 +30,16 @@ namespace gatewayGK.POSBC
/// </summary> /// </summary>
public Respuestas Ejecutar() public Respuestas Ejecutar()
{ {
string direccionIpPosbc = "10.89.81.102"; string direccionIpPosbc = "127.0.0.1";
int puerto = 6697; int puerto = 6697;
string xmlData = Request.mensajeXml; string xmlData = Request.mensajeXml;
// Convertir la trama XML a bytes // Convertir la trama XML a bytes
byte[] dataToSend = Encoding.UTF8.GetBytes(xmlData); byte[] dataToSend = Encoding.UTF8.GetBytes(xmlData);
byte[] bufferRecibido = Entorno<EntornoPOSBC>.Instancia.get().BufferEntrada;
int cantBytes = Entorno<EntornoPOSBC>.Instancia.get().CantBytes;
try try
{ {
// Crear un socket TCP/IP // Crear un socket TCP/IP
...@@ -49,17 +52,19 @@ namespace gatewayGK.POSBC ...@@ -49,17 +52,19 @@ namespace gatewayGK.POSBC
socket.Connect(endPoint); socket.Connect(endPoint);
Log.Information("Conectandose al servidor POSBC"); 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]; // Enviar los datos
int bytesReceived = socket.Receive(buffer); 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 // Convertir los datos recibidos a una cadena
string response = Encoding.UTF8.GetString(buffer, 0, bytesReceived); string response = Encoding.UTF8.GetString(buffer, 0, bytesReceived);
Log.Information($"Respuesta recibida del POSBC {response}"); Log.Information($"Respuesta recibida del POSBC {response}");
// Cerrar el socket // Cerrar el socket
socket.Shutdown(SocketShutdown.Both); socket.Shutdown(SocketShutdown.Both);
......
...@@ -3,6 +3,7 @@ using Microsoft.Extensions.Configuration; ...@@ -3,6 +3,7 @@ using Microsoft.Extensions.Configuration;
using EvaPosSCOSrv; using EvaPosSCOSrv;
using EvaPosSrvAplicacionImp; using EvaPosSrvAplicacionImp;
using EvaPosSrvRespImp; using EvaPosSrvRespImp;
using gatewayGK.POSBC;
namespace GatewaySCO namespace GatewaySCO
{ {
...@@ -55,6 +56,11 @@ namespace GatewaySCO ...@@ -55,6 +56,11 @@ namespace GatewaySCO
Entorno<EntornoGK>.Instancia.get().ConfigGk = configGk; Entorno<EntornoGK>.Instancia.get().ConfigGk = configGk;
Log.Information($"GK {Entorno<EntornoGK>.Instancia.get().UrlBase}"); 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; 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