Pruebas para consulta por API
This commit is contained in:
@@ -6263,6 +6263,13 @@
|
|||||||
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
|
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function httpGet() {
|
||||||
|
var xmlHttp = new XMLHttpRequest();
|
||||||
|
xmlHttp.open("GET", "http://localhost:85/ashx/SIGWeb.ashx?metodo=GetTokenAngular", false); // false for synchronous request
|
||||||
|
xmlHttp.send(null);
|
||||||
|
return xmlHttp.responseText;
|
||||||
|
}
|
||||||
|
|
||||||
function CargaGraficaCompratamientoSaldoMensual(data, graph) {
|
function CargaGraficaCompratamientoSaldoMensual(data, graph) {
|
||||||
var chart = AmCharts.makeChart("chartdiv4", {
|
var chart = AmCharts.makeChart("chartdiv4", {
|
||||||
"type": "serial",
|
"type": "serial",
|
||||||
|
|||||||
@@ -7,7 +7,14 @@ Imports System.IO
|
|||||||
Imports Microsoft.Reporting.WebForms
|
Imports Microsoft.Reporting.WebForms
|
||||||
Imports System.Data
|
Imports System.Data
|
||||||
Imports System.Globalization
|
Imports System.Globalization
|
||||||
|
Imports System.Net.Http
|
||||||
|
Imports Newtonsoft.Json
|
||||||
|
Imports System.Threading.Tasks
|
||||||
|
Imports Newtonsoft.Json.Linq
|
||||||
|
Imports System.Net
|
||||||
|
Imports System.Collections.Generic
|
||||||
|
Imports Newtonsoft.Json.Serialization
|
||||||
|
|
||||||
Partial Class Clientes
|
Partial Class Clientes
|
||||||
Inherits ClsPaginas
|
Inherits ClsPaginas
|
||||||
|
|
||||||
@@ -1797,22 +1804,27 @@ Partial Class Clientes
|
|||||||
|
|
||||||
Return Retorno
|
Return Retorno
|
||||||
End Function
|
End Function
|
||||||
Private Sub CargaHistorial(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1)
|
Private Sub CargaHistorial(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1)
|
||||||
Dim ObjClientes As New ClsClientes()
|
Dim ObjClientes As New ClsClientes()
|
||||||
If ObjClientes.GetHistorialVentas(CveCliente, SelectTop, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
|
If ObjClientes.GetHistorialVentas(CveCliente, SelectTop, CveClienteSucursal:=DdlSucursalCliente.SelectedValue.ToEntero()) Then
|
||||||
If ObjClientes.DtResultados.Rows.Count > 0 Then
|
If ObjClientes.DtResultados.Rows.Count > 0 Then
|
||||||
|
|
||||||
'Carga Grid
|
'Carga Grid
|
||||||
DTHistorialVentas = ObjClientes.DtResultados
|
DTHistorialVentas = ObjClientes.DtResultados
|
||||||
GVHistorial.DataSource = ObjClientes.DtResultados
|
GVHistorial.DataSource = ObjClientes.DtResultados
|
||||||
Else
|
Else
|
||||||
GVHistorial.DataSource = Nothing
|
GVHistorial.DataSource = Nothing
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
GVHistorial.DataSource = Nothing
|
GVHistorial.DataSource = Nothing
|
||||||
End If
|
End If
|
||||||
ObjClientes.Dispose()
|
ObjClientes.Dispose()
|
||||||
GVHistorial.DataBind()
|
GVHistorial.DataBind()
|
||||||
|
|
||||||
|
'DTHistorialVentas = ConsultarHistorial()
|
||||||
|
'GVHistorial.DataSource = DTHistorialVentas
|
||||||
|
'GVHistorial.DataBind()
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
Private Function CargaCxC(Optional CveClienteSucursal As Integer = -1) As Boolean
|
Private Function CargaCxC(Optional CveClienteSucursal As Integer = -1) As Boolean
|
||||||
Dim Retorno As Boolean = False
|
Dim Retorno As Boolean = False
|
||||||
@@ -10348,5 +10360,125 @@ Partial Class Clientes
|
|||||||
End If
|
End If
|
||||||
ObjClientes.Dispose()
|
ObjClientes.Dispose()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Public Function ConsultarHistorial2(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1) As DataTable
|
||||||
|
Dim retorno As DataTable = Nothing
|
||||||
|
|
||||||
|
Using cliente As New HttpClient()
|
||||||
|
cliente.Timeout = New TimeSpan(0, 0, 15)
|
||||||
|
cliente.DefaultRequestHeaders.Add("Accept", "application/json")
|
||||||
|
|
||||||
|
Try
|
||||||
|
|
||||||
|
Dim Parametros As JObject = New JObject(
|
||||||
|
New JProperty("CveCliente", CveCliente),
|
||||||
|
New JProperty("SelectTop", SelectTop),
|
||||||
|
New JProperty("CveClienteSucursal", CveClienteSucursal),
|
||||||
|
New JProperty("TipoDocto", "-1")
|
||||||
|
)
|
||||||
|
|
||||||
|
Dim Url = New Uri(String.Format("{0}api/cliente/GetHistorialVentas?CveCliente={1}&SelectTop={2}&CveClienteSucursal={3}&TipoDocto={4}", "https://localhost:5001/", CveCliente, SelectTop, CveClienteSucursal, "-1"))
|
||||||
|
|
||||||
|
Dim response = cliente.GetAsync(Url).Result
|
||||||
|
|
||||||
|
If response.StatusCode = 200 Then
|
||||||
|
Dim json = response.Content.ReadAsStringAsync().Result
|
||||||
|
retorno = Newtonsoft.Json.JsonConvert.DeserializeObject(Of DataTable)(json)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Url = Nothing
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al obtener el historial de ventas", ex)
|
||||||
|
End Try
|
||||||
|
End Using
|
||||||
|
|
||||||
|
Return retorno
|
||||||
|
End Function
|
||||||
|
Public Function ConsultarHistorial(Optional SelectTop As Integer = 21, Optional CveClienteSucursal As Integer = -1) As DataTable
|
||||||
|
Dim retorno As DataTable = Nothing
|
||||||
|
|
||||||
|
Using cliente As New HttpClient()
|
||||||
|
cliente.Timeout = New TimeSpan(0, 0, 15)
|
||||||
|
cliente.DefaultRequestHeaders.Add("Authorization", String.Format("Bearer {0}", GetTokenAngular()))
|
||||||
|
Try
|
||||||
|
|
||||||
|
Dim Parametros As JObject = New JObject(
|
||||||
|
New JProperty("CveCliente", CveCliente),
|
||||||
|
New JProperty("SelectTop", SelectTop),
|
||||||
|
New JProperty("CveClienteSucursal", CveClienteSucursal),
|
||||||
|
New JProperty("TipoDocto", "-1")
|
||||||
|
)
|
||||||
|
System.Net.ServicePointManager.SecurityProtocol = DirectCast(3072, SecurityProtocolType)
|
||||||
|
|
||||||
|
Dim Url = New Uri(String.Format("{0}api/cliente/GetHistorialVentas", "http://localhost:5000/"))
|
||||||
|
|
||||||
|
Dim response = cliente.PostAsync(Url, New StringContent(Parametros.ToString(), Encoding.UTF8, "application/json")).Result
|
||||||
|
|
||||||
|
If response.StatusCode = 200 Then
|
||||||
|
Dim json = response.Content.ReadAsStringAsync().Result
|
||||||
|
|
||||||
|
Dim result = JsonConvert.DeserializeObject(Of MResult)(json)
|
||||||
|
|
||||||
|
If result.isSuccess Then
|
||||||
|
|
||||||
|
'Dim contractResolver = New DefaultContractResolver With
|
||||||
|
'{
|
||||||
|
' .NamingStrategy = New KebabCaseNamingStrategy()
|
||||||
|
'}
|
||||||
|
'Dim options = New JsonSerializerSettings() With
|
||||||
|
'{
|
||||||
|
' .ContractResolver = contractResolver,
|
||||||
|
' .Formatting = Formatting.Indented
|
||||||
|
'}
|
||||||
|
|
||||||
|
retorno = JsonConvert.DeserializeObject(Of DataTable)(result.result.ToString())
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
response.Dispose()
|
||||||
|
|
||||||
|
Url = Nothing
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al obtener el historial de ventas", ex)
|
||||||
|
End Try
|
||||||
|
End Using
|
||||||
|
|
||||||
|
Return retorno
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Property Token As String = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJDdmVQbGF0YWZvcm1hIjoiMSIsIkN2ZVVzdWFyaW8iOiIxNTM4IiwiQ3ZlRW1wcmVzYSI6IjIiLCJDdmVSb2wiOiIxIiwiRmVjaGEiOiJzw6FiYWRvLCAyMCBkZSBtYXJ6byBkZSAyMDIxIiwibmJmIjoxNjE2MjYzMzg2LCJleHAiOjE2MTYyNzQxODYsImlhdCI6MTYxNjI2MzM4Nn0.N_4yHZ0J41GgcXbAFfvyLvXiV-U8nRm85LoZhG1riNc"
|
||||||
|
|
||||||
|
Public Class MResult
|
||||||
|
Public Property isSuccess As Boolean
|
||||||
|
Public Property message As String
|
||||||
|
Public Property result As JArray
|
||||||
|
End Class
|
||||||
|
|
||||||
|
Public Function GetTokenAngular() As String
|
||||||
|
Dim retorno As String = ""
|
||||||
|
|
||||||
|
Using cliente As New HttpClient()
|
||||||
|
|
||||||
|
cliente.Timeout = New TimeSpan(0, 0, 15)
|
||||||
|
cliente.DefaultRequestHeaders.Add("Accept", "text/json")
|
||||||
|
|
||||||
|
Try
|
||||||
|
Dim Url = New Uri(String.Format("{0}ashx/SIGWeb.ashx?metodo=GetTokenAngular", "http://localhost:85/"))
|
||||||
|
|
||||||
|
Dim response = cliente.GetAsync(Url).Result
|
||||||
|
|
||||||
|
If response.StatusCode = 200 Then
|
||||||
|
retorno = response.Content.ReadAsStringAsync().Result
|
||||||
|
End If
|
||||||
|
|
||||||
|
Url = Nothing
|
||||||
|
Catch ex As Exception
|
||||||
|
OnError("Ocurrió un error al obtener el token", ex)
|
||||||
|
End Try
|
||||||
|
End Using
|
||||||
|
|
||||||
|
Return retorno
|
||||||
|
End Function
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user