From b459ac00e4ca415396bef916425fe731e4fda803 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Tue, 3 Sep 2019 11:01:27 -0500 Subject: [PATCH] checkpoint registro conexion --- App_Code/ClsClasificaciones.vb | 42 +++++++++++++++++++++++++++++-- App_Code/ClsClientes.vb | 42 +++++++++++++++++++++++++++++-- App_Code/ClsCompEstatusFactura.vb | 40 ++++++++++++++++++++++++++++- 3 files changed, 119 insertions(+), 5 deletions(-) diff --git a/App_Code/ClsClasificaciones.vb b/App_Code/ClsClasificaciones.vb index cac31225d..d1491e709 100644 --- a/App_Code/ClsClasificaciones.vb +++ b/App_Code/ClsClasificaciones.vb @@ -20,7 +20,8 @@ Public Class ClsClasificaciones Private StrSQL As StringBuilder Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -51,7 +52,7 @@ Public Class ClsClasificaciones 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) @@ -63,6 +64,42 @@ Public Class ClsClasificaciones 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("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 + 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) + + 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() @@ -531,6 +568,7 @@ Public Class ClsClasificaciones ' 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/ClsClientes.vb b/App_Code/ClsClientes.vb index fe0d35a9a..3ac2829ec 100644 --- a/App_Code/ClsClientes.vb +++ b/App_Code/ClsClientes.vb @@ -22,7 +22,8 @@ Public Class ClsClientes 'Atributos de la clase Private disposedValue As Boolean = False ' Para detectar llamadas redundantes - + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region #Region "Propiedades" @@ -187,7 +188,7 @@ Public Class ClsClientes 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 @@ -198,6 +199,42 @@ Public Class ClsClientes 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("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 + 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) + + 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() @@ -1586,6 +1623,7 @@ Public Class ClsClientes ' 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/ClsCompEstatusFactura.vb b/App_Code/ClsCompEstatusFactura.vb index 72da2252b..ab0d5245c 100644 --- a/App_Code/ClsCompEstatusFactura.vb +++ b/App_Code/ClsCompEstatusFactura.vb @@ -17,6 +17,8 @@ Public Class ClsCompEstatusFactura Private SqlTransacc As SqlTransaction Private Data As DataTable Private disposedValue As Boolean = False ' Para detectar llamadas redundantes + 'REGISTRAR CONEXIÓN + Private CveConexion As Integer = 0 #End Region @@ -47,7 +49,7 @@ Public Class ClsCompEstatusFactura SqlCommand = New SqlCommand("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion) - + ConexionAdd() End Sub Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) @@ -59,7 +61,42 @@ Public Class ClsCompEstatusFactura 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("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 + 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) + + 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 GetEstatusFactura() As Boolean Dim Retorno As Boolean = False @@ -189,6 +226,7 @@ Public Class ClsCompEstatusFactura ' 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