Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Brayan Sarmiento
API-Gateway-CHEC
Commits
80ed77d5
Commit
80ed77d5
authored
Jun 25, 2024
by
Jose Hugo Torres
Browse files
Maneja mensaje terminar
parent
5f1abf15
Changes
23
Show whitespace changes
Inline
Side-by-side
CHECPrueba/Program.cs
View file @
80ed77d5
...
@@ -9,12 +9,33 @@ public class CHECPrueba
...
@@ -9,12 +9,33 @@ public class CHECPrueba
private
const
string
GatewayServer
=
"127.0.0.1"
;
private
const
string
GatewayServer
=
"127.0.0.1"
;
private
const
int
GatewayPort
=
6690
;
private
const
int
GatewayPort
=
6690
;
static
string
mensaje1
=
@"soeps~Message-Type=REQ|Session-Id=400|~<?xml version=""1.0"" encoding=""UTF-8""?><scsns:Initialize xmlns:scsns=""http://bc.si.retail.ibm.com/POSBCSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://bc.si.retail.ibm.com/POSBCSchema C:\\PosBc\\POSBCSchema_main.xsd"" >
<InitializeRequest>
<OperatorID>NO_DEFAULT</OperatorID
<TerminalNumber>400</TerminalNumber>
<Recovery>false</Recovery>
</InitializeRequest>
</scsns:Initialize>"
;
static
string
mensaje2
=
@"soeps~Message-Type=REQ|Session-Id=400|~<?xml version=""1.0"" encoding=""UTF-8""?><scsns:QueryStatus xmlns:scsns=""http://bc.si.retail.ibm.com/POSBCSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://bc.si.retail.ibm.com/POSBCSchema C:\\PosBc\\POSBCSchema_main.xsd"" >
<QueryStatusRequest/>
</scsns:QueryStatus>"
;
static
string
mensaje3
=
@"soeps~Message-Type=REQ|Session-Id=400|~<?xml version=""1.0"" encoding=""UTF-8""?><scsns:ReportStatusEvents xmlns:scsns=""http://bc.si.retail.ibm.com/POSBCSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://bc.si.retail.ibm.com/POSBCSchema C:\\PosBc\\POSBCSchema_main.xsd"" >
<ReportStatusEventsRequest>
<RequestID>101</RequestID></ReportStatusEventsRequest>
</scsns:ReportStatusEvents>"
;
public
static
async
Task
Main
(
string
[]
args
)
public
static
async
Task
Main
(
string
[]
args
)
{
{
Log
.
Logger
=
new
LoggerConfiguration
()
Log
.
Logger
=
new
LoggerConfiguration
()
.
WriteTo
.
Console
()
.
WriteTo
.
Console
()
.
CreateLogger
();
.
CreateLogger
();
string
[]
mensajes
=
[
CHECPrueba
.
mensaje1
,
CHECPrueba
.
mensaje2
,
CHECPrueba
.
mensaje3
];
int
i
=
0
;
try
try
{
{
using
TcpClient
client
=
new
TcpClient
();
using
TcpClient
client
=
new
TcpClient
();
...
@@ -27,7 +48,9 @@ public class CHECPrueba
...
@@ -27,7 +48,9 @@ public class CHECPrueba
while
(
true
)
while
(
true
)
{
{
// Remitir un mensaje numerado al Gateway
// Remitir un mensaje numerado al Gateway
string
message
=
$"Mensaje
{
messageNumber
}
desde CHEC"
;
string
message
=
mensajes
[
i
++];
if
(
i
==
mensajes
.
Length
-
1
)
i
=
0
;
byte
[]
messageBytes
=
Encoding
.
UTF8
.
GetBytes
(
message
);
byte
[]
messageBytes
=
Encoding
.
UTF8
.
GetBytes
(
message
);
byte
[]
lengthBytes
=
BitConverter
.
GetBytes
(
messageBytes
.
Length
);
byte
[]
lengthBytes
=
BitConverter
.
GetBytes
(
messageBytes
.
Length
);
...
@@ -38,8 +61,6 @@ public class CHECPrueba
...
@@ -38,8 +61,6 @@ public class CHECPrueba
byte
[]
bytesMsj
=
Util
.
ConcatenaArreglosBytes
(
lengthBytes
,
messageBytes
);
byte
[]
bytesMsj
=
Util
.
ConcatenaArreglosBytes
(
lengthBytes
,
messageBytes
);
// await stream.WriteAsync(lengthBytes, 0, 4);
// await stream.WriteAsync(messageBytes, 0, messageBytes.Length);
await
stream
.
WriteAsync
(
bytesMsj
,
0
,
bytesMsj
.
Length
);
await
stream
.
WriteAsync
(
bytesMsj
,
0
,
bytesMsj
.
Length
);
Log
.
Information
(
$"Mensaje
{
messageNumber
}
enviado al Gateway:
{
message
}
"
);
Log
.
Information
(
$"Mensaje
{
messageNumber
}
enviado al Gateway:
{
message
}
"
);
...
@@ -47,7 +68,7 @@ public class CHECPrueba
...
@@ -47,7 +68,7 @@ public class CHECPrueba
await
ReceiveResponsesAsync
(
stream
);
await
ReceiveResponsesAsync
(
stream
);
messageNumber
++;
messageNumber
++;
await
Task
.
Delay
(
5
000
);
// Esperar 5 segundos antes de enviar el siguiente mensaje
await
Task
.
Delay
(
8
000
);
// Esperar 5 segundos antes de enviar el siguiente mensaje
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
...
POSBCPrueba/Program.cs
View file @
80ed77d5
...
@@ -9,6 +9,23 @@ public class PosbcServer
...
@@ -9,6 +9,23 @@ public class PosbcServer
private
const
int
Port
=
6697
;
private
const
int
Port
=
6697
;
private
static
int
messageCounter
=
1
;
private
static
int
messageCounter
=
1
;
static
string
mensaje1
=
@"soeps~Session-Id=400|Message-Type=EVENT|~<?xml version=""1.0"" encoding=""UTF-8""?>
<schema:POSBCStatusEvent xmlns:schema=""http://bc.si.retail.ibm.com/POSBCSchema"">
<POSStatus>
<Severity>INFO</Severity>
<Status>CONNECTING_TO_POS</Status>
<StatusMessage>Connecting to POS system</StatusMessage>
</POSStatus>
</schema:POSBCStatusEvent>"
;
static
string
mensajeTerminar
=
@"soeps~Session-Id=400|Message-Type=RESP|~<?xml version=""1.0"" encoding=""UTF-8""?>
<schema:TerminateResponse xmlns:schema=""http://bc.si.retail.ibm.com/POSBCSchema"">
<TerminateResult>
<RequestID>110</RequestID>
</TerminateResult>
</schema:TerminateResponse>"
;
public
static
async
Task
Main
()
public
static
async
Task
Main
()
{
{
Log
.
Logger
=
new
LoggerConfiguration
()
Log
.
Logger
=
new
LoggerConfiguration
()
...
@@ -62,14 +79,19 @@ public class PosbcServer
...
@@ -62,14 +79,19 @@ public class PosbcServer
Log
.
Information
(
$"Mensaje recibido del Gateway:
{
message
}
"
);
Log
.
Information
(
$"Mensaje recibido del Gateway:
{
message
}
"
);
// Esperar 2 segundos antes de enviar la primera respuesta
// Esperar 2 segundos antes de enviar la primera respuesta
await
Task
.
Delay
(
2000
);
await
Task
.
Delay
(
1000
);
await
EnviarMensaje
(
stream
,
$"Respuesta
{
messageCounter
++}
desde POSBC"
);
//await EnviarMensaje(stream, $"Respuesta {messageCounter++} desde POSBC");
await
EnviarMensaje
(
stream
,
mensaje1
);
// Esperar 2 segundos y enviar dos mensajes adicionales
// Esperar 2 segundos y enviar dos mensajes adicionales
await
Task
.
Delay
(
2000
);
await
Task
.
Delay
(
1000
);
await
EnviarMensaje
(
stream
,
$"Mensaje adicional
{
messageCounter
++}
desde POSBC"
);
//await EnviarMensaje(stream, $"Mensaje adicional {messageCounter++} desde POSBC");
await
Task
.
Delay
(
2000
);
await
EnviarMensaje
(
stream
,
mensaje1
);
await
EnviarMensaje
(
stream
,
$"Mensaje adicional
{
messageCounter
++}
desde POSBC"
);
await
Task
.
Delay
(
1000
);
//await EnviarMensaje(stream, $"Mensaje adicional {messageCounter++} desde POSBC");
await
EnviarMensaje
(
stream
,
mensajeTerminar
);
await
Task
.
Delay
(
1000
);
break
;
}
}
}
}
}
}
...
...
gatewayGK/ComandosPOSBC/InitializeRequestCmd.cs
0 → 100644
View file @
80ed77d5
using
EvaPOS_API_FRAME.DTO.Intercambio
;
using
EvaPOS_API_FRAME.RespuestasXML
;
using
EvaPOS_API_FRAME.RespuestasXML.Printer
;
using
EvaPosSrvDTO
;
using
EvaPosSrvResp
;
using
Serilog
;
namespace
Gateway.Comandos.POSBC
{
/// <summary>
/// Procesa solicitudes de InitializeRequest.
/// </summary>
public
class
InitializeRequestCmd
:
IComando
{
public
string
Referencia
{
get
;
set
;
}
=
"scsns:Initialize"
;
/// <summary>
/// DTO con solicitud.
/// </summary>
public
InitializeRequestDTO
Request
{
get
;
private
set
;
}
/// <summary>
/// Procesa y responde InitializeRequest.
/// </summary>
public
Respuestas
Ejecutar
()
{
int
terminalNumber
=
Request
.
TerminalNumber
;
Log
.
Debug
(
"Cmd InitializeRequestCmd ejecutado. Request id: {id}, terminal: {terminal}, recovery: {recovery}"
,
Request
.
OperatorID
,
Request
.
TerminalNumber
,
Request
.
Recovery
);
// --- NO EJECUTA ACCIÓN, NO RETORNA RESPUESTAS.
return
[];
}
public
IComando
CreaCopia
()
{
return
(
InitializeRequestCmd
)
this
.
MemberwiseClone
();
}
public
void
CargaDTO
(
DTOBase
initializeRequestDTO
)
{
Request
=
(
InitializeRequestDTO
)
initializeRequestDTO
;
}
}
}
gatewayGK/ComandosPOSBCTest/InitializeRequestCmd.cs
0 → 100644
View file @
80ed77d5
using
EvaPOS_API_FRAME.DTO.Intercambio
;
using
EvaPOS_API_FRAME.RespuestasXML
;
using
EvaPOS_API_FRAME.RespuestasXML.Printer
;
using
EvaPosSrvDTO
;
using
EvaPosSrvResp
;
using
Serilog
;
namespace
Gateway.Comandos.POSBCTest
{
/// <summary>
/// Procesa solicitudes de InitializeRequest.
/// </summary>
public
class
InitializeRequestCmd
:
IComando
{
public
string
Referencia
{
get
;
set
;
}
=
"scsns:Initialize"
;
/// <summary>
/// DTO con solicitud.
/// </summary>
public
InitializeRequestDTO
Request
{
get
;
private
set
;
}
/// <summary>
/// Procesa y responde InitializeRequest.
/// </summary>
public
Respuestas
Ejecutar
()
{
int
terminalNumber
=
Request
.
TerminalNumber
;
Log
.
Debug
(
"Cmd InitializeRequestCmd ejecutado. Request id: {id}, terminal: {terminal}, recovery: {recovery}"
,
Request
.
OperatorID
,
Request
.
TerminalNumber
,
Request
.
Recovery
);
var
posbcStatus1
=
new
POSBCStatusEvent
(
1
,
TipoMensaje
.
Event
,
"INFO"
,
"CONNECTING_TO_POS"
,
"Procesador por el Geteway"
);
return
[
posbcStatus1
];
}
public
IComando
CreaCopia
()
{
return
(
InitializeRequestCmd
)
this
.
MemberwiseClone
();
}
public
void
CargaDTO
(
DTOBase
initializeRequestDTO
)
{
Request
=
(
InitializeRequestDTO
)
initializeRequestDTO
;
}
}
}
gatewayGK/Comandosgk/AddItemRequestCmdGk.cs
View file @
80ed77d5
...
@@ -210,7 +210,7 @@ namespace gatewayGK.ComandosGk
...
@@ -210,7 +210,7 @@ namespace gatewayGK.ComandosGk
var
regularUnitPriceTrans
=
regularUnitPrice
.
ToString
();
var
regularUnitPriceTrans
=
regularUnitPrice
.
ToString
();
Log
.
Debug
(
$"Transaction ID:
{
transactionId
}
"
);
Log
.
Debug
(
$"Transaction ID:
{
transactionId
}
"
);
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
TransactionID
=
transactionId
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
TransactionID
=
transactionId
;
string
tomarNombreCorto
=
""
;
string
tomarNombreCorto
=
""
;
//Valores que se mandan en chec
//Valores que se mandan en chec
...
...
gatewayGK/Comandosgk/AddItemRequestCmdGk2.cs
View file @
80ed77d5
...
@@ -29,7 +29,7 @@ namespace gatewayGK.ComandosGk
...
@@ -29,7 +29,7 @@ namespace gatewayGK.ComandosGk
/// <summary>
/// <summary>
/// Url servicio autenticación Gk.
/// Url servicio autenticación Gk.
/// </summary>
/// </summary>
private
string
_urlRegisterItem
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
UrlBase
private
string
_urlRegisterItem
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
UrlBase
+
"/com.gk_software.pos.api.service.transaction.LineItemService/registerLineItem"
;
+
"/com.gk_software.pos.api.service.transaction.LineItemService/registerLineItem"
;
/// <summary>
/// <summary>
...
@@ -70,7 +70,7 @@ namespace gatewayGK.ComandosGk
...
@@ -70,7 +70,7 @@ namespace gatewayGK.ComandosGk
MaxTimeout
=
-
1
,
MaxTimeout
=
-
1
,
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
};
};
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
;
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
var
client
=
new
RestClient
(
options
);
var
client
=
new
RestClient
(
options
);
...
@@ -201,7 +201,7 @@ namespace gatewayGK.ComandosGk
...
@@ -201,7 +201,7 @@ namespace gatewayGK.ComandosGk
units
,
units
,
textName
textName
);
);
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
TransactionID
=
transactionId
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
TransactionID
=
transactionId
;
string
tomarNombreCorto
=
""
;
string
tomarNombreCorto
=
""
;
//Valores que se mandan en chec
//Valores que se mandan en chec
...
...
gatewayGK/Comandosgk/AddItemRequestCmdGk3.cs
View file @
80ed77d5
...
@@ -31,7 +31,7 @@ namespace gatewayGK.ComandosGk
...
@@ -31,7 +31,7 @@ namespace gatewayGK.ComandosGk
/// <summary>
/// <summary>
/// Url servicio autenticación Gk.
/// Url servicio autenticación Gk.
/// </summary>
/// </summary>
private
string
_urlRegisterItem
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
UrlBase
private
string
_urlRegisterItem
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
UrlBase
+
"/com.gk_software.pos.api.service.transaction.LineItemService/registerLineItem"
;
+
"/com.gk_software.pos.api.service.transaction.LineItemService/registerLineItem"
;
/// <summary>
/// <summary>
...
@@ -72,7 +72,7 @@ namespace gatewayGK.ComandosGk
...
@@ -72,7 +72,7 @@ namespace gatewayGK.ComandosGk
MaxTimeout
=
-
1
,
MaxTimeout
=
-
1
,
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
};
};
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
;
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
var
client
=
new
RestClient
(
options
);
var
client
=
new
RestClient
(
options
);
...
@@ -201,9 +201,9 @@ namespace gatewayGK.ComandosGk
...
@@ -201,9 +201,9 @@ namespace gatewayGK.ComandosGk
}
}
}
}
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
TransactionID
=
transactionId
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
TransactionID
=
transactionId
;
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
BusinessUnitGroupID
=
businessUnitGroupID
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
BusinessUnitGroupID
=
businessUnitGroupID
;
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
SequenceNumber
=
sequenceNumber
??
0
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
SequenceNumber
=
sequenceNumber
??
0
;
//Pasarlo a string
//Pasarlo a string
var
regularUnitPriceTrans
=
regularUnitPrice
.
ToString
();
var
regularUnitPriceTrans
=
regularUnitPrice
.
ToString
();
...
@@ -216,7 +216,7 @@ namespace gatewayGK.ComandosGk
...
@@ -216,7 +216,7 @@ namespace gatewayGK.ComandosGk
units
,
units
,
receiptText
,
receiptText
,
sequenceNumber
,
sequenceNumber
,
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
SuspendNumber
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
SuspendNumber
);
);
Log
.
Information
(
String
.
Format
(
"{0,3} | {1,13} | {2,-20} | {3,3}| {4,-5:N2} | {5,12:N2} | {6,12:N2} | {7,12:N2} | {8,12:N2} | {9,3}"
,
Log
.
Information
(
String
.
Format
(
"{0,3} | {1,13} | {2,-20} | {3,3}| {4,-5:N2} | {5,12:N2} | {6,12:N2} | {7,12:N2} | {8,12:N2} | {9,3}"
,
addedOrModifiedLineItems
.
Key
.
RetailTransactionLineItemSequenceNumber
,
addedOrModifiedLineItems
.
Key
.
RetailTransactionLineItemSequenceNumber
,
...
...
gatewayGK/Comandosgk/CalculateTaxtCmdGk.cs
View file @
80ed77d5
...
@@ -30,7 +30,7 @@ namespace gatewayGK.ComandosGk
...
@@ -30,7 +30,7 @@ namespace gatewayGK.ComandosGk
/// <summary>
/// <summary>
/// Url servicio autenticación Gk.
/// Url servicio autenticación Gk.
/// </summary>
/// </summary>
private
string
_urlRegisterItem
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
UrlBase
private
string
_urlRegisterItem
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
UrlBase
+
"services/com.gk_software.pos.api.service.taxengine.TaxEngineService/calculateTax"
;
+
"services/com.gk_software.pos.api.service.taxengine.TaxEngineService/calculateTax"
;
/// <summary>
/// <summary>
...
@@ -55,7 +55,7 @@ namespace gatewayGK.ComandosGk
...
@@ -55,7 +55,7 @@ namespace gatewayGK.ComandosGk
{
{
Key
=
new
()
Key
=
new
()
{
{
BusinessUnitGroupID
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
BusinessUnitGroupID
,
BusinessUnitGroupID
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
BusinessUnitGroupID
,
TransactionID
=
""
TransactionID
=
""
},
},
OperatorID
=
""
,
OperatorID
=
""
,
...
@@ -88,7 +88,7 @@ namespace gatewayGK.ComandosGk
...
@@ -88,7 +88,7 @@ namespace gatewayGK.ComandosGk
MaxTimeout
=
-
1
,
MaxTimeout
=
-
1
,
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
};
};
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
;
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
var
client
=
new
RestClient
(
options
);
var
client
=
new
RestClient
(
options
);
...
@@ -198,7 +198,7 @@ namespace gatewayGK.ComandosGk
...
@@ -198,7 +198,7 @@ namespace gatewayGK.ComandosGk
));
));
Log
.
Information
(
String
.
Format
(
"SUBTOTAL: {0,12:N2} // SUBTOTAL_DISCOUNT: {1,12:N2} // TOTAL: {2,12:N2}"
,
Log
.
Information
(
String
.
Format
(
"SUBTOTAL: {0,12:N2} // SUBTOTAL_DISCOUNT: {1,12:N2} // TOTAL: {2,12:N2}"
,
subtotal
,
subtotalDcto
,
total
));
subtotal
,
subtotalDcto
,
total
));
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
TransactionID
=
transactionId
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
TransactionID
=
transactionId
;
string
tomarNombreCorto
=
""
;
string
tomarNombreCorto
=
""
;
//Valores que se mandan en chec
//Valores que se mandan en chec
...
...
gatewayGK/Comandosgk/InitializeRequestCmdGk.cs
View file @
80ed77d5
...
@@ -22,7 +22,7 @@ namespace gatewayGK.ComandosGk
...
@@ -22,7 +22,7 @@ namespace gatewayGK.ComandosGk
/// <summary>
/// <summary>
/// Url servicio autenticación Gk.
/// Url servicio autenticación Gk.
/// </summary>
/// </summary>
private
string
_urlLogin
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
UrlBase
private
string
_urlLogin
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
UrlBase
+
"/com.gk_software.pos.api.service.session.PosSessionService/login"
;
+
"/com.gk_software.pos.api.service.session.PosSessionService/login"
;
/// <summary>
/// <summary>
...
@@ -69,12 +69,12 @@ namespace gatewayGK.ComandosGk
...
@@ -69,12 +69,12 @@ namespace gatewayGK.ComandosGk
var
datosAutenticacion
=
new
AutenticationReq
var
datosAutenticacion
=
new
AutenticationReq
{
{
RetailStoreId
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
ConfigGk
.
RetailStoreId
,
RetailStoreId
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
ConfigGk
.
RetailStoreId
,
WorkstationId
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
ConfigGk
.
WorkstationId
,
WorkstationId
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
ConfigGk
.
WorkstationId
,
WorkstationAddress
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
ConfigGk
.
WorkstationAddress
,
WorkstationAddress
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
ConfigGk
.
WorkstationAddress
,
WorkstationTypeCode
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
ConfigGk
.
WorkstationTypeCode
,
WorkstationTypeCode
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
ConfigGk
.
WorkstationTypeCode
,
LoginName
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
ConfigGk
.
LoginName
,
LoginName
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
ConfigGk
.
LoginName
,
Password
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
ConfigGk
.
Password
,
Password
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
ConfigGk
.
Password
,
TrainingMode
=
false
,
TrainingMode
=
false
,
FinalizeControlTransactionFlag
=
false
,
FinalizeControlTransactionFlag
=
false
,
UseLoginTypeTechnicalForLoginManager
=
false
,
UseLoginTypeTechnicalForLoginManager
=
false
,
...
@@ -82,8 +82,8 @@ namespace gatewayGK.ComandosGk
...
@@ -82,8 +82,8 @@ namespace gatewayGK.ComandosGk
{
{
TillDoKey
=
new
TillDoKey
TillDoKey
=
new
TillDoKey
{
{
BusinessUnitGroupID
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
ConfigGk
.
BusinessUnitGroupID
,
BusinessUnitGroupID
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
ConfigGk
.
BusinessUnitGroupID
,
TillID
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
ConfigGk
.
TillID
TillID
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
ConfigGk
.
TillID
}
}
}
}
};
};
...
@@ -120,9 +120,9 @@ namespace gatewayGK.ComandosGk
...
@@ -120,9 +120,9 @@ namespace gatewayGK.ComandosGk
var
operatorID
=
autenticacionResp
.
primaryEntry
.
transaction
.
operatorID
;
var
operatorID
=
autenticacionResp
.
primaryEntry
.
transaction
.
operatorID
;
var
posSessionId
=
autenticacionResp
.
posSessionId
.
id
;
var
posSessionId
=
autenticacionResp
.
posSessionId
.
id
;
// Salvar Transaccion y id de la session.
// Salvar Transaccion y id de la session.
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
=
posSessionId
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
=
posSessionId
;
Log
.
Information
(
"<< GK login:operatorID {operatorID}, transactionId {transactionId}, posSessionId {posSessionId}"
,
Log
.
Information
(
"<< GK login:operatorID {operatorID}, transactionId {transactionId}, posSessionId {posSessionId}"
,
operatorID
,
transactionId
,
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
);
operatorID
,
transactionId
,
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
);
// Respuestas a SCO.
// Respuestas a SCO.
var
posbcStatus1
=
new
POSBCStatusEvent
(
1
,
TipoMensaje
.
Event
,
"INFO"
,
"CONNECTING_TO_POS"
,
"Connecting to POS system"
);
var
posbcStatus1
=
new
POSBCStatusEvent
(
1
,
TipoMensaje
.
Event
,
"INFO"
,
"CONNECTING_TO_POS"
,
"Connecting to POS system"
);
...
...
gatewayGK/Comandosgk/SubtotalCalculationCmdGk.cs
View file @
80ed77d5
...
@@ -30,7 +30,7 @@ namespace gatewayGK.ComandosGk
...
@@ -30,7 +30,7 @@ namespace gatewayGK.ComandosGk
/// <summary>
/// <summary>
/// Url servicio autenticación Gk.
/// Url servicio autenticación Gk.
/// </summary>
/// </summary>
private
readonly
string
_urlRequest
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
UrlBase
private
readonly
string
_urlRequest
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
UrlBase
+
"/com.gk_software.pos.api.service.subtotal.SubtotalService/processSubtotalCalculation"
;
+
"/com.gk_software.pos.api.service.subtotal.SubtotalService/processSubtotalCalculation"
;
/// <summary>
/// <summary>
...
@@ -96,7 +96,7 @@ namespace gatewayGK.ComandosGk
...
@@ -96,7 +96,7 @@ namespace gatewayGK.ComandosGk
MaxTimeout
=
-
1
,
MaxTimeout
=
-
1
,
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
};
};
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
;
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
var
client
=
new
RestClient
(
options
);
var
client
=
new
RestClient
(
options
);
...
@@ -289,7 +289,7 @@ namespace gatewayGK.ComandosGk
...
@@ -289,7 +289,7 @@ namespace gatewayGK.ComandosGk
}
}
}
}
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
TransactionID
=
transactionId
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
TransactionID
=
transactionId
;
Log
.
Information
(
"-------------------------------------------------------------------------------------------------------------------------"
);
Log
.
Information
(
"-------------------------------------------------------------------------------------------------------------------------"
);
Log
.
Information
(
String
.
Format
(
"\t\tSUBTOTAL: {0,12:N2} -- SUBTOTAL_DISCOUNT: {1,12:N2} -- TOTAL: {2,12:N2}"
,
Log
.
Information
(
String
.
Format
(
"\t\tSUBTOTAL: {0,12:N2} -- SUBTOTAL_DISCOUNT: {1,12:N2} -- TOTAL: {2,12:N2}"
,
subtotal
,
subtotalDcto
,
total
));
subtotal
,
subtotalDcto
,
total
));
...
...
gatewayGK/Comandosgk/TerminateRequestCmdGk.cs
View file @
80ed77d5
...
@@ -20,7 +20,7 @@ namespace gatewayGK.ComandosGk
...
@@ -20,7 +20,7 @@ namespace gatewayGK.ComandosGk
/// DTO con solicitud.
/// DTO con solicitud.
/// </summary>
/// </summary>
public
TerminateRequestDTO
Destroy
{
get
;
private
set
;
}
public
TerminateRequestDTO
Destroy
{
get
;
private
set
;
}
private
string
_urlLogout
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
UrlBase
private
string
_urlLogout
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
UrlBase
+
"/com.gk_software.pos.api.service.session.PosSessionService/logout"
;
+
"/com.gk_software.pos.api.service.session.PosSessionService/logout"
;
/// <summary>
/// <summary>
...
@@ -32,7 +32,7 @@ namespace gatewayGK.ComandosGk
...
@@ -32,7 +32,7 @@ namespace gatewayGK.ComandosGk
var
requestId
=
Destroy
.
DestroySession
;
var
requestId
=
Destroy
.
DestroySession
;
// --- cliente rest.
// --- cliente rest.
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
;
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
;
var
options
=
new
RestClientOptions
()
var
options
=
new
RestClientOptions
()
{
{
// TODO manejar el timeout como un parámetro de configuración.
// TODO manejar el timeout como un parámetro de configuración.
...
@@ -93,7 +93,7 @@ namespace gatewayGK.ComandosGk
...
@@ -93,7 +93,7 @@ namespace gatewayGK.ComandosGk
.
GetBoolean
();
.
GetBoolean
();
if
(
success
)
if
(
success
)
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
=
""
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
=
""
;
Log
.
Information
(
"<< GK logout - success {success}, transactionID {transactionID}"
,
Log
.
Information
(
"<< GK logout - success {success}, transactionID {transactionID}"
,
success
,
transactionID
);
success
,
transactionID
);
...
...
gatewayGK/Comandosgk/UpdateTerminalTenderAuthorizationCmdGk.cs
View file @
80ed77d5
...
@@ -32,7 +32,7 @@ namespace gatewayGK.ComandosGk
...
@@ -32,7 +32,7 @@ namespace gatewayGK.ComandosGk
/// <summary>
/// <summary>
/// Url servicio autenticación Gk.
/// Url servicio autenticación Gk.
/// </summary>
/// </summary>
private
readonly
string
_urlRequest
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
UrlBase
private
readonly
string
_urlRequest
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
UrlBase
+
"/com.gk_software.pos.api.service.payment.PaymentService/updateTerminalTenderAuthorization"
;
+
"/com.gk_software.pos.api.service.payment.PaymentService/updateTerminalTenderAuthorization"
;
/// <summary>
/// <summary>
...
@@ -181,7 +181,7 @@ namespace gatewayGK.ComandosGk
...
@@ -181,7 +181,7 @@ namespace gatewayGK.ComandosGk
);
);
ComGkSoftwareGkrApiServerMdCurrencyDtoDomCurrencyDOKey
currencyKey
=
new
(
ComGkSoftwareGkrApiServerMdCurrencyDtoDomCurrencyDOKey
currencyKey
=
new
(
businessUnitGroupID
:
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
BusinessUnitGroupID
,
businessUnitGroupID
:
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
BusinessUnitGroupID
,
isocurrencyCode
:
"COP"
isocurrencyCode
:
"COP"
);
);
...
@@ -191,7 +191,7 @@ namespace gatewayGK.ComandosGk
...
@@ -191,7 +191,7 @@ namespace gatewayGK.ComandosGk
);
);
ComGkSoftwareGkrApiServerMdTenderDtoDomTenderDOKey
tenderKey
=
new
(
ComGkSoftwareGkrApiServerMdTenderDtoDomTenderDOKey
tenderKey
=
new
(
businessUnitGroupID
:
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
BusinessUnitGroupID
,
businessUnitGroupID
:
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
BusinessUnitGroupID
,
tenderTypeCode
:
"ZTTE"
tenderTypeCode
:
"ZTTE"
);
);
...
@@ -204,7 +204,7 @@ namespace gatewayGK.ComandosGk
...
@@ -204,7 +204,7 @@ namespace gatewayGK.ComandosGk
);
);
ComGkSoftwarePosApiModelDomAppServicesTransactionTenderAuthorizationKey
tenderAuthorizationKey
=
new
(
ComGkSoftwarePosApiModelDomAppServicesTransactionTenderAuthorizationKey
tenderAuthorizationKey
=
new
(
businessUnitGroupID
:
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
BusinessUnitGroupID
,
businessUnitGroupID
:
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
BusinessUnitGroupID
,
transactionID
:
""
,
// TODO - fijar el correcto.
transactionID
:
""
,
// TODO - fijar el correcto.
tenderAuthorizationSequenceNumber
:
0
tenderAuthorizationSequenceNumber
:
0
);
);
...
@@ -234,7 +234,7 @@ namespace gatewayGK.ComandosGk
...
@@ -234,7 +234,7 @@ namespace gatewayGK.ComandosGk
MaxTimeout
=
-
1
,
MaxTimeout
=
-
1
,
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
RemoteCertificateValidationCallback
=
(
sender
,
certificate
,
chain
,
sslPolicyErrors
)
=>
true
};
};
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
posSessionId
;
string
sessionId
=
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
posSessionId
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
string
cookieValue
=
$"sessionid=
{
sessionId
}
"
;
var
client
=
new
RestClient
(
options
);
var
client
=
new
RestClient
(
options
);
...
@@ -426,7 +426,7 @@ namespace gatewayGK.ComandosGk
...
@@ -426,7 +426,7 @@ namespace gatewayGK.ComandosGk
}
}
}
}
Entorno
<
EntornoGK
>.
Instancia
.
g
et
().
TransactionID
=
transactionId
;
Entorno
<
EntornoGK
>.
Instancia
.
G
et
().
TransactionID
=
transactionId
;
Log
.
Information
(
"-------------------------------------------------------------------------------------------------------------------------"
);
Log
.
Information
(
"-------------------------------------------------------------------------------------------------------------------------"
);
Log
.
Information
(
String
.
Format
(
"\t\tSUBTOTAL: {0,12:N2} -- SUBTOTAL_DISCOUNT: {1,12:N2} -- TOTAL: {2,12:N2}"
,
Log
.
Information
(
String
.
Format
(
"\t\tSUBTOTAL: {0,12:N2} -- SUBTOTAL_DISCOUNT: {1,12:N2} -- TOTAL: {2,12:N2}"
,
subtotal
,
subtotalDcto
,
total
));
subtotal
,
subtotalDcto
,
total
));
...
...
gatewayGK/Infraestructura/ConfigPOSBCTest.cs
0 → 100644
View file @
80ed77d5
/// <summary>
/// Clase que representa los parámetros de configuración de la aplicación
/// registrados en el archivo appsettings.json asociados a POSBC.
/// </summary>
public
sealed
class
ConfigPOSBCTest
{
public
required
string
IpPOSBC
{
get
;
set
;
}
=
"127.0.0.1"
;
public
required
int
PortPOSBC
{
get
;
set
;
}
=
6698
;
public
override
string
ToString
()
{
return
base
.
ToString
()
+
$" - IpPOSBC: '
{
IpPOSBC
}
', PortPOSBC: '
{
PortPOSBC
}
' "
;
}
}
\ No newline at end of file
gatewayGK/Infraestructura/DirectorioCmdsFactory.cs
View file @
80ed77d5
...
@@ -11,13 +11,12 @@ public class DirectorioCmdsFactory
...
@@ -11,13 +11,12 @@ public class DirectorioCmdsFactory
return
tipoPOS
switch
return
tipoPOS
switch
{
{
"ECO"
=>
DispensaDirectorioCmdsPruebas
.
Dispensa
(),
"ECO"
=>
DispensaDirectorioCmdsPruebas
.
Dispensa
(),
//"ECO_POSBC" => throw new NotImplementedException(),
"POSBC"
=>
DispensaDirectorioCmdsPOSBC
.
Dispensa
(),
"ECO_POSBC"
=>
DispensaDirectorioCmdsGKPruebas
.
Dispensa
(),
"POSBCTest"
=>
DispensaDirectorioCmdsPOSBCTest
.
Dispensa
(),
"POSBC"
=>
throw
new
NotImplementedException
(),
"evapos"
=>
DispensaDirectorioCmdsEvaPOS
.
Dispensa
(),
"evapos"
=>
DispensaDirectorioCmdsEvaPOS
.
Dispensa
(),
"gk"
=>
DispensaDirectorioCmdsGK
.
Dispensa
(),
"gk"
=>
DispensaDirectorioCmdsGK
.
Dispensa
(),
"gk_test"
=>
DispensaDirectorioCmdsGKPruebas
.
Dispensa
(),
"gk_test"
=>
DispensaDirectorioCmdsGKPruebas
.
Dispensa
(),
_
=>
throw
new
ArgumentException
(
"Valor no reconocido en archivo configuración, parámetro 'POS', valor
encontrado {pos
}."
,
tipoPOS
),
_
=>
throw
new
ArgumentException
(
$
"Valor no reconocido en archivo configuración, parámetro 'POS',
con
valor
{
tipoPOS
}
."
,
tipoPOS
),
};
};
}
}
}
}
gatewayGK/Infraestructura/DispensaDirectorioCmdsPOSBC.cs
0 → 100644
View file @
80ed77d5
using
Gateway.Comandos.POSBC
;
using
Serilog
;
/// <summary>
/// Instancia directorio de comandos POSBCTest
/// CUIDADO: Distinge los comandos por namespace.
/// </summary>
public
class
DispensaDirectorioCmdsPOSBC
:
IDispensaDirectorioCmds
{
/// <summary>
/// Retorna directorio de comandos instanciado y poblado de
/// comandos.
/// </summary>
public
static
CreaDirectorioCmds
Dispensa
()
{
Log
.
Information
(
"Instancia comandos POSBCTest."
);
return
new
IniciaDirectorioCmds
()
.
AgregaCmd
(
new
InitializeRequestCmd
())
.
DirectorioCmds
;
}
}
\ No newline at end of file
gatewayGK/Infraestructura/DispensaDirectorioCmdsPOSBCTest.cs
0 → 100644
View file @
80ed77d5
using
Gateway.Comandos.POSBCTest
;
using
Serilog
;
/// <summary>
/// Instancia directorio de comandos POSBCTest
/// CUIDADO: Distinge los comandos por namespace.
/// </summary>
public
class
DispensaDirectorioCmdsPOSBCTest
:
IDispensaDirectorioCmds
{
/// <summary>
/// Retorna directorio de comandos instanciado y poblado de
/// comandos.
/// </summary>
public
static
CreaDirectorioCmds
Dispensa
()
{
Log
.
Information
(
"Instancia comandos POSBCTest."
);
return
new
IniciaDirectorioCmds
()
.
AgregaCmd
(
new
InitializeRequestCmd
())
.
DirectorioCmds
;
}
}
\ No newline at end of file
gatewayGK/Infraestructura/Entorno.cs
View file @
80ed77d5
...
@@ -32,7 +32,7 @@ namespace GatewaySCO
...
@@ -32,7 +32,7 @@ namespace GatewaySCO
/// <summary>
/// <summary>
/// Obtener datos de entorno.
/// Obtener datos de entorno.
/// </summary>
/// </summary>
public
T
g
et
()
public
T
G
et
()
{
{
if
(
_datos
==
null
)
if
(
_datos
==
null
)
{
{
...
@@ -44,7 +44,7 @@ namespace GatewaySCO
...
@@ -44,7 +44,7 @@ namespace GatewaySCO
/// <summary>
/// <summary>
/// Fijar datos de entorno.
/// Fijar datos de entorno.
/// </summary>
/// </summary>
public
void
s
et
(
T
datos
)
public
void
S
et
(
T
datos
)
{
{
_datos
=
datos
;
_datos
=
datos
;
}
}
...
...
gatewayGK/POSBC/EntornoPOSBC.cs
View file @
80ed77d5
...
@@ -13,5 +13,5 @@ public class EntornoPOSBC
...
@@ -13,5 +13,5 @@ public class EntornoPOSBC
/// <summary>
/// <summary>
/// Socket en uso de conexión al POSBC.
/// Socket en uso de conexión al POSBC.
/// </summary>
/// </summary>
public
ClienteServidorPOSBC
ClientePOSBC
{
get
;
set
;
}
public
ClienteServidorPOSBC
ClientePOSBC
{
get
;
set
;
}
=
null
;
}
}
\ No newline at end of file
gatewayGK/Program.cs
View file @
80ed77d5
...
@@ -20,16 +20,37 @@ namespace GatewaySCO
...
@@ -20,16 +20,37 @@ namespace GatewaySCO
{
{
public
static
async
Task
Main
(
string
[]
args
)
public
static
async
Task
Main
(
string
[]
args
)
{
{
Console
.
WriteLine
(
"*** Gateway SCO - Servidor: procesa peticiones de Toshiba CHEC ***"
);
Config
(
args
);
ProgramGatewaySCO
program
=
new
();
TcpGateway
gateway
=
null
;
program
.
LeeActivaConfiguracion
(
args
);
switch
(
Entorno
<
Config
>.
Instancia
.
Get
().
POS
)
{
TcpGateway
gateway
=
new
TcpGateway
();
case
"POSBC"
:
gateway
=
new
(
Entorno
<
Config
>.
Instancia
.
Get
().
PortGateway
,
Entorno
<
ConfigPOSBC
>.
Instancia
.
Get
().
IpPOSBC
,
Entorno
<
ConfigPOSBC
>.
Instancia
.
Get
().
PortPOSBC
);
break
;
case
"POSBCTest"
:
gateway
=
new
(
Entorno
<
Config
>.
Instancia
.
Get
().
PortGateway
,
Entorno
<
ConfigPOSBCTest
>.
Instancia
.
Get
().
IpPOSBC
,
Entorno
<
ConfigPOSBCTest
>.
Instancia
.
Get
().
PortPOSBC
);
break
;
default
:
throw
new
Exception
(
"Tipo de POS en sección Config de archivo de configuración no reconocido."
);
}
await
gateway
.
Start
();
await
gateway
.
Start
();
}
}
public
void
LeeActivaConfiguracion
(
string
[]
args
)
/// <summary>
/// Lee configuración de archivo appsettings.json
/// La configuración se almacen en clase Entorno para consulta desde
/// cualquier parte del programa.
/// </summary>
/// <param name="args"></param>
/// <exception cref="ApplicationException"></exception>
public
static
void
Config
(
string
[]
args
)
{
{
// TODO - opción de incluir la activación en la cadena de configuración.
// TODO - opción de incluir la activación en la cadena de configuración.
...
@@ -52,7 +73,27 @@ namespace GatewaySCO
...
@@ -52,7 +73,27 @@ namespace GatewaySCO
Config
config
=
configBuilder
.
GetRequiredSection
(
"GatewayConfig"
).
Get
<
Config
>()
Config
config
=
configBuilder
.
GetRequiredSection
(
"GatewayConfig"
).
Get
<
Config
>()
??
throw
new
ApplicationException
(
"Archivo de configuración sin sección 'GatewayConfig'."
);
??
throw
new
ApplicationException
(
"Archivo de configuración sin sección 'GatewayConfig'."
);
Log
.
Information
(
config
.
ToString
());
Log
.
Information
(
config
.
ToString
());
Entorno
<
Config
>.
Instancia
.
Set
(
config
);
if
(
config
.
POS
==
"POSBC"
)
{
ConfigPOSBC
configPOSBC
=
configBuilder
.
GetRequiredSection
(
"POSBC"
).
Get
<
ConfigPOSBC
>()
??
throw
new
ApplicationException
(
"Archivo de configuración sin sección 'POSBC'."
);
Log
.
Information
(
configPOSBC
.
ToString
());
Entorno
<
ConfigPOSBC
>.
Instancia
.
Set
(
configPOSBC
);
Entorno
<
ConfigPOSBC
>.
Instancia
.
Get
().
IpPOSBC
=
configPOSBC
.
IpPOSBC
;
Entorno
<
ConfigPOSBC
>.
Instancia
.
Get
().
PortPOSBC
=
configPOSBC
.
PortPOSBC
;
}
}
if
(
config
.
POS
==
"POSBCTest"
)
{
ConfigPOSBCTest
configPOSBCTest
=
configBuilder
.
GetRequiredSection
(
"POSBCTest"
).
Get
<
ConfigPOSBCTest
>()
??
throw
new
ApplicationException
(
"Archivo de configuración sin sección 'POSBCTest'."
);
Log
.
Information
(
configPOSBCTest
.
ToString
());
Entorno
<
ConfigPOSBCTest
>.
Instancia
.
Set
(
configPOSBCTest
);
Entorno
<
ConfigPOSBCTest
>.
Instancia
.
Get
().
IpPOSBC
=
configPOSBCTest
.
IpPOSBC
;
Entorno
<
ConfigPOSBCTest
>.
Instancia
.
Get
().
PortPOSBC
=
configPOSBCTest
.
PortPOSBC
;
}
}
}
}
}
}
gatewayGK/Servidor/EvaPosSrvSCO.cs
View file @
80ed77d5
...
@@ -286,7 +286,7 @@ namespace EvaPosSCOSrv
...
@@ -286,7 +286,7 @@ namespace EvaPosSCOSrv
}
}
Log
.
Information
(
"Nuevo mensaje {bytes} bytes."
,
bytesLeidos
);
Log
.
Information
(
"Nuevo mensaje {bytes} bytes."
,
bytesLeidos
);
string
tipoPOS
=
Entorno
<
Config
>.
Instancia
.
g
et
().
POS
;
string
tipoPOS
=
Entorno
<
Config
>.
Instancia
.
G
et
().
POS
;
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------
// Procesa mensajes desde CHEC según la modalida de configuración del Gateway
// Procesa mensajes desde CHEC según la modalida de configuración del Gateway
...
@@ -310,7 +310,7 @@ namespace EvaPosSCOSrv
...
@@ -310,7 +310,7 @@ namespace EvaPosSCOSrv
continua
=
false
;
continua
=
false
;
}
}
byte
[]
mensajeSalida
=
Entorno
<
EntornoPOSBC
>.
Instancia
.
g
et
().
ClientePOSBC
.
EnviaRecibe
(
mensajeEntrada
);
byte
[]
mensajeSalida
=
Entorno
<
EntornoPOSBC
>.
Instancia
.
G
et
().
ClientePOSBC
.
EnviaRecibe
(
mensajeEntrada
);
// Remitir respuestas sin cambio a CHEC.
// Remitir respuestas sin cambio a CHEC.
socket
.
Send
(
mensajeSalida
,
0
,
mensajeSalida
.
Length
,
SocketFlags
.
None
);
socket
.
Send
(
mensajeSalida
,
0
,
mensajeSalida
.
Length
,
SocketFlags
.
None
);
...
@@ -370,7 +370,7 @@ namespace EvaPosSCOSrv
...
@@ -370,7 +370,7 @@ namespace EvaPosSCOSrv
/// Clase que controla el nivel básico de entrada y salida de mensajes.
/// Clase que controla el nivel básico de entrada y salida de mensajes.
/// Extrae la información del mensaje, limpiando la información de control.
/// Extrae la información del mensaje, limpiando la información de control.
/// </summary>
/// </summary>
class
Sesion
public
class
Sesion
{
{
static
ILogger
log
=
Log
.
ForContext
<
Sesion
>();
static
ILogger
log
=
Log
.
ForContext
<
Sesion
>();
readonly
static
bool
_isDebug
=
Log
.
IsEnabled
(
LogEventLevel
.
Debug
);
readonly
static
bool
_isDebug
=
Log
.
IsEnabled
(
LogEventLevel
.
Debug
);
...
@@ -381,11 +381,6 @@ namespace EvaPosSCOSrv
...
@@ -381,11 +381,6 @@ namespace EvaPosSCOSrv
/// </summary>
/// </summary>
public
static
TramaSCO
Entrada
(
byte
[]
buffer
,
int
nroBytes
)
public
static
TramaSCO
Entrada
(
byte
[]
buffer
,
int
nroBytes
)
{
{
if
(
_isDebug
)
{
log
.
Debug
(
"Buffer entrada: >>{subBuffer}<<"
,
buffer
);
}
TramaSCO
trama
=
new
()
TramaSCO
trama
=
new
()
{
{
Longitud
=
Convert
.
ToUInt32
(
nroBytes
)
Longitud
=
Convert
.
ToUInt32
(
nroBytes
)
...
@@ -413,7 +408,7 @@ namespace EvaPosSCOSrv
...
@@ -413,7 +408,7 @@ namespace EvaPosSCOSrv
// Extraer contenido.
// Extraer contenido.
trama
.
TextoXML
=
datos
.
Substring
(
inicioXML
);
trama
.
TextoXML
=
datos
.
Substring
(
inicioXML
);
log
.
Information
(
"{contenido}"
,
trama
.
TextoXML
);
log
.
Information
(
"
xml:\n
{contenido}"
,
trama
.
TextoXML
);
return
trama
;
return
trama
;
}
}
...
@@ -449,7 +444,7 @@ namespace EvaPosSCOSrv
...
@@ -449,7 +444,7 @@ namespace EvaPosSCOSrv
/// <summary>
/// <summary>
/// Clase que interpreta los mensajes y los transforma en objetos DTO.
/// Clase que interpreta los mensajes y los transforma en objetos DTO.
/// </summary>
/// </summary>
class
Presentacion
public
class
Presentacion
{
{
DirectorioAdaptadoresDTO
_adaptadores
;
DirectorioAdaptadoresDTO
_adaptadores
;
CreaDirectorioCmds
_comandos
;
CreaDirectorioCmds
_comandos
;
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment