From 95f1e3f3d80b3db3f75555ae799a9501b0672e1f Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 4 Sep 2019 11:30:37 -0500 Subject: [PATCH 1/6] checkpoint registro de conexion --- App_Code/ClsContPAQi.vb | 4 ++-- App_Code/ClsOC.vb | 45 ++++++++++++++++++++++++++++++++++++++-- App_Code/ClsOIEventos.vb | 44 ++++++++++++++++++++++++++++++++++++++- App_Code/ClsOS.vb | 44 ++++++++++++++++++++++++++++++++++++++- App_Code/ClsRH.vb | 14 ++++++------- 5 files changed, 138 insertions(+), 13 deletions(-) diff --git a/App_Code/ClsContPAQi.vb b/App_Code/ClsContPAQi.vb index 0d88941c7..35151b8c0 100644 --- a/App_Code/ClsContPAQi.vb +++ b/App_Code/ClsContPAQi.vb @@ -89,7 +89,7 @@ Public Class ClsContPAQi Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - ConexionAdd() + 'ConexionAdd() End Sub Private Sub SetTimeOut(Optional Tiempo As Integer = 30) SqlCommand.CommandTimeout = Tiempo @@ -11200,7 +11200,7 @@ Public Class ClsContPAQi ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). - ConexionClose() + 'ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsOC.vb b/App_Code/ClsOC.vb index c3ac9355d..fce2ade3e 100644 --- a/App_Code/ClsOC.vb +++ b/App_Code/ClsOC.vb @@ -16,7 +16,8 @@ Public Class ClsOC Private Data As DataTable 'Atributos de la clase Private disposedValue As Boolean = False - + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -167,7 +168,7 @@ Public Class ClsOC SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -178,6 +179,45 @@ Public Class ClsOC If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + + Try + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -2481,6 +2521,7 @@ Public Class ClsOC disposedValue = True End Sub Public Sub Dispose() Implements IDisposable.Dispose + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsOIEventos.vb b/App_Code/ClsOIEventos.vb index d5cb92c8e..6d875be92 100644 --- a/App_Code/ClsOIEventos.vb +++ b/App_Code/ClsOIEventos.vb @@ -16,6 +16,8 @@ Public Class ClsOIEventos Private SqlCommand As SqlCommand Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -109,7 +111,7 @@ Public Class ClsOIEventos SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -120,6 +122,45 @@ Public Class ClsOIEventos Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + + Try + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Sub IniciaTransacSQL() SqlTransacc = SqlConexion.BeginTransaction() End Sub @@ -1339,6 +1380,7 @@ Public Class ClsOIEventos ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsOS.vb b/App_Code/ClsOS.vb index 06cdedb50..f8348c05a 100644 --- a/App_Code/ClsOS.vb +++ b/App_Code/ClsOS.vb @@ -15,6 +15,8 @@ Public Class ClsOS Private Data As DataTable 'Atributos de la clase Private disposedValue As Boolean = False + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -98,7 +100,7 @@ Public Class ClsOS SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -109,6 +111,45 @@ Public Class ClsOS If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -1632,6 +1673,7 @@ Public Class ClsOS ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsRH.vb b/App_Code/ClsRH.vb index 44e3ba416..a36c44be4 100644 --- a/App_Code/ClsRH.vb +++ b/App_Code/ClsRH.vb @@ -81,14 +81,14 @@ Public Class ClsRH If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo - DataAdapter("PA_Sis_RegistrarConexion") - With SqlAdapter.SelectCommand.Parameters - .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name - .Add("@Modulo", SqlDbType.VarChar).Value = HttpContext.Current.Request.Url.AbsolutePath.ToString - .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output - End With Try + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With SqlAdapter.Fill(Data) CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero Catch ex As Exception @@ -102,7 +102,7 @@ Public Class ClsRH If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) - + CveConexion = 0 Try SqlAdapter.Fill(Data) From 004f94f11fdedfc7fd7463e8be6c950e04f07e18 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 4 Sep 2019 11:55:36 -0500 Subject: [PATCH 2/6] checkpoint registro de conexion --- App_Code/ClsPresupuestos.vb | 43 ++++++++++++++++++++++++++++- App_Code/ClsProductosServicios.vb | 46 +++++++++++++++++++++++++++++-- App_Code/ClsProsEncuestas.vb | 42 +++++++++++++++++++++++++++- 3 files changed, 127 insertions(+), 4 deletions(-) diff --git a/App_Code/ClsPresupuestos.vb b/App_Code/ClsPresupuestos.vb index 1b7e07982..130490b48 100644 --- a/App_Code/ClsPresupuestos.vb +++ b/App_Code/ClsPresupuestos.vb @@ -21,6 +21,8 @@ Public Class ClsPresupuestos 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -64,7 +66,7 @@ Public Class ClsPresupuestos End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -78,7 +80,45 @@ Public Class ClsPresupuestos End Sub #End Region +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "P R E S U P U E S T O S - P R O D U C T O S - D E T A L L E S" Public Function GetPresupuestosDetalleProductos(CvePresupuestoDetalle As Integer) As Boolean @@ -732,6 +772,7 @@ Public Class ClsPresupuestos ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index c94f491b2..4b7653fbc 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -18,6 +18,9 @@ Public Class ClsProductosServicios Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 + #End Region #Region "Propiedades" @@ -113,7 +116,7 @@ Public Class ClsProductosServicios Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub @@ -145,7 +148,7 @@ Public Class ClsProductosServicios End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -156,6 +159,45 @@ Public Class ClsProductosServicios If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function GetPS(CvePS As Integer, CveClasificacion As Integer, CveEmpresa As Integer, Optional Codigo As String = "-1", Optional Codigo2 As String = "-1", Optional CodigoBarras As String = "-1", Optional PS As String = "-1", Optional EsPaquete As Integer = -1, Optional CveSubProyecto As Integer = -1, Optional pAplicaParaVenta As Integer = -1, Optional pEstado As Integer = -1, Optional CveClasificacionCosto As Integer = -1, Optional CveTipoPS As Integer = -1, Optional CveCompuesto As Integer = -1, Optional SATClavePS As String = "-1") As Boolean Dim Retorno As Boolean = False diff --git a/App_Code/ClsProsEncuestas.vb b/App_Code/ClsProsEncuestas.vb index a337e00f3..2271cb05b 100644 --- a/App_Code/ClsProsEncuestas.vb +++ b/App_Code/ClsProsEncuestas.vb @@ -17,6 +17,8 @@ Public Class ClsProsEncuestas Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private StrSQL As StringBuilder + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -48,7 +50,7 @@ Public Class ClsProsEncuestas End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -60,7 +62,44 @@ Public Class ClsProsEncuestas If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function IniciaTransacSQL() As SqlTransaction If SqlTransacc Is Nothing Then SqlTransacc = SqlConexion.BeginTransaction() Return SqlTransacc @@ -752,6 +791,7 @@ Public Class ClsProsEncuestas ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub From b21a1c47841abfabd521840e004ba7175dbce2fa Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 4 Sep 2019 12:11:40 -0500 Subject: [PATCH 3/6] checkpoint agregar registro de conexion --- App_Code/ClsProspectos.vb | 43 +++++++++++++++++++++++++++++++++++++- App_Code/ClsProyectos.vb | 43 +++++++++++++++++++++++++++++++++++++- App_Code/ClsPruebasJJMQ.vb | 41 ++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 2 deletions(-) diff --git a/App_Code/ClsProspectos.vb b/App_Code/ClsProspectos.vb index 6bd8eb740..eeabe87ff 100644 --- a/App_Code/ClsProspectos.vb +++ b/App_Code/ClsProspectos.vb @@ -16,6 +16,8 @@ Public Class ClsProspectos Private Data As DataTable Private StrSQL As StringBuilder Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -161,7 +163,7 @@ Public Class ClsProspectos End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -173,6 +175,44 @@ Public Class ClsProspectos Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "Prospectos" Public Function GetNext() As Boolean @@ -4591,6 +4631,7 @@ Public Class ClsProspectos ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsProyectos.vb b/App_Code/ClsProyectos.vb index 47e176c0a..c9275c51b 100644 --- a/App_Code/ClsProyectos.vb +++ b/App_Code/ClsProyectos.vb @@ -23,6 +23,8 @@ Public Class ClsProyectos 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -55,7 +57,7 @@ Public Class ClsProyectos SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -66,6 +68,44 @@ Public Class ClsProyectos If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -210,6 +250,7 @@ Public Class ClsProyectos ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsPruebasJJMQ.vb b/App_Code/ClsPruebasJJMQ.vb index 3cbc168a2..2fcd9c0b4 100644 --- a/App_Code/ClsPruebasJJMQ.vb +++ b/App_Code/ClsPruebasJJMQ.vb @@ -18,6 +18,8 @@ Public Class ClsPruebasJJMQ Private StrSQL As StringBuilder Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -47,6 +49,7 @@ Public Class ClsPruebasJJMQ SqlAdapter = New SqlDataAdapter("", SqlConexion) StrSQL = New StringBuilder + ConexionAdd() End Sub Private Sub SqlDataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -58,7 +61,44 @@ Public Class ClsPruebasJJMQ If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + SqlDataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + SqlDataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub SqlDataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -134,6 +174,7 @@ Public Class ClsPruebasJJMQ ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub From 7e4646444aa33747d6cf63001d296fb403d727ef Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 4 Sep 2019 12:28:33 -0500 Subject: [PATCH 4/6] checkpoint registro de conexion --- App_Code/ClsPV.vb | 42 ++++++++++++++++++++++++++++++++++++++- App_Code/ClsPuntoVenta.vb | 42 ++++++++++++++++++++++++++++++++++++++- App_Code/ClsRMA.vb | 42 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 123 insertions(+), 3 deletions(-) diff --git a/App_Code/ClsPV.vb b/App_Code/ClsPV.vb index cf21fe045..2d882e6ec 100644 --- a/App_Code/ClsPV.vb +++ b/App_Code/ClsPV.vb @@ -21,6 +21,8 @@ Public Class ClsPV 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -64,7 +66,7 @@ Public Class ClsPV End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) @@ -76,7 +78,44 @@ Public Class ClsPV If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region 'Reporte de Ventas Public Function GetRepPVVentas(FechaI As String, FechaF As String, FechaIEjec As String, FechaFEjec As String, CveCliente As Integer, CveSubProyecto As Integer, CveSubProyectoEjecucion As Integer, @@ -193,6 +232,7 @@ Public Class ClsPV ' This code added by Visual Basic to correctly implement the disposable pattern. Public Sub Dispose() Implements IDisposable.Dispose ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsPuntoVenta.vb b/App_Code/ClsPuntoVenta.vb index 7274c8c7b..2b1a20416 100644 --- a/App_Code/ClsPuntoVenta.vb +++ b/App_Code/ClsPuntoVenta.vb @@ -20,6 +20,8 @@ Public Class ClsPuntoVenta 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -84,7 +86,7 @@ Public Class ClsPuntoVenta End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) @@ -96,7 +98,44 @@ Public Class ClsPuntoVenta If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function GetVta_CortesDetalles(CveCorte As Integer) As Boolean Dim Retorno As Boolean = False @@ -390,6 +429,7 @@ Public Class ClsPuntoVenta ' This code added by Visual Basic to correctly implement the disposable pattern. Public Sub Dispose() Implements IDisposable.Dispose ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsRMA.vb b/App_Code/ClsRMA.vb index 6f4516bbd..92bbff8d7 100644 --- a/App_Code/ClsRMA.vb +++ b/App_Code/ClsRMA.vb @@ -17,6 +17,8 @@ Public Class ClsRMA Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -56,7 +58,7 @@ Public Class ClsRMA End If SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) With SqlAdapter.SelectCommand @@ -67,7 +69,44 @@ Public Class ClsRMA Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -181,6 +220,7 @@ Public Class ClsRMA ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub From db057fe1f5cb51941f380b879bea54e6d45bbed3 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 4 Sep 2019 12:43:53 -0500 Subject: [PATCH 5/6] checkpoint registro de conexion --- App_Code/ClsSAT.vb | 42 ++++++++++++++++++++++++++++++++++- App_Code/ClsSCTLicencias.vb | 44 +++++++++++++++++++++++++++++++++++-- App_Code/ClsSeguimiento.vb | 42 ++++++++++++++++++++++++++++++++++- 3 files changed, 124 insertions(+), 4 deletions(-) diff --git a/App_Code/ClsSAT.vb b/App_Code/ClsSAT.vb index 09df0c882..475b7e8b1 100644 --- a/App_Code/ClsSAT.vb +++ b/App_Code/ClsSAT.vb @@ -30,6 +30,8 @@ Public Class ClsSAT Private disposedValue As Boolean = False Private ContListado69B As Integer = 0 + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -78,7 +80,7 @@ Public Class ClsSAT SqlAdapter = New SqlDataAdapter("", SqlConexion) - 'ConexionAdd() + ConexionAdd() End Sub Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) @@ -90,7 +92,44 @@ Public Class ClsSAT Data = New DataTable If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function ActualizarListado69B(Ruta As String) As Boolean Dim respusta As Boolean = False @@ -337,6 +376,7 @@ Public Class ClsSAT ' This code added by Visual Basic to correctly implement the disposable pattern. Public Sub Dispose() Implements IDisposable.Dispose ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsSCTLicencias.vb b/App_Code/ClsSCTLicencias.vb index fe7650872..24e19a081 100644 --- a/App_Code/ClsSCTLicencias.vb +++ b/App_Code/ClsSCTLicencias.vb @@ -15,6 +15,8 @@ Public Class ClsSCTLicencias Private SqlCommand As SqlCommand Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -53,7 +55,7 @@ Public Class ClsSCTLicencias Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -64,10 +66,47 @@ Public Class ClsSCTLicencias End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "L I C E N C I A S " - + Public Function GetLicencias(CveLicencia As Integer, TipoLicencia As String, NumeroLicencia As String, FechaExpedicionInicio As String, FechaExpedicionFin As String) As Boolean Dim Retorno As Boolean = False @@ -226,6 +265,7 @@ Public Class ClsSCTLicencias ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsSeguimiento.vb b/App_Code/ClsSeguimiento.vb index 41ae9b40e..4f9aa53a0 100644 --- a/App_Code/ClsSeguimiento.vb +++ b/App_Code/ClsSeguimiento.vb @@ -14,6 +14,8 @@ Public Class ClsSeguimiento Private SqlAdapter As SqlDataAdapter Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -34,7 +36,7 @@ Public Class ClsSeguimiento Catch ex As Exception OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -45,7 +47,44 @@ Public Class ClsSeguimiento End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region " S E G U I M I E N T O " @@ -144,6 +183,7 @@ Public Class ClsSeguimiento ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub From b0627e5583a3f4b2fd79653d8a6116316c57ddee Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 4 Sep 2019 12:54:45 -0500 Subject: [PATCH 6/6] checkpoint registro conexion --- App_Code/ClsSisEmpresas.vb | 42 ++++++++++++++++++++++++++++++++ App_Code/ClsSisNotificaciones.vb | 42 +++++++++++++++++++++++++++++++- App_Code/ClsSisParametros.vb | 42 +++++++++++++++++++++++++++++++- 3 files changed, 124 insertions(+), 2 deletions(-) diff --git a/App_Code/ClsSisEmpresas.vb b/App_Code/ClsSisEmpresas.vb index de89d9b0c..7ae8e51ec 100644 --- a/App_Code/ClsSisEmpresas.vb +++ b/App_Code/ClsSisEmpresas.vb @@ -54,6 +54,8 @@ Public Class ClsSisEmpresas Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region @@ -221,6 +223,7 @@ Public Class ClsSisEmpresas SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -232,6 +235,44 @@ Public Class ClsSisEmpresas If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc Data = New DataTable End Sub +#Region "Conexiones" + + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Private Sub DataCommand(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) With SqlCommand .Parameters.Clear() @@ -1836,6 +1877,7 @@ Public Class ClsSisEmpresas ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose ( que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsSisNotificaciones.vb b/App_Code/ClsSisNotificaciones.vb index 7b07140fd..770dc4a57 100644 --- a/App_Code/ClsSisNotificaciones.vb +++ b/App_Code/ClsSisNotificaciones.vb @@ -45,6 +45,8 @@ Public Class ClsSisNotificaciones Private _ClavesNotificaciones As Dictionary(Of String, List(Of Integer)) Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "P R O P I E D A D E S" @@ -92,7 +94,7 @@ Public Class ClsSisNotificaciones 'Inicializamos las propiedades necesarias _ClavesNotificaciones = New Dictionary(Of String, List(Of Integer)) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -103,7 +105,44 @@ Public Class ClsSisNotificaciones End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region #Region "N O T I F I C A C I O N E S" Public Sub DispararNotificacion(CveNotificacion As Integer, CvesFiltro As List(Of Object), CveEmpresa As Integer) @@ -2046,6 +2085,7 @@ Public Class ClsSisNotificaciones ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub diff --git a/App_Code/ClsSisParametros.vb b/App_Code/ClsSisParametros.vb index f11dee532..ceb813bf4 100644 --- a/App_Code/ClsSisParametros.vb +++ b/App_Code/ClsSisParametros.vb @@ -25,6 +25,8 @@ Public Class ClsSisParametros Private _NombreUsuario As String Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'PARA REGISTRAR CONEXION + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -82,7 +84,7 @@ Public Class ClsSisParametros Catch ex As Exception Me.OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) End Try - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -93,7 +95,44 @@ Public Class ClsSisParametros End With Data = New DataTable End Sub +#Region "Conexiones" + Private Sub ConexionAdd() + If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + Try + 'DataAdapter(String.Format("INSERT INTO Sis_Conexiones (Clase,Modulo) VALUES ('ClsRH','{0}')", "RH/CatMotivosBaja"), CommandType.Text) ' pendiente de terminar parra registrar el cveconexion, falta el rarámetro de módulo + DataAdapter("PA_Sis_RegistrarConexion") + With SqlAdapter.SelectCommand.Parameters + .Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name + .Add("@Modulo", SqlDbType.VarChar).Value = String.Format("{0}{1}", HttpContext.Current.Request.Url.AbsolutePath.ToString, HttpContext.Current.Request.QueryString.ToString) + .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output + End With + SqlAdapter.Fill(Data) + CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + End Sub + + Private Sub ConexionClose() + If CveConexion > 0 AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then + + DataAdapter(String.Format("UPDATE Sis_Conexiones SET FechaCierre = GETDATE() WHERE CveConexion = {0}", CveConexion), CommandType.Text) + CveConexion = 0 + Try + SqlAdapter.Fill(Data) + + Catch ex As Exception + OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + End If + + End Sub +#End Region Public Function GetParametros() As Boolean Dim OnError As Boolean = False @@ -234,6 +273,7 @@ Public Class ClsSisParametros ' Visual Basic agregó este código para implementar correctamente el modelo descartable. Public Sub Dispose() Implements IDisposable.Dispose ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean). + ConexionClose() Dispose(True) GC.SuppressFinalize(Me) End Sub