From fcd3175678f7b255deddac0654a2662661c5b6ad Mon Sep 17 00:00:00 2001 From: Rakcsle Supertramp Date: Wed, 15 Apr 2020 08:27:33 -0700 Subject: [PATCH 1/4] Layout Por Grupos bloquear pago si no existe cuenta deposito --- Bancos/ProveedoresAbonar.aspx.vb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Bancos/ProveedoresAbonar.aspx.vb b/Bancos/ProveedoresAbonar.aspx.vb index 30fb51bf0..a971cf96e 100644 --- a/Bancos/ProveedoresAbonar.aspx.vb +++ b/Bancos/ProveedoresAbonar.aspx.vb @@ -2562,9 +2562,13 @@ Partial Class Bancos_ProveedoresAbonar BtnIEGuardar.Enabled = False BtnIEGuardar.ToolTip = "El proveedor no tiene cuentas deposito" - UpGuardar.Update() + Else + BtnIEGuardar.Enabled = True + BtnIEGuardar.ToolTip = "" End If + UpGuardar.Update() + End If End If From e4e7b952b74376d734177e7a56fe6cb8179f3032 Mon Sep 17 00:00:00 2001 From: Rakcsle Supertramp Date: Wed, 15 Apr 2020 09:13:02 -0700 Subject: [PATCH 2/4] Pago Electronico Por Grupos cambio de lugar Link que abre modal para validar cuentas beneficiarias --- Bancos/PagoElectronicoGrupos.aspx | 8 ++++---- Bancos/PagoElectronicoGrupos.aspx.vb | 7 +------ vwd.webinfo | 2 ++ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Bancos/PagoElectronicoGrupos.aspx b/Bancos/PagoElectronicoGrupos.aspx index 567686b7d..f9242d7a1 100644 --- a/Bancos/PagoElectronicoGrupos.aspx +++ b/Bancos/PagoElectronicoGrupos.aspx @@ -94,7 +94,9 @@ Altas: - + <%----%> + + Interbancarias: @@ -250,9 +252,7 @@    - - - + <%----%> diff --git a/Bancos/PagoElectronicoGrupos.aspx.vb b/Bancos/PagoElectronicoGrupos.aspx.vb index 09047cabb..683b16d2f 100644 --- a/Bancos/PagoElectronicoGrupos.aspx.vb +++ b/Bancos/PagoElectronicoGrupos.aspx.vb @@ -290,7 +290,7 @@ Partial Class Bancos_PagoElectronicoGrupos End If Next - LbNumeroAltas.Text = Altas.ToString + LnkNumeroAltas.Text = Altas.ToString LbNumeroInterbancarias.Text = Interbancarias.ToString LbNumeroBancomer.Text = Bancomer.ToString @@ -404,11 +404,6 @@ Partial Class Bancos_PagoElectronicoGrupos Protected Sub GvPendientes_RowDataBound(sender As Object, e As GridViewRowEventArgs) - If e.Row.RowType = DataControlRowType.Header Then - - e.Row.FCLinkButton("LnkCabeceraPendientes").Text = LbNumeroAltas.Text - - End If diff --git a/vwd.webinfo b/vwd.webinfo index c9e193dc4..6b76e11e1 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -50,6 +50,8 @@ + + From 2685e90023a60dad115498426f305832bc109c80 Mon Sep 17 00:00:00 2001 From: JORGE LUIS CAUDILLO ESPARZA Date: Wed, 15 Apr 2020 14:30:01 -0700 Subject: [PATCH 3/4] --- App_Code/ClsPaginas.vb | 110 ++++++++++++++++----------- App_Code/Empresa.vb | 90 +++++++++++----------- App_Code/WS/WSSIGVentas.vb | 85 +++++++++++++++++++++ App_Code/WS/WSUSer.vb | 151 +++++++++++++++++++++++++++++++++++++ App_Code/WS/WsUtility.vb | 105 ++++++++++++++++++++++++++ App_Code/WebApiConfig.vb | 1 + App_Code/modExtensiones.vb | 63 +++++++++++----- packages.config | 4 + vwd.webinfo | 6 ++ 9 files changed, 507 insertions(+), 108 deletions(-) create mode 100644 App_Code/WS/WSSIGVentas.vb create mode 100644 App_Code/WS/WSUSer.vb create mode 100644 App_Code/WS/WsUtility.vb diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index 70bf0364a..00f09143a 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -5138,56 +5138,74 @@ Public Class ClsPaginas 'limpio ReportViwer Dim sw As New System.Diagnostics.Stopwatch() sw.Start() + Dim bdir As String = AppDomain.CurrentDomain.BaseDirectory + RutaReporte.Replace("/", "\") + If Not RutaReporte.ToUpper().StartsWith(bdir.ToUpper()) Then + RutaReporte = String.Format("{0}{1}", bdir, RutaReporte) + End If + Dim CveUsuario As Integer = 0 + Dim CveEmpresa As Integer = 0 + If Context.Session("UsuarioSIG") IsNot Nothing Then + CveUsuario = UsuarioActual.CveUsuario + CveEmpresa = UsuarioActual.CveEmpresa + + End If Dim Bytes As Byte() = Nothing + Dim wsreport As New WSRDLC.WebServiceSoapClient + Dim params As New List(Of WSRDLC.ReportParameter) + Dim ds As New DataSet + For Each rpds As ReportDataSource In DataSource + Dim dt As DataTable = DirectCast(rpds.Value, Data.DataTable) + dt.TableName = rpds.Name + ds.Tables.Add(dt) + Next + For Each rpds As ReportParameter In Parametros + Dim param As New WSRDLC.ReportParameter + param.Name = rpds.Name + param.Values = {rpds.Values(0)} + params.Add(param) + Next + Dim ruta = wsreport.StreamPDF(RutaReporte, ds, params.ToArray(), NombreArchivo, Formato, CveEmpresa, CveUsuario) + If File.Exists(ruta) Then + Bytes = File.ReadAllBytes(ruta) + File.Delete(ruta) + End If + 'Dim setup As AppDomainSetup = New AppDomainSetup + 'With setup + ' .ApplicationBase = Environment.CurrentDirectory + ' .LoaderOptimization = LoaderOptimization.MultiDomainHost + 'End With + 'setup.SetCompatibilitySwitches({"NetFx40_LegacySecurityPolicy"}) + 'Dim _casPolicyEnabledDomain As AppDomain = AppDomain.CreateDomain("Full Trust", Nothing, setup) + 'Dim fllreport As ADSReportLib.FullTrustReportviewer = Nothing + 'Try - Dim setup As AppDomainSetup = New AppDomainSetup - With setup - .ApplicationBase = Environment.CurrentDirectory - .LoaderOptimization = LoaderOptimization.MultiDomainHost - End With - setup.SetCompatibilitySwitches({"NetFx40_LegacySecurityPolicy"}) - Dim _casPolicyEnabledDomain As AppDomain = AppDomain.CreateDomain("Full Trust", Nothing, setup) - Dim fllreport As ADSReportLib.FullTrustReportviewer = Nothing - Try - 'Dim rvNextgenReport2 As WebReportviewer.FullTrustReportviewer = CType(_casPolicyEnabledDomain.CreateInstanceFromAndUnwrap(GetType(WebReportviewer.FullTrustReportviewer).Assembly.CodeBase, GetType(WebReportviewer.FullTrustReportviewer).FullName), WebReportviewer.FullTrustReportviewer) - 'rvNextgenReport2.Initialize(DisplayName, ReportPath, Visible, reportParam, reportRenderFormat, DeviceInfo, repMainContent, repSubContent) + ' fllreport = CType(_casPolicyEnabledDomain.CreateInstanceFromAndUnwrap(GetType(ADSReportLib.FullTrustReportviewer).Assembly.CodeBase, GetType(ADSReportLib.FullTrustReportviewer).FullName), ADSReportLib.FullTrustReportviewer) - 'For Each _ReportDataSource As ReportDataSource In DataSources - ' rvNextgenReport2.AddDataSources(_ReportDataSource.Name, CType(_ReportDataSource.Value, DataTable)) - 'Next - - 'Return rvNextgenReport2.Render(reportRenderFormat, DeviceInfo) - fllreport = CType(_casPolicyEnabledDomain.CreateInstanceFromAndUnwrap(GetType(ADSReportLib.FullTrustReportviewer).Assembly.CodeBase, GetType(ADSReportLib.FullTrustReportviewer).FullName), ADSReportLib.FullTrustReportviewer) - - Dim bdir As String = AppDomain.CurrentDomain.BaseDirectory - RutaReporte.Replace("/", "\") - If Not RutaReporte.ToUpper().StartsWith(bdir.ToUpper()) Then - RutaReporte = String.Format("{0}{1}", bdir, RutaReporte) - End If - fllreport.Initialize("DisplayName", RutaReporte, Parametros.AsEnumerable(), New List(Of String()), True) - For Each RDS As ReportDataSource In DataSource - fllreport.AddDataSources(RDS.Name, DirectCast(RDS.Value, DataTable)) - Next - Dim Warnings As Warning() = Nothing - Dim StreamIds As String() = Nothing - Dim MimeType As String = Nothing - Dim Encoding As String = Nothing - Dim Extension As String = Nothing - Bytes = fllreport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds) - fllreport = Nothing - Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - Catch ex As Exception - GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") - 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 - 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") - Finally - AppDomain.Unload(_casPolicyEnabledDomain) - End Try - If fllreport IsNot Nothing Then fllreport.liberarecursos() + ' fllreport.Initialize("DisplayName", RutaReporte, Parametros.AsEnumerable(), New List(Of String()), True) + ' For Each RDS As ReportDataSource In DataSource + ' fllreport.AddDataSources(RDS.Name, DirectCast(RDS.Value, DataTable)) + ' Next + ' Dim Warnings As Warning() = Nothing + ' Dim StreamIds As String() = Nothing + ' Dim MimeType As String = Nothing + ' Dim Encoding As String = Nothing + ' Dim Extension As String = Nothing + ' Bytes = fllreport.Render(Formato, Nothing, MimeType, Encoding, Extension, StreamIds) + ' fllreport = Nothing + 'Catch ex As Microsoft.Reporting.WebForms.ScriptManagerNotFoundException + ' GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + ' 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + ' 'GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + 'Catch ex As Exception + ' GuardaLog($"Error: { If(ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, ex.Message) } | Descripcion: {If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException IsNot Nothing AndAlso ex.InnerException.InnerException.Message IsNot Nothing, ex.InnerException.InnerException.Message, If(ex.InnerException IsNot Nothing AndAlso ex.InnerException.Message IsNot Nothing, ex.InnerException.Message, "Sin descripcion"))} - Ruta {RutaReporte}") + ' 'HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017 + ' 'GuardaLog($"Error {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}") + 'Finally + ' AppDomain.Unload(_casPolicyEnabledDomain) + 'End Try + 'If fllreport IsNot Nothing Then fllreport.liberarecursos() sw.Stop() If sw.Elapsed.TotalSeconds > 10 Then diff --git a/App_Code/Empresa.vb b/App_Code/Empresa.vb index c16fa4e9b..2492f959c 100644 --- a/App_Code/Empresa.vb +++ b/App_Code/Empresa.vb @@ -4,51 +4,51 @@ Option Strict On Public Class Empresa - Public CveEmpresa As Integer - Public Empresa As String - Public NombreCorto As String - Public Direccion As String - Public NoExt As String - Public NoInt As String - Public Colonia As String - Public Ciudad As String - Public Estado As String - Public CP As Integer - Public RFC As String - Public CURP As String - Public RegistroPatronal As String - Public Telefono As String - Public Contacto As String - Public Mail As String - Public TipoFacturacion As String - Public ContraseñaKey As String - Public ArchivoKey As String - Public ArchivoCer As String - Public ArchivoPfx As String - Public BIUsuario As String - Public BIContraseña As String - Public Banner As String - Public FacturaProduccion As Boolean - Public FechaIng As Date - Public CveUsuario As Integer - Public SendMail As String - Public SendMailPassword As String - Public SendMailServer As String - Public SendMailPuerto As Integer - Public SendMailSSL As Boolean - Public Usuario As String - Public MostrarRetIVA As Boolean - Public EjercicioActual As Integer - Public PeriodoActual As Integer - Public GralSoloProyecto As Boolean - Public MetodoOC As Integer - Public CveMetodoInventario As Integer - Public RequiereCentroCostos As Boolean - Public EmpresaEncabezado As String - Public GrupoEmpresa As Integer - Public Extension As String - Public EsComercializadora As Boolean - Public BaseDatosNombre As String = "Ventas" + Public Property CveEmpresa As Integer + Public Property Empresa As String + Public Property NombreCorto As String + Public Property Direccion As String + Public Property NoExt As String + Public Property NoInt As String + Public Property Colonia As String + Public Property Ciudad As String + Public Property Estado As String + Public Property CP As Integer + Public Property RFC As String + Public Property CURP As String + Public Property RegistroPatronal As String + Public Property Telefono As String + Public Property Contacto As String + Public Property Mail As String + Public Property TipoFacturacion As String + Public Property ContraseñaKey As String + Public Property ArchivoKey As String + Public Property ArchivoCer As String + Public Property ArchivoPfx As String + Public Property BIUsuario As String + Public Property BIContraseña As String + Public Property Banner As String + Public Property FacturaProduccion As Boolean + Public Property FechaIng As Date + Public Property CveUsuario As Integer + Public Property SendMail As String + Public Property SendMailPassword As String + Public Property SendMailServer As String + Public Property SendMailPuerto As Integer + Public Property SendMailSSL As Boolean + Public Property Usuario As String + Public Property MostrarRetIVA As Boolean + Public Property EjercicioActual As Integer + Public Property PeriodoActual As Integer + Public Property GralSoloProyecto As Boolean + Public Property MetodoOC As Integer + Public Property CveMetodoInventario As Integer + Public Property RequiereCentroCostos As Boolean + Public Property EmpresaEncabezado As String + Public Property GrupoEmpresa As Integer + Public Property Extension As String + Public Property EsComercializadora As Boolean + Public Property BaseDatosNombre As String = "Ventas" 'Nuevos Public AreaGeografica As String diff --git a/App_Code/WS/WSSIGVentas.vb b/App_Code/WS/WSSIGVentas.vb new file mode 100644 index 000000000..1aefdebbe --- /dev/null +++ b/App_Code/WS/WSSIGVentas.vb @@ -0,0 +1,85 @@ +Imports System.Net +Imports System.Web.Http +Imports Extensiones +Imports WsUtility + +Namespace SIG + + + + Public Class SIGVentasController + Inherits ApiController + + + + Public Function CrearTrama( params As WsBody) As Object + Dim respuesta = "Entraste " 'New With {.Correcto = False, .Mensaje = "", .Datos = New JObject} + + Return respuesta + End Function + + + + + Public Function GetComplementoPago( params As WsBody) As Object + Dim respuesta As Data.DataTable = Nothing 'New With {.Correcto = False, .Mensaje = "", .Datos = New JObject} + + Dim CveCliente As Integer = -1 + Dim FechaI As DateTime = DateTime.Now + Dim FechaF As DateTime = DateTime.Now + Dim CveIE As Integer = -1 + Dim CveVenta As Integer = -1 + Dim opcion As Integer = -1 + Dim CveEmpresa As Integer = -1 + Dim status As Integer = -1 + + Dim continuar As Boolean = True + Dim jsobj As New JSutil(params.Datos) + + Dim value As String = Nothing + If continuar Then continuar = jsobj.GetValue("CveCliente", value) + If continuar Then CveCliente = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("FechaInicio", value) + If continuar Then DateTime.TryParseExact(value, "yyyyMMdd", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaI) + If continuar Then continuar = jsobj.GetValue("FechaFin", value) + If continuar Then DateTime.TryParseExact(value, "yyyyMMdd", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaF) + If continuar Then continuar = jsobj.GetValue("CveIE", value) + If continuar Then CveIE = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("Opcion", value) + If continuar Then opcion = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("CveVenta", value) + If continuar Then CveVenta = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("CveEmpresa", value) + If continuar Then CveEmpresa = value.ToEntero() + If continuar Then continuar = jsobj.GetValue("Estatus", value) + If continuar Then status = value.ToEntero() + + + Using Banco As New ClsBancos() + If Banco.GetComplementoPagosRep(CveCliente, FechaI, FechaF, CveIE, CveVenta, opcion, CveEmpresa, Estatus:=status) Then + respuesta = Banco.DtResultados + End If + End Using + + Return JSutil.strresponse(respuesta, (Not IsNothing(respuesta)), "") + End Function + ' GET api/ + Public Function GetValues() As IEnumerable(Of String) + Return New String() {"value1", "value2"} + End Function + ' GET api//5 + Public Function GetValue(ByVal id As Integer) As String + Return "value" + End Function + ' POST api/ + Public Sub PostValue( ByVal value As String) + End Sub + ' PUT api//5 + Public Sub PutValue(ByVal id As Integer, ByVal value As String) + End Sub + ' DELETE api//5 + Public Sub DeleteValue(ByVal id As Integer) + End Sub + End Class + +End Namespace diff --git a/App_Code/WS/WSUSer.vb b/App_Code/WS/WSUSer.vb new file mode 100644 index 000000000..6d375f6d6 --- /dev/null +++ b/App_Code/WS/WSUSer.vb @@ -0,0 +1,151 @@ + +Imports System.Net +Imports System.Web.Http +Imports Extensiones +Imports WsUtility + +Namespace SIG + + + + Public Class usuarioController 'SIGVentasController + Inherits ApiController + + + + Public Function Login( params As WsBody) As Object + 'Dim respuesta = "" 'New With {.Correcto = False, .Mensaje = "", .Datos = New JObject} + Dim continuar As Boolean = True + Dim Token As Integer + If True Then + Dim authHeader = Request.Headers.Authorization + Dim dataArray = Extensiones.Decripta(authHeader.Parameter).Split("|"c) + If dataArray.Length > 4 AndAlso IsNumeric(dataArray(0)) AndAlso IsNumeric(dataArray(1)) AndAlso IsNumeric(dataArray(4)) Then + + Dim CveUsuario As Integer = dataArray(0).ToEntero() + Dim FechaPeticion As DateTime + DateTime.TryParseExact(String.Format("{0} {1}", dataArray(2), dataArray(3)), "ddMMyyyy HHmm", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaPeticion) + Dim CveEmpresa As Integer = dataArray(4).ToEntero() + + Dim diferencia As Double = (FechaPeticion - DateTime.Now).TotalMinutes + Token = diferencia.ToString("N0").ToEntero() + End If + End If + Dim jsobj As New JSutil(params.Datos) + + Dim username As String = Nothing + Dim password As String = Nothing + Dim CveEmpresastr As String = "-1" + Dim value As String = Nothing + If continuar Then continuar = jsobj.GetValue("UsuarioName", value) + If continuar Then username = value + If continuar Then continuar = jsobj.GetValue("Password", value) + If continuar Then password = value + If jsobj.GetValue("CveEmpresa", value) Then CveEmpresastr = value + + Dim Retorno As List(Of String) = Nothing + If continuar Then + Using objuser As New ClsSisUsuarios + Dim user As Usuario = objuser.ValidaUsuario(username, Extensiones.ModExtensiones.Encripta(password), "-1", CveEmpresastr.ToEntero()) + + Dim OjEmpresa As Empresa = Nothing + If user IsNot Nothing Then + If CveEmpresastr.ToEntero() > 0 Then + user.CveEmpresa = CveEmpresastr.ToEntero() + End If + Using ObjEmpresa As New ClsSisEmpresas() + + If ObjEmpresa.GetEmpresas(user.CveEmpresa, "-1", "-1", "-1", "-1") Then + 'If ObjEmpresa.GetEmpresasFuncionalidades(user.CveEmpresa) Then + ' Dim dttmp As Data.DataTable = ObjEmpresa.DtResultados + + ' Dim EmpresasFuncionalidades As New HybridDictionary + ' For Each Row As Data.DataRow In dttmp.Rows + ' EmpresasFuncionalidades.Add(Convert.ToInt32(Row("CveFuncionalidad")), Row("Valor").ToString) + ' Next + ' ObjEmpresa.Empresa.SetFuncionalidades(EmpresasFuncionalidades) + 'End If + + OjEmpresa = ObjEmpresa.Empresa + End If + End Using + Dim Retornouser As UsuarioApp + Retornouser = New UsuarioApp With { + .CveUsuario = user.CveUsuario, + .Nombre = user.Nombre, + .UsuarioName = user.Usuario, + .CveRol = user.CveRol, + .Rol = user.Rol, + .CveEmpresa = user.CveEmpresa, + .Token = Token', .Empresa = OjEmpresa + } + Retorno = New List(Of String) + Retorno.Add(Extensiones.ModExtensiones.Encripta(Newtonsoft.Json.JsonConvert.SerializeObject(Retornouser))) + Retorno.Add(Extensiones.ModExtensiones.Encripta(Newtonsoft.Json.JsonConvert.SerializeObject(OjEmpresa))) + + End If + End Using + End If + Dim objrt = New WsBody With { + .Datos = Newtonsoft.Json.JsonConvert.SerializeObject(Retorno), + .IsFail = False, + .FailStr = "" + } + Return objrt + 'Return JSutil.strresponse(Retorno, (Not IsNothing(Retorno)), "") + End Function + + + + + + Public Function GetEmpresa() As Object + Dim retorno As Data.DataTable = Nothing + Using ObjEmpresas As New ClsSisEmpresas() + If ObjEmpresas.GetEmpresas(-1, "-1", "-1", "-1", "-1") Then + 'verifico si existe la carpeta de la empresa, sino la crea + For Each dr As Data.DataRow In ObjEmpresas.DtResultados.Rows + Dim Ruta As String = String.Format("{0}Empresas\{1}", AppDomain.CurrentDomain.BaseDirectory, dr("CveEmpresa")) + If Not IO.Directory.Exists(Ruta) Then IO.Directory.CreateDirectory(Ruta) + If Not System.IO.Directory.Exists(String.Format("{0}\XML\", Ruta)) Then System.IO.Directory.CreateDirectory(String.Format("{0}\XML\", Ruta)) + If Not System.IO.Directory.Exists(String.Format("{0}\PDF\", Ruta)) Then System.IO.Directory.CreateDirectory(String.Format("{0}\PDF\", Ruta)) + + Next + retorno = ObjEmpresas.DtResultados + End If + End Using + + + Return JSutil.strresponse(retorno, (Not IsNothing(retorno)), "") + End Function + + + + Public Function GetUsuariosEmpresa( params As WsBody) As Object + Dim retorno As Data.DataTable = Nothing + + Using ObjUsuarios As New ClsSisUsuarios() + If ObjUsuarios.GetUsuarios(-1, -1) Then + retorno = ObjUsuarios.DtResultados.FiltraParametros(String.Format("CveEmpresa = {0}", Extensiones.ModExtensiones.Decripta(params.Datos).ToEntero())) + End If + End Using + Return JSutil.strresponse(retorno, (Not IsNothing(retorno)), "") + End Function + End Class + + + Public Class UsuarioApp + Public Sub New() + End Sub + + Public Property CveUsuario As Integer + Public Property CveEmpresa As Integer + Public Property CveRol As Integer + Public Property Rol As String + Public Property Token As Integer + Public Property UsuarioName As String + Public Property Password As String + Public Property Nombre As String + + End Class +End Namespace diff --git a/App_Code/WS/WsUtility.vb b/App_Code/WS/WsUtility.vb new file mode 100644 index 000000000..ce5cf2ac1 --- /dev/null +++ b/App_Code/WS/WsUtility.vb @@ -0,0 +1,105 @@ +Imports System.Net.Http +Imports Microsoft.VisualBasic + + +Namespace WsUtility + + 'Public Class SigAuthenticationAttribute + ' Inherits Http.Filters.AuthorizationFilterAttribute + + + ' Public Sub New() + + ' End Sub + + ' Public Overrides Sub OnAuthorization(ByVal actionContext As Http.Controllers.HttpActionContext) + ' Dim authHeader = actionContext.Request.Headers.Authorization + ' Dim noautorizado As Boolean = True + ' If authHeader IsNot Nothing Then + ' Try + + ' Dim decodedAuthenticationToken = Extensiones.Decripta(authHeader.Parameter) + ' Dim dataArray = decodedAuthenticationToken.Split("|"c) + ' If dataArray.Length > 4 Then + + ' Dim CveUsuario As Integer = dataArray(0) + ' Dim Token As Integer = dataArray(1) + ' Dim FechaPeticion As DateTime + ' DateTime.TryParseExact(String.Format("{0} {1}", dataArray(2), dataArray(3)), "ddMMyyyy HHmm", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaPeticion) + ' FechaPeticion = FechaPeticion.AddMinutes(Token) + ' Dim CveEmpresa As Integer = dataArray(4) + + ' Dim diferencia As Integer = Math.Abs((FechaPeticion - DateTime.Now).TotalMinutes) + ' If diferencia < 30 Then + ' noautorizado = False + ' End If + ' End If + ' Catch ex As Exception + ' noautorizado = True + ' End Try + ' End If + ' If noautorizado Then + ' HandleUnathorized(actionContext) + ' End If + ' End Sub + + ' Private Shared Sub HandleUnathorized(ByVal actionContext As Http.Controllers.HttpActionContext) + ' actionContext.Response = actionContext.Request.CreateResponse(Net.HttpStatusCode.Unauthorized) + ' actionContext.Response.Headers.Add("WWW-Authenticate", "Basic Scheme='Data' location = 'http://localhost:") + ' End Sub + + 'End Class + Public Class JSutil + Public Property jsobj As Newtonsoft.Json.Linq.JObject + Public Sub New(strjson As String, Optional isencripted As Boolean = True) + If isencripted Then strjson = Extensiones.ModExtensiones.Decripta(strjson) + Try + jsobj = Newtonsoft.Json.Linq.JObject.Parse(strjson) + Catch ex As Exception + Extensiones.GuardaLog(String.Format("Json Invalido '{0}'{2}{1}", strjson, ex.ToString(), vbNewLine)) + End Try + End Sub + Public Function GetValue(FieldName As String, ByRef Valor As String) As Boolean + Dim continuar As Boolean = False + If Not IsNothing(jsobj) Then + + Dim value As Newtonsoft.Json.Linq.JToken = Nothing + + continuar = jsobj.TryGetValue(FieldName, value) + If continuar Then + Valor = value.ToString() + End If + End If + Return continuar + End Function + + Public Shared Function strresponse(objeto As Object, isFail As Boolean, FailStr As String) As WsBody + Dim retorno As String = "" + retorno = Newtonsoft.Json.JsonConvert.SerializeObject(objeto) + retorno = Extensiones.ModExtensiones.Encripta(retorno) + Dim objrt = New WsBody With { + .Datos = retorno, + .IsFail = isFail, + .FailStr = FailStr + } + 'retorno = Newtonsoft.Json.JsonConvert.SerializeObject(objrt) + Return objrt + End Function + + + End Class + Class UserValidation + Public Property CveUsuario As Integer + Public Property Token As String + Public Property Valida As Boolean + Public Property Min As Integer + + End Class + Public Class WsBody + Public Property Datos As String + Public Property Metodo As String + Public Property IsFail As Boolean + Public Property FailStr As String + End Class + +End Namespace diff --git a/App_Code/WebApiConfig.vb b/App_Code/WebApiConfig.vb index bc5121bcc..4b8bc43e6 100644 --- a/App_Code/WebApiConfig.vb +++ b/App_Code/WebApiConfig.vb @@ -9,5 +9,6 @@ Public Class WebApiConfig config.EnableCors(Cors) config.MapHttpAttributeRoutes() config.Filters.Add(New Extensiones.BasicAuthenticationAttribute("sigfoxapiuser", "_$83965./54")) + 'config.Filters.Add(New WsUtility.SigAuthenticationAttribute()) End Sub End Class \ No newline at end of file diff --git a/App_Code/modExtensiones.vb b/App_Code/modExtensiones.vb index 4fe2b853f..7a640df12 100644 --- a/App_Code/modExtensiones.vb +++ b/App_Code/modExtensiones.vb @@ -3330,33 +3330,62 @@ Namespace Extensiones #Region "A T R I B U T O S" Public Class BasicAuthenticationAttribute Inherits AuthorizationFilterAttribute - + Private Const SigfoxPath As String = "/api/sigfox" + Private Const LoginPath As String = "/api/usuario/Login" Public Property Usuario As String - Public Property Contra As String - + Public Property Contra As String + + Public Sub New() + End Sub Public Sub New(Usuario As String, Contra As String) Me.Usuario = Usuario Me.Contra = Contra End Sub Public Overrides Sub OnAuthorization(ByVal actionContext As HttpActionContext) - Dim authHeader = actionContext.Request.Headers.Authorization - + Dim authHeader = actionContext.Request.Headers.Authorization + Dim noautorizado As Boolean = True If authHeader IsNot Nothing Then - Dim authenticationToken = actionContext.Request.Headers.Authorization.Parameter - Dim decodedAuthenticationToken = Encoding.UTF8.GetString(Convert.FromBase64String(authenticationToken)) - Dim usernamePasswordArray = decodedAuthenticationToken.Split(":"c) - Dim userName = usernamePasswordArray(0) - Dim password = usernamePasswordArray(1) + If Left(actionContext.Request.RequestUri.AbsolutePath, 11).ToUpper() = SigfoxPath.ToUpper() Then + Dim usernamePasswordArray = Encoding.UTF8.GetString(Convert.FromBase64String(authHeader.Parameter)).Split(":"c) + Dim userName = usernamePasswordArray(0) + Dim password = usernamePasswordArray(1) + noautorizado = Not (userName = Me.Usuario AndAlso password = Me.Contra) + Else + Try + + If actionContext.Request.RequestUri.AbsolutePath.ToUpper() <> LoginPath.ToUpper() Then + Dim dataArray = Extensiones.Decripta(authHeader.Parameter).Split("|"c) + If dataArray.Length > 4 AndAlso IsNumeric(dataArray(0)) AndAlso IsNumeric(dataArray(1)) AndAlso IsNumeric(dataArray(4)) Then + + Dim CveUsuario As Integer = dataArray(0).ToEntero() + Dim Token As Integer = dataArray(1).ToEntero() + Dim FechaPeticion As DateTime + DateTime.TryParseExact(String.Format("{0} {1}", dataArray(2), dataArray(3)), "ddMMyyyy HHmm", New Globalization.CultureInfo("es-MX"), Globalization.DateTimeStyles.None, FechaPeticion) + FechaPeticion = FechaPeticion.AddMinutes(Token) + Dim CveEmpresa As Integer = dataArray(4).ToEntero() + + Dim diferencia As Double = (FechaPeticion - DateTime.Now).TotalMinutes + + diferencia = Math.Abs(diferencia) + If diferencia < 5 Then 'si la fecha que me envía es de cuando menos hace cinco minuto, se permite accesar, para que no se copie ese parámetro y se esté recuperando información "medida de seguridad" + noautorizado = False + End If + End If + Else + noautorizado = False + End If + Catch ex As Exception + noautorizado = True + End Try + End If + - Dim isValid = (userName = Me.Usuario AndAlso password = Me.Contra) - - If isValid Then - Return - End If + End If + + If noautorizado Then + HandleUnathorized(actionContext) End If - - HandleUnathorized(actionContext) End Sub Private Shared Sub HandleUnathorized(ByVal actionContext As HttpActionContext) diff --git a/packages.config b/packages.config index 888b93e1c..0878a2900 100644 --- a/packages.config +++ b/packages.config @@ -10,6 +10,10 @@ + + + + diff --git a/vwd.webinfo b/vwd.webinfo index 40d1fe36c..c9e193dc4 100644 --- a/vwd.webinfo +++ b/vwd.webinfo @@ -40,6 +40,12 @@ + + + + + + From ba33616cf8da26a5e1735c97e0dc0b9579e6b228 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 15 Apr 2020 21:10:21 -0700 Subject: [PATCH 4/4] subiendo cambios en CRM --- App_Code/ClsCRM.vb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/App_Code/ClsCRM.vb b/App_Code/ClsCRM.vb index 67953b293..b4a4f540e 100644 --- a/App_Code/ClsCRM.vb +++ b/App_Code/ClsCRM.vb @@ -273,7 +273,7 @@ Public Class ClsCRM Return Retorno End Function - Public Function AddMedioCaptacion(MedioCaptacion As String, Descripcion As String, CveEmpresa As Integer, CveUsuarioIng As Integer) As Boolean + Public Function AddMedioCaptacion(MedioCaptacion As String, Descripcion As String, CveEmpresa As Integer, CveUsuarioIng As Integer, Optional CveTipoProceso As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CRM_MedioCaptacionAdd") With SqlAdapter.SelectCommand.Parameters @@ -281,6 +281,7 @@ Public Class ClsCRM .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveUsuarioIng", SqlDbType.Int).Value = CveUsuarioIng + .Add("@CveTipoProceso", SqlDbType.Int).Value = CveTipoProceso End With Try SqlAdapter.Fill(Data) @@ -291,7 +292,8 @@ Public Class ClsCRM Return Retorno End Function - Public Function UpdateMedioCaptacion(MedioCaptacion As String, Descripcion As String, CveEstatus As Boolean, CveMedioCaptacion As Integer) As Boolean + Public Function UpdateMedioCaptacion(MedioCaptacion As String, Descripcion As String, CveEstatus As Boolean, CveMedioCaptacion As Integer, + Optional CveTipoProceso As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CRM_MedioCaptacionUpdate") With SqlAdapter.SelectCommand.Parameters @@ -299,6 +301,7 @@ Public Class ClsCRM .Add("@Descripcion", SqlDbType.VarChar).Value = Descripcion .Add("@CveEstatus", SqlDbType.Bit).Value = CveEstatus .Add("@CveMedioCaptacion", SqlDbType.Int).Value = CveMedioCaptacion + .Add("@CveTipoProceso", SqlDbType.Int).Value = CveTipoProceso End With Try SqlAdapter.Fill(Data) @@ -590,13 +593,14 @@ Public Class ClsCRM Return Retorno End Function - Public Function AddProbabilidadAcercamiento(ProbabilidadAcercamiento As String, CveEmpresa As Integer, CveUsuarioIng As Integer) As Boolean + Public Function AddProbabilidadAcercamiento(ProbabilidadAcercamiento As String, CveEmpresa As Integer, CveUsuarioIng As Integer, Optional CveTipoProceso As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CRM_ProbabilidadAcercamientoAdd") With SqlAdapter.SelectCommand.Parameters .Add("@ProbabilidadAcercamiento", SqlDbType.VarChar).Value = ProbabilidadAcercamiento .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveUsuarioIng", SqlDbType.Int).Value = CveUsuarioIng + .Add("@CveTipoProceso", SqlDbType.Int).Value = CveTipoProceso End With Try SqlAdapter.Fill(Data) @@ -607,7 +611,8 @@ Public Class ClsCRM Return Retorno End Function - Public Function UpdateProbabilidadAcercamiento(ProbabilidadAcercamiento As String, CveEstatus As Boolean, CveProbabilidadAcercamiento As Integer) As Boolean + Public Function UpdateProbabilidadAcercamiento(ProbabilidadAcercamiento As String, CveEstatus As Boolean, CveProbabilidadAcercamiento As Integer, + Optional CveTipoProceso As Integer = -1) As Boolean Dim Retorno As Boolean = False DataAdapter("PA_CRM_ProbabilidadAcercamientoUpdate") With SqlAdapter.SelectCommand.Parameters @@ -615,6 +620,7 @@ Public Class ClsCRM .Add("@CveEstatus", SqlDbType.Bit).Value = CveEstatus .Add("@CveProbabilidadAcercamiento", SqlDbType.Int).Value = CveProbabilidadAcercamiento + .Add("@CveTipoProceso", SqlDbType.Int).Value = CveTipoProceso End With Try SqlAdapter.Fill(Data)