diff --git a/App_Code/ClsBancos.vb b/App_Code/ClsBancos.vb index e4b936d10..a2129f8a1 100644 --- a/App_Code/ClsBancos.vb +++ b/App_Code/ClsBancos.vb @@ -1718,9 +1718,9 @@ Public Class ClsBancos Return Retorno End Function - Public Function CancelarBancos_IE(CveUsuario As Integer, CveIE As Integer, MesAnterior As Boolean, IdPoliza As Integer, FolioPoliza As Integer, Optional FechaCancelacion As Date = MinFecha, Optional TipoMovimiento As Integer = 1) As Boolean + Public Function CancelarBancos_IE(CveUsuario As Integer, CveIE As Integer, MesAnterior As Boolean, IdPoliza As Integer, FolioPoliza As Integer, Optional FechaCancelacion As Date = MinFecha, Optional TipoMovimiento As Integer = 1) As Integer - Dim Retorno As Boolean = False + Dim Retorno As Integer = 0 DataAdapter("PA_Banc_IECancelar") With SqlAdapter.SelectCommand.Parameters @@ -1731,11 +1731,12 @@ Public Class ClsBancos .Add("@FolioPoliza", SqlDbType.Int).Value = FolioPoliza .Add("@FechaCancelacion", SqlDbType.Date).Value = FechaCancelacion .Add("@TipoMovimiento", SqlDbType.Int).Value = TipoMovimiento + .Add("@CvePrePoliza", SqlDbType.Int).Direction = ParameterDirection.Output End With Try SqlAdapter.Fill(Data) - Retorno = True + Retorno = SqlAdapter.SelectCommand.Parameters("@CvePrePoliza").Value.ToString.ToEntero Catch ex As Exception OnError("Ocurrió un error al cancelar el movimiento en bancos.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) End Try diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 1a74dda78..850cbb1c6 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5017,11 +5017,11 @@ Public Class ClsPaginas PaginaDict.Add("/PV/PVRepCompras.aspx".ToUpper(), 272) PaginaDict.Add("/PV/PVRepVentasCompras.aspx".ToUpper(), 273) - PaginaDict.Add("/Contratos/ContratoObra.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/RepContratosObraAvances.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/RepContratosObraAvancesDetalle.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/RepContratosObraAvancesPartida.aspx".ToUpper(), -1) - PaginaDict.Add("/Contratos/ContratoObraAutorizacion.aspx".ToUpper(), -1) + PaginaDict.Add("/Contratos/ContratoObra.aspx".ToUpper(), 911) + PaginaDict.Add("/Contratos/RepContratosObraAvances.aspx".ToUpper(), 914) + PaginaDict.Add("/Contratos/RepContratosObraAvancesDetalle.aspx".ToUpper(), 914) + PaginaDict.Add("/Contratos/RepContratosObraAvancesPartida.aspx".ToUpper(), 914) + PaginaDict.Add("/Contratos/ContratoObraAutorizacion.aspx".ToUpper(), 913) diff --git a/App_Code/Modelos.vb b/App_Code/Modelos.vb index b2e9e897d..2a0131d71 100644 --- a/App_Code/Modelos.vb +++ b/App_Code/Modelos.vb @@ -5105,6 +5105,12 @@ Namespace Modelos Dim ValidaVirtual = True Dim DtPSVirtual As New DataTable("DtTamanios") + Dim tCveAlmacen As Integer = -1 + + If ObjInventario.GetMovimientos(CveMovimiento, -1, -1, UsuarioActual.CveEmpresa) AndAlso ObjInventario.DtResultados.Rows.Count > 0 Then + tCveAlmacen = ObjInventario.DtResultados.FiltroPrimeroValor("CveAlmacen").ToEntero() + End If + If ObjInventario.GetMovimientosDetalleVirtual(CveMovimiento, UsuarioActual.CveEmpresa, CveMovimientoRelacionado:=CveMovimientoRelacionado) Then DtPSVirtual = ObjInventario.DtResultados End If @@ -5113,7 +5119,7 @@ Namespace Modelos Dim CveAlmacenVirtual As Integer = -1 Dim CveMovimientoRelacionadoVirtual As Integer = CveMovimiento - CveAlmacenVirtual = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, 24).FiltroPrimeroValor("CveAlmacen", $"CveSubProyecto={CveSubProyecto}").ToEntero() + CveAlmacenVirtual = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveAlmacen:=tCveAlmacen).FiltroPrimeroValor("CveAlmacenVirtual").ToEntero() If DtPSVirtual IsNot Nothing AndAlso DtPSVirtual.Rows.Count > 0 AndAlso CveAlmacenVirtual > 0 AndAlso CveConceptoMovimientoVirtual > 0 Then CveMovimientoVirtual = ObjInventario.AddMovimiento(CveAlmacenVirtual, CveConceptoMovimientoVirtual, 1, Now, -1, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, -1, CveVenta, -1, -1, diff --git a/Ashx/E141.ashx b/Ashx/E141.ashx index dd8ea7fcf..51b154202 100644 --- a/Ashx/E141.ashx +++ b/Ashx/E141.ashx @@ -1,14 +1,13 @@ <%@ WebHandler Language="VB" Class="E141" %> -Imports System -Imports System.Web +Option Strict On +Option Explicit On + Imports System.Data Imports System.Net.Http -Imports System.Net Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Imports Extensiones -Imports System.IO Public Class E141 : Implements IHttpHandler @@ -50,7 +49,7 @@ Public Class E141 : Implements IHttpHandler Public ReadOnly Property TokenAutorizacion As String Get If EsProduccion Then - Return "$2y$10$AGCCDbEoGEpd0ys89fuBXedtWlunwUeLRlo4MdeLyxDvJF4GwpL7a" + Return "$2y$10$8Mk3YeIkJESilIwD.U5dG.SsA4JloycJKbaGls8TNEw/AKBE1qane" Else Return "$2y$10$8Mk3YeIkJESilIwD.U5dG.SsA4JloycJKbaGls8TNEw/AKBE1qane" End If @@ -60,7 +59,7 @@ Public Class E141 : Implements IHttpHandler Public ReadOnly Property URLBase As String Get If EsProduccion Then - Return "https://services.fidelityapps.mx/" + Return "https://econollantas-pruebas.fidelityapps.mx" Else Return "https://econollantas-pruebas.fidelityapps.mx/" End If @@ -68,11 +67,11 @@ Public Class E141 : Implements IHttpHandler End Property Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest - context.Response.ContentType = "application/json" - Dim retorno As String = "no se encontro la variable" + Dim retorno As String = "" Try Dim Params = If(context.Request("P") = Nothing, "", context.Request("P").ToString()) + 'DESCARGA DEL PDF If Not String.IsNullOrEmpty(Params) Then Dim UrlParametros As Hashtable = Parametros(Decripta(Params)) @@ -80,41 +79,54 @@ Public Class E141 : Implements IHttpHandler If Not String.IsNullOrEmpty(File) Then ImprimirbytesPDF(context, DescargarFactura(File), File) End If + Else - End If + Dim Metodo = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString()) + 'OBTENER EXISTENCIAS + If Metodo = "GetExistencia" Then + context.Response.ContentType = "application/json" - Dim Metodo = If(context.Request("Metodo") = Nothing, "", context.Request("Metodo").ToString()) + Dim Codigo = If(context.Request("Sku") = Nothing, "", context.Request("Sku").ToString()) + retorno = GetExistencia(context, Codigo) - Dim FiltrarTodos = If(context.Request("FiltrarTodos") = Nothing, "", context.Request("FiltrarTodos").ToString()) + Else + context.Response.ContentType = "text/html" - If Metodo = "CrearActualizarProductos" Then - retorno = CrearActualizarProductos(If(FiltrarTodos = "1", True, False)) - End If + Dim FiltrarTodos = If(context.Request("FiltrarTodos") = Nothing, "", context.Request("FiltrarTodos").ToString()) - If Metodo = "ActualizarPrecios" Then - retorno = ActualizarPrecios(If(FiltrarTodos = "1", True, False)) - End If + Dim respuesta As Boolean = False - If Metodo = "ActualizarExistencias" Then - retorno = ActualizarExistencias(If(FiltrarTodos = "1", True, False)) - End If + 'TAREAS PROGRAMADAS + Select Case Metodo + Case "CrearActualizarProductos" + respuesta = CrearActualizarProductos(If(FiltrarTodos = "1", True, False)) + Case "ActualizarPrecios" + respuesta = ActualizarPrecios(If(FiltrarTodos = "1", True, False)) + Case "ActualizarExistencias" + respuesta = ActualizarExistencias() + Case "ActualizarVendedores" + respuesta = ActualizarVendedores(If(FiltrarTodos = "1", True, False)) + End Select - If Metodo = "ActualizarVendedores" Then - retorno = ActualizarVendedores(If(FiltrarTodos = "1", True, False)) - End If + If respuesta Then + retorno = "True" + Else + retorno = "False" + End If + + End If + + context.Response.Write(retorno) - If Metodo = "GetExistencia" Then - Dim Codigo = If(context.Request("Sku") = Nothing, "", context.Request("Sku").ToString()) - retorno = GetExistencia(context, Codigo) End If Catch ex As Exception + context.Response.ContentType = "text/html" retorno = ex.ToString() ex.GuardaLog(ex.ToString()) + context.Response.Write(retorno) End Try - - context.Response.Write(retorno) End Sub Private Function GetExistencia(ByVal context As HttpContext, Codigo As String) As String @@ -157,17 +169,23 @@ Public Class E141 : Implements IHttpHandler Using ObjPS As New ClsProductosServicios() If ObjPS.GetExistenciasEmpresa(Codigo, CveEmpresa) Then Dim ArrayPS As New JArray - For Each RowPS As DataRow In ObjPS.DtResultados.Rows - Dim producto As New JObject( - New JProperty("sku", RowPS("Codigo")), - New JProperty("stock", RowPS("Existencia")) - ) - ArrayPS.Add(producto) - Next + If ObjPS.DtResultados.Rows.Count > 0 Then + For Each RowPS As DataRow In ObjPS.DtResultados.Rows + Dim producto As New JObject( + New JProperty("sku", RowPS("Codigo")), + New JProperty("stock", RowPS("Existencia")) + ) + ArrayPS.Add(producto) + Next + respuesta.isSuccess = True + respuesta.message = "La existencia se obtuvo correctamente" + Else + respuesta.isSuccess = True + respuesta.message = "No se encontro ningun producto" + End If respuesta.products = ArrayPS - respuesta.isSuccess = True - respuesta.message = "La existencia se obtuvo correctamente" + Else respuesta.isSuccess = False respuesta.message = "Ocurrió un error al obtener la existencia" @@ -182,6 +200,7 @@ Public Class E141 : Implements IHttpHandler Dim Retorno As String = "{}" Try Using httpClient = New HttpClient() + httpClient.Timeout = New TimeSpan(0, 5, 0) Using request = New HttpRequestMessage(HttpMethod.Post, New Uri(url)) request.Headers.Add("token", TokenAutorizacion) @@ -233,12 +252,10 @@ Public Class E141 : Implements IHttpHandler ' Return Retorno 'End Function #Region "C R E A C I Ó N / A C T U A L I Z A C I Ó N - P R O D U C T O S" - Private Function CrearActualizarProductos(Todos As Boolean) As String - Return EnviarInformacion($"{Me.URLBase}api/services/products/import", GetProductosModificados(Todos)) - End Function - Private Function GetProductosModificados(Todos As Boolean) As String - Dim Retorno As String = "{}" + Private Function CrearActualizarProductos(Todos As Boolean) As Boolean + Dim Retorno As Boolean = False + Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios @@ -250,59 +267,124 @@ Public Class E141 : Implements IHttpHandler If DtPS IsNot Nothing Then - Dim ArrayPS As New JArray - For Each RowPS As DataRow In DtPS.Rows + If DtPS.Rows.Count > 0 AndAlso DtPS.Rows.Count = 1 Then + Dim Dt As DataTable = DtPS.FiltraPorIndices(0, 0) + Dim payload = New JObject() - Dim PSData As String() = RowPS("PS").ToString().Split(" ".ToCharArray()) + payload.Add(New JProperty("products", GenerarPayloadProductos(Dt))) - Dim Measurement As String = "", Size As String = "", alt_code As String = "" + Dim resp = EnviarInformacion($"{Me.URLBase}api/services/products/import", payload.ToString()) - If PSData.Length > 0 Then - Measurement = PSData(0) + CountPeticiones += 1 + + If IsValidJson(resp) Then + Dim respuesta = JObject.Parse(resp) + If respuesta("status").ToString() = "success" Then + CountPeticionesExitosas += 1 + End If End If - If PSData.Length > 1 Then - Size = PSData(1) - End If + Else + Dim TotalIndex As Integer = DtPS.Rows.Count - 1 + Dim TotaRegistrosPorPeticion As Integer = 500 + Dim PrevIndex As Integer = 0 + Dim CurrentIndex As Integer = 0 - alt_code = String.Concat(Measurement, Size) + While PrevIndex < TotalIndex + CurrentIndex += TotaRegistrosPorPeticion - Dim producto As New JObject( - New JProperty("clasificacion", RowPS("Clasificacion")), - New JProperty("category", "Prod"), - New JProperty("pza", RowPS("Unidad")), - New JProperty("sku", RowPS("Codigo")), - New JProperty("name", RowPS("PS")), - New JProperty("measurement", Measurement), - New JProperty("size", Size), - New JProperty("brand", RowPS("Marca")), - New JProperty("price", RowPS("Precio")), - New JProperty("active", RowPS("Estado")), - New JProperty("user", RowPS("UsuarioModifico")), - New JProperty("alt_code", alt_code), - New JProperty("short_description", ""), - New JProperty("description", ""), - New JProperty("currency", 1), - New JProperty("promo_price", RowPS("PrecioPromocion")) - ) + If CurrentIndex > TotalIndex Then + CurrentIndex = TotalIndex + End If - ArrayPS.Add(producto) - Next - Retorno = New JObject(New JProperty("products", ArrayPS)).ToString() + Dim Dt As DataTable = DtPS.FiltraPorIndices(PrevIndex, CurrentIndex) + Dim payload = New JObject() + + 'If Not EsProduccion Then + ' payload.Add(New JProperty("deleteNotIncluded", True)) + 'End If + + payload.Add(New JProperty("products", GenerarPayloadProductos(Dt))) + + PrevIndex = CurrentIndex + + Dim resp = EnviarInformacion($"{Me.URLBase}api/services/products/import", payload.ToString()) + + CountPeticiones += 1 + + If IsValidJson(resp) Then + Dim respuesta = JObject.Parse(resp) + If respuesta("status").ToString() = "success" Then + CountPeticionesExitosas += 1 + End If + End If + + Threading.Thread.Sleep(3000) + End While + End If + + End If + + If CountPeticionesExitosas = CountPeticiones Then + Retorno = True End If Return Retorno End Function + + Private Function GenerarPayloadProductos(DtPS As DataTable) As JArray + Dim ArrayPS As New JArray + For Each RowPS As DataRow In DtPS.Rows + + Dim PSData As String() = RowPS("PS").ToString().Split(" ".ToCharArray()) + + Dim Measurement As String = "", Size As String = "", alt_code As String = "" + + If PSData.Length > 0 Then + Measurement = PSData(0) + End If + + If PSData.Length > 1 Then + Size = PSData(1) + End If + + alt_code = String.Concat(Measurement, Size) + + Dim producto As New JObject( + New JProperty("clasificacion", RowPS("Clasificacion")), + New JProperty("category", "Prod"), + New JProperty("pza", RowPS("Unidad")), + New JProperty("sku", RowPS("Codigo")), + New JProperty("name", RowPS("PS")), + New JProperty("measurement", Measurement), + New JProperty("size", Size), + New JProperty("brand", RowPS("Marca")), + New JProperty("price", RowPS("Precio")), + New JProperty("active", RowPS("Estado")), + New JProperty("user", RowPS("UsuarioModifico")), + New JProperty("alt_code", alt_code), + New JProperty("short_description", ""), + New JProperty("description", ""), + New JProperty("currency", 1), + New JProperty("promo_price", RowPS("PrecioPromocion")) + ) + + ArrayPS.Add(producto) + Next + + Return ArrayPS + End Function #End Region #Region "A C T U A L I Z A R - P R E C I O S" - Private Function ActualizarPrecios(Todos As Boolean) As String - Return EnviarInformacion($"{Me.URLBase}api/services/products/price-import", GetPreciosModificados(Todos)) - End Function + 'Private Function ActualizarPrecios(Todos As Boolean) As String + ' Return EnviarInformacion($"{Me.URLBase}api/services/products/price-import", GetPreciosModificados(Todos)) + 'End Function - Private Function GetPreciosModificados(Todos As Boolean) As String - Dim Retorno As String = "{}" + Private Function ActualizarPrecios(Todos As Boolean) As Boolean + Dim Retorno As Boolean = False + Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios @@ -314,32 +396,90 @@ Public Class E141 : Implements IHttpHandler If DtPS IsNot Nothing Then - Dim ArrayPS As New JArray - For Each RowPS As DataRow In DtPS.Rows + If DtPS.Rows.Count > 0 AndAlso DtPS.Rows.Count = 1 Then + Dim Dt As DataTable = DtPS.FiltraPorIndices(0, 0) + Dim payload = New JObject() - Dim producto As New JObject( - New JProperty("sku", RowPS("Codigo")), - New JProperty("price", RowPS("Precio")), - New JProperty("promo_price", RowPS("PrecioPromocion")) - ) + payload.Add(New JProperty("products", GenerarPayloadPrecios(Dt))) + + + Dim resp = EnviarInformacion($"{Me.URLBase}api/services/products/price-import", payload.ToString()) + + CountPeticiones += 1 + + If IsValidJson(resp) Then + Dim respuesta = JObject.Parse(resp) + If respuesta("status").ToString() = "success" Then + CountPeticionesExitosas += 1 + End If + End If + + Else + Dim TotalIndex As Integer = DtPS.Rows.Count - 1 + Dim TotaRegistrosPorPeticion As Integer = 500 + Dim PrevIndex As Integer = 0 + Dim CurrentIndex As Integer = 0 + + While PrevIndex < TotalIndex + CurrentIndex += TotaRegistrosPorPeticion + + If CurrentIndex > TotalIndex Then + CurrentIndex = TotalIndex + End If + + Dim Dt As DataTable = DtPS.FiltraPorIndices(PrevIndex, CurrentIndex) + Dim payload = New JObject() + + payload.Add(New JProperty("products", GenerarPayloadPrecios(Dt))) + + PrevIndex = CurrentIndex + + Dim resp = EnviarInformacion($"{Me.URLBase}api/services/products/price-import", payload.ToString()) + + CountPeticiones += 1 + + If IsValidJson(resp) Then + Dim respuesta = JObject.Parse(resp) + If respuesta("status").ToString() = "success" Then + CountPeticionesExitosas += 1 + End If + End If + + Threading.Thread.Sleep(3000) + End While + End If - ArrayPS.Add(producto) - Next - Retorno = New JObject(New JProperty("products", ArrayPS)).ToString() End If Return Retorno End Function + + Private Function GenerarPayloadPrecios(DtPS As DataTable) As JArray + Dim ArrayPS As New JArray + For Each RowPS As DataRow In DtPS.Rows + + Dim producto As New JObject( + New JProperty("sku", RowPS("Codigo")), + New JProperty("price", RowPS("Precio")), + New JProperty("promo_price", RowPS("PrecioPromocion")) + ) + + ArrayPS.Add(producto) + Next + + Return ArrayPS + End Function #End Region #Region "A C T U A L I Z A R - E X I S T E N C I A S" - Private Function ActualizarExistencias() As String - Return EnviarInformacion($"{Me.URLBase}api/services/products/stock", GetPSExistencias()) - End Function + 'Private Function ActualizarExistencias() As String + ' Return EnviarInformacion($"{Me.URLBase}api/services/products/stock", GetPSExistencias()) + 'End Function - Private Function GetPSExistencias() As String - Dim Retorno As String = "{}" + Private Function ActualizarExistencias() As Boolean + Dim Retorno As Boolean = False + Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 Dim DtPS As DataTable = Nothing Using ObjPS As New ClsProductosServicios @@ -350,34 +490,90 @@ Public Class E141 : Implements IHttpHandler End Using If DtPS IsNot Nothing Then + If DtPS.Rows.Count > 0 AndAlso DtPS.Rows.Count = 1 Then - Dim ArrayPS As New JArray - For Each RowPS As DataRow In DtPS.Rows + Dim Dt As DataTable = DtPS.FiltraPorIndices(0, 0) + Dim payload = New JObject() - Dim producto As New JObject( - New JProperty("sku", RowPS("Codigo")), - New JProperty("branch_office_code", "01"), - New JProperty("stock", RowPS("Existencia")) - ) + payload.Add(New JProperty("stock", GenerarPayloadExistencias(Dt))) - ArrayPS.Add(producto) - Next - Retorno = New JObject(New JProperty("stock", ArrayPS)).ToString() + Dim resp = EnviarInformacion($"{Me.URLBase}api/services/products/stock", payload.ToString()) + + CountPeticiones += 1 + + If IsValidJson(resp) Then + Dim respuesta = JObject.Parse(resp) + If respuesta("status").ToString() = "success" Then + CountPeticionesExitosas += 1 + End If + End If + + Else + Dim TotalIndex As Integer = DtPS.Rows.Count - 1 + Dim TotaRegistrosPorPeticion As Integer = 500 + Dim PrevIndex As Integer = 0 + Dim CurrentIndex As Integer = 0 + + While PrevIndex < TotalIndex + CurrentIndex += TotaRegistrosPorPeticion + + If CurrentIndex > TotalIndex Then + CurrentIndex = TotalIndex + End If + + Dim Dt As DataTable = DtPS.FiltraPorIndices(PrevIndex, CurrentIndex) + Dim payload = New JObject() + + payload.Add(New JProperty("stock", GenerarPayloadExistencias(Dt))) + + PrevIndex = CurrentIndex + + Dim resp = EnviarInformacion($"{Me.URLBase}api/services/products/stock", payload.ToString()) + + CountPeticiones += 1 + + If IsValidJson(resp) Then + Dim respuesta = JObject.Parse(resp) + If respuesta("status").ToString() = "success" Then + CountPeticionesExitosas += 1 + End If + End If + + Threading.Thread.Sleep(3000) + End While + End If + End If + + If CountPeticionesExitosas = CountPeticiones Then + Retorno = True End If Return Retorno End Function + + Private Function GenerarPayloadExistencias(DtPS As DataTable) As JArray + Dim ArrayPS As New JArray + For Each RowPS As DataRow In DtPS.Rows + + Dim producto As New JObject( + New JProperty("sku", RowPS("Codigo")), + New JProperty("branch_office_code", "01"), + New JProperty("stock", RowPS("Existencia").ToString()) + ) + + ArrayPS.Add(producto) + Next + + Return ArrayPS + End Function #End Region #Region "A C T U A L I Z A R - E X I S T E N C I A S" - Private Function ActualizarVendedores(Todos As Boolean) As String - Return EnviarInformacion($"{Me.URLBase}api/v1/sellers/import", GetVendedores(Todos)) - End Function - - Private Function GetVendedores(Todos As Boolean) As String - Dim Retorno As String = "{}" + Private Function ActualizarVendedores(Todos As Boolean) As Boolean + Dim Retorno As Boolean = False + Dim CountPeticiones As Integer = 0, CountPeticionesExitosas As Integer = 0 Dim DtVendedores As DataTable = Nothing Using ObjPS As New ClsProductosServicios @@ -410,6 +606,11 @@ Public Class E141 : Implements IHttpHandler Apellido = String.Concat(VendedorData(0), " ", VendedorData(1)) End Select + If VendedorData.Length > 4 Then + Nombre = String.Concat(VendedorData(VendedorData.Length - 1), " ", VendedorData(VendedorData.Length)) + Apellido = String.Concat(VendedorData(0), " ", VendedorData(1)) + End If + Dim vendedor As New JObject( New JProperty("email", RowVendedor("Correo")), New JProperty("password", RowVendedor("Correo")), @@ -426,7 +627,19 @@ Public Class E141 : Implements IHttpHandler ArrayVendedores.Add(vendedor) Next - Retorno = New JObject(New JProperty("sellers", ArrayVendedores)).ToString() + + Dim payload = New JObject(New JProperty("sellers", ArrayVendedores)).ToString() + + Dim resp = EnviarInformacion($"{Me.URLBase}api/v1/sellers/import", payload) + + CountPeticiones += 1 + + If IsValidJson(resp) Then + Dim respuesta = JObject.Parse(resp) + If respuesta("status").ToString() = "success" Then + CountPeticionesExitosas += 1 + End If + End If End If Return Retorno @@ -495,4 +708,28 @@ Public Class E141 : Implements IHttpHandler Return URLParametros End Function + Private Shared Function IsValidJson(ByVal strInput As String) As Boolean + If String.IsNullOrWhiteSpace(strInput) Then + Return False + End If + + strInput = strInput.Trim() + + If (strInput.StartsWith("{") AndAlso strInput.EndsWith("}")) OrElse (strInput.StartsWith("[") AndAlso strInput.EndsWith("]")) Then + + Try + Dim obj = JToken.Parse(strInput) + Return True + Catch jex As JsonReaderException + Console.WriteLine(jex.Message) + Return False + Catch ex As Exception + Console.WriteLine(ex.ToString()) + Return False + End Try + Else + Return False + End If + End Function + End Class \ No newline at end of file diff --git a/Ashx/SIGWeb.ashx b/Ashx/SIGWeb.ashx index 46d96e18d..0b6332772 100644 --- a/Ashx/SIGWeb.ashx +++ b/Ashx/SIGWeb.ashx @@ -699,7 +699,7 @@ Public Class SIGWeb : Implements IHttpHandler, IRequiresSessionState 'verifica existencias - If Pagina.Contiene("ventas/ventas", "oc/oc", "inv/traspaso") AndAlso CveEmpresa.Contiene(72, 80, 119, 140, 141, 152, 153) Then + If Pagina.Contiene("ventas/ventas", "oc/oc", "inv/traspaso") AndAlso CveEmpresa.Contiene(72, 80, 119, 140, 141, 152, 153, 159, 160, 161, 162, 163) Then UsaGlobal = False If CveEmpresa = 140 And Pagina.Contiene("ventas/ventas") Then diff --git a/Bancos/IE.aspx b/Bancos/IE.aspx index 574ec5150..38f89fdc3 100644 --- a/Bancos/IE.aspx +++ b/Bancos/IE.aspx @@ -1180,7 +1180,10 @@