ConnectionServiceLayer: unificar LoginPost en Login (eran identicos)
Las 4 llamadas a LoginPost() ahora llaman a Login(). Sin cambios de comportamiento. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a5a4160471
commit
ac725aed9b
2 files changed
+9
-96
No files matched your search
@@ -93,8 +93,10 @@ transferencias siempre, sin depender de `Notificacion`. Detalle y tabla en
|
|||||||
`TotalDetalle_Parcial`/`_Invoice`/`SerieOrigen` y un `if` vacío en
|
`TotalDetalle_Parcial`/`_Invoice`/`SerieOrigen` y un `if` vacío en
|
||||||
`CreateHojaRuta`) y se agregaron comentarios en Picking, Recibo,
|
`CreateHojaRuta`) y se agregaron comentarios en Picking, Recibo,
|
||||||
`ConnectionServiceLayer`, `CreditNotesRepository`, `InvoiceRepository` y
|
`ConnectionServiceLayer`, `CreditNotesRepository`, `InvoiceRepository` y
|
||||||
`RepositoryWrapper`. Sigue pendiente: código comentado, `Login`/`LoginPost`
|
`RepositoryWrapper`. Además se unificó `LoginPost()` en `Login()` (eran idénticos;
|
||||||
duplicados y `PatchAsyncSBA`.
|
las 4 llamadas a `LoginPost` ahora llaman a `Login`). Sigue pendiente: código
|
||||||
|
comentado, `PatchAsyncSBA` y la redundancia de las transferencias automáticas
|
||||||
|
(3 copias en Picking/Recibo) y de los métodos POST/PATCH del cliente.
|
||||||
- Sin probar contra SAP: confirmar con la factura 292410 que SAP devuelve
|
- Sin probar contra SAP: confirmar con la factura 292410 que SAP devuelve
|
||||||
`BaseType`/`BaseEntry` en las líneas y `BatchNumbers` en las de la Entrega.
|
`BaseType`/`BaseEntry` en las líneas y `BatchNumbers` en las de la Entrega.
|
||||||
|
|
||||||
@@ -148,7 +150,7 @@ Picking, columna `HORA` en `B_Log`. Lo que **no** se trajo: `Chatbots` y
|
|||||||
- `BE_ResultadoTransaccion<T>.NombreEstacion`: setter con recursión infinita
|
- `BE_ResultadoTransaccion<T>.NombreEstacion`: setter con recursión infinita
|
||||||
(bomba de tiempo; hoy nada lo asigna).
|
(bomba de tiempo; hoy nada lo asigna).
|
||||||
- `ConnectionServiceLayer.PatchAsyncSBA<T>`: con un `204` real devuelve `null`
|
- `ConnectionServiceLayer.PatchAsyncSBA<T>`: con un `204` real devuelve `null`
|
||||||
sin marcar éxito. `Login()`/`LoginPost()` duplicados.
|
sin marcar éxito.
|
||||||
- El cliente HTTP `bypass-ssl-validation` acepta cualquier certificado TLS hacia
|
- El cliente HTTP `bypass-ssl-validation` acepta cualquier certificado TLS hacia
|
||||||
el Service Layer (se quitó el método `ValidarCertificado`, que no se usaba).
|
el Service Layer (se quitó el método `ValidarCertificado`, que no se usaba).
|
||||||
- `appsettings.json` (fuera de git, en `.gitignore`) contiene credenciales
|
- `appsettings.json` (fuera de git, en `.gitignore`) contiene credenciales
|
||||||
|
|||||||
@@ -136,95 +136,6 @@ namespace Net.Connection.ServiceLayer
|
|||||||
return _responseLoginServiceLayer;
|
return _responseLoginServiceLayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Igual que Login(); duplicado historico (candidato a unificar)
|
|
||||||
public async Task<ResponseLoginServiceLayer> LoginPost()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// CONSTRUIMOS LA URL DE LA ACCIÓN
|
|
||||||
var urlBuilder_ = new StringBuilder();
|
|
||||||
urlBuilder_.Append(_url != null ? _url.TrimEnd('/') : "")
|
|
||||||
.Append("/Login");
|
|
||||||
var url_ = urlBuilder_.ToString();
|
|
||||||
|
|
||||||
// RECUPERAMOS EL HttpClient
|
|
||||||
|
|
||||||
var client_ = _httpClient.CreateClient("bypass-ssl-validation");
|
|
||||||
|
|
||||||
|
|
||||||
using (var request_ = new HttpRequestMessage())
|
|
||||||
{
|
|
||||||
///////////////////////////////////////
|
|
||||||
// CONSTRUIMOS LA PETICIÓN (REQUEST) //
|
|
||||||
///////////////////////////////////////
|
|
||||||
// DEFINIMOS EL Content CON EL OBJETO A ENVIAR SERIALIZADO.
|
|
||||||
request_.Content = new StringContent("{\"CompanyDB\":\"" + _company + "\",\"Password\":\"" + _password + "\",\"UserName\":\"" + _user + "\"}");
|
|
||||||
//request_.Content = new StringContent("{\"CompanyDB\":\"" + _company + "\",\"Password\":\"" + _password + "\",\"UserName\":\"" + _user + "\",\"Language\":\"" + _language + "\"}");
|
|
||||||
|
|
||||||
// DEFINIMOS EL ContentType, EN ESTE CASO ES "application/json"
|
|
||||||
request_.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
|
|
||||||
request_.Headers.Add("cache-control", "no-cache");
|
|
||||||
|
|
||||||
// DEFINIMOS EL MÉTODO HTTP
|
|
||||||
request_.Method = new HttpMethod("POST");
|
|
||||||
|
|
||||||
// DEFINIMOS LA URI
|
|
||||||
request_.RequestUri = new Uri(url_, System.UriKind.RelativeOrAbsolute);
|
|
||||||
|
|
||||||
// DEFINIMOS EL Accept, EN ESTE CASO ES "application/json"
|
|
||||||
request_.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json"));
|
|
||||||
|
|
||||||
/////////////////////////////////////////
|
|
||||||
// CONSTRUIMOS LA RESPUESTA (RESPONSE) //
|
|
||||||
/////////////////////////////////////////
|
|
||||||
// Utilizamos ConfigureAwait(false) para evitar el DeadLock.
|
|
||||||
var response_ = await client_.SendAsync(request_).ConfigureAwait(false);
|
|
||||||
|
|
||||||
// OBTENEMOS EL Content DEL RESPONSE como un String
|
|
||||||
// Utilizamos ConfigureAwait(false) para evitar el DeadLock.
|
|
||||||
var responseText_ = await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
|
|
||||||
|
|
||||||
// SI ES LA RESPUESTA ESPERADA !! ...
|
|
||||||
if (response_.StatusCode == System.Net.HttpStatusCode.OK) // 200
|
|
||||||
{
|
|
||||||
// DESERIALIZAMOS Content DEL RESPONSE
|
|
||||||
_responseLoginServiceLayer = JsonConvert.DeserializeObject<ResponseLoginServiceLayer>(responseText_);
|
|
||||||
_responseLoginServiceLayer.ServicioActivo = true;
|
|
||||||
_responseLoginServiceLayer.MensajeLogin = "Autenticación Correcta";
|
|
||||||
return _responseLoginServiceLayer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
// SI NO SE ESTÁ AUTORIZADO ...
|
|
||||||
if (response_.StatusCode == System.Net.HttpStatusCode.Unauthorized) // 401
|
|
||||||
{
|
|
||||||
_responseLoginServiceLayer = JsonConvert.DeserializeObject<ResponseLoginServiceLayer>(responseText_);
|
|
||||||
_responseLoginServiceLayer.ServicioActivo = false;
|
|
||||||
_responseLoginServiceLayer.MensajeLogin = "401 Unauthorized. Las credenciales de acceso del usuario son incorrectas.";
|
|
||||||
return _responseLoginServiceLayer;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
// CUALQUIER OTRA RESPUESTA ...
|
|
||||||
if (response_.StatusCode != System.Net.HttpStatusCode.OK && // 200
|
|
||||||
response_.StatusCode != System.Net.HttpStatusCode.NoContent) // 204
|
|
||||||
{
|
|
||||||
_responseLoginServiceLayer = JsonConvert.DeserializeObject<ResponseLoginServiceLayer>(responseText_);
|
|
||||||
_responseLoginServiceLayer.ServicioActivo = false;
|
|
||||||
_responseLoginServiceLayer.MensajeLogin = "401 Unauthorized. Las credenciales de acceso del usuario son incorrectas.";
|
|
||||||
return _responseLoginServiceLayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// RETORNAMOS EL OBJETO POR DEFECTO ESPERADO
|
|
||||||
return _responseLoginServiceLayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_responseLoginServiceLayer.ServicioActivo = false;
|
|
||||||
_responseLoginServiceLayer.MensajeLogin = ex.Message.ToString();
|
|
||||||
return _responseLoginServiceLayer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// GET al Service Layer. dinamico = true: la respuesta es una sola entidad (ej. Invoices(123)); false: coleccion { value: [...] }
|
// GET al Service Layer. dinamico = true: la respuesta es una sola entidad (ej. Invoices(123)); false: coleccion { value: [...] }
|
||||||
public async Task<List<T>> GetAsync<T>(string Query, int maxpagesize,bool dinamico = false)
|
public async Task<List<T>> GetAsync<T>(string Query, int maxpagesize,bool dinamico = false)
|
||||||
{
|
{
|
||||||
@@ -394,7 +305,7 @@ namespace Net.Connection.ServiceLayer
|
|||||||
|
|
||||||
if (_responseLoginServiceLayer.error.code.ToString() == "301")
|
if (_responseLoginServiceLayer.error.code.ToString() == "301")
|
||||||
{
|
{
|
||||||
await LoginPost();
|
await Login();
|
||||||
}
|
}
|
||||||
|
|
||||||
goto band;
|
goto band;
|
||||||
@@ -528,7 +439,7 @@ namespace Net.Connection.ServiceLayer
|
|||||||
|
|
||||||
if (_responseLoginServiceLayer.error.code.ToString() == "301")
|
if (_responseLoginServiceLayer.error.code.ToString() == "301")
|
||||||
{
|
{
|
||||||
await LoginPost();
|
await Login();
|
||||||
}
|
}
|
||||||
|
|
||||||
goto band;
|
goto band;
|
||||||
@@ -657,7 +568,7 @@ namespace Net.Connection.ServiceLayer
|
|||||||
|
|
||||||
if (_responseLoginServiceLayer.error.code.ToString() == "301")
|
if (_responseLoginServiceLayer.error.code.ToString() == "301")
|
||||||
{
|
{
|
||||||
await LoginPost();
|
await Login();
|
||||||
}
|
}
|
||||||
|
|
||||||
goto band;
|
goto band;
|
||||||
@@ -783,7 +694,7 @@ namespace Net.Connection.ServiceLayer
|
|||||||
|
|
||||||
if (_responseLoginServiceLayer.error.code.ToString() == "301")
|
if (_responseLoginServiceLayer.error.code.ToString() == "301")
|
||||||
{
|
{
|
||||||
await LoginPost();
|
await Login();
|
||||||
goto band;
|
goto band;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user