From b21a1c47841abfabd521840e004ba7175dbce2fa Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 4 Sep 2019 12:11:40 -0500 Subject: [PATCH] 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