checkpoint registro de conexion

This commit is contained in:
Antonio Gonzalez
2019-09-04 12:43:53 -05:00
parent 7e4646444a
commit db057fe1f5
3 changed files with 124 additions and 4 deletions

View File

@@ -30,6 +30,8 @@ Public Class ClsSAT
Private disposedValue As Boolean = False Private disposedValue As Boolean = False
Private ContListado69B As Integer = 0 Private ContListado69B As Integer = 0
'PARA REGISTRAR CONEXION
Private CveConexion As Integer = 0
#End Region #End Region
#Region "Propiedades" #Region "Propiedades"
@@ -78,7 +80,7 @@ Public Class ClsSAT
SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion)
'ConexionAdd() ConexionAdd()
End Sub End Sub
Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure) Private Sub DataAdapter(ByVal pStrSQL As String, Optional ByVal TipoComando As CommandType = CommandType.StoredProcedure)
@@ -90,7 +92,44 @@ Public Class ClsSAT
Data = New DataTable Data = New DataTable
If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc If SqlTransacc IsNot Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc
End Sub 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 Public Function ActualizarListado69B(Ruta As String) As Boolean
Dim respusta As Boolean = False Dim respusta As Boolean = False
@@ -337,6 +376,7 @@ Public Class ClsSAT
' This code added by Visual Basic to correctly implement the disposable pattern. ' This code added by Visual Basic to correctly implement the disposable pattern.
Public Sub Dispose() Implements IDisposable.Dispose Public Sub Dispose() Implements IDisposable.Dispose
' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above. ' Do not change this code. Put cleanup code in Dispose(disposing As Boolean) above.
ConexionClose()
Dispose(True) Dispose(True)
GC.SuppressFinalize(Me) GC.SuppressFinalize(Me)
End Sub End Sub

View File

@@ -15,6 +15,8 @@ Public Class ClsSCTLicencias
Private SqlCommand As SqlCommand Private SqlCommand As SqlCommand
Private Data As DataTable Private Data As DataTable
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'PARA REGISTRAR CONEXION
Private CveConexion As Integer = 0
#End Region #End Region
#Region "Propiedades" #Region "Propiedades"
@@ -53,7 +55,7 @@ Public Class ClsSCTLicencias
Catch ex As Exception Catch ex As Exception
OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
End Try End Try
ConexionAdd()
End Sub End Sub
Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) Private Sub DataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure)
@@ -64,10 +66,47 @@ Public Class ClsSCTLicencias
End With End With
Data = New DataTable Data = New DataTable
End Sub 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 " #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 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 Dim Retorno As Boolean = False
@@ -226,6 +265,7 @@ Public Class ClsSCTLicencias
' Visual Basic agregó este código para implementar correctamente el modelo descartable. ' Visual Basic agregó este código para implementar correctamente el modelo descartable.
Public Sub Dispose() Implements IDisposable.Dispose 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). ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean).
ConexionClose()
Dispose(True) Dispose(True)
GC.SuppressFinalize(Me) GC.SuppressFinalize(Me)
End Sub End Sub

View File

@@ -14,6 +14,8 @@ Public Class ClsSeguimiento
Private SqlAdapter As SqlDataAdapter Private SqlAdapter As SqlDataAdapter
Private Data As DataTable Private Data As DataTable
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'PARA REGISTRAR CONEXION
Private CveConexion As Integer = 0
#End Region #End Region
#Region "Propiedades" #Region "Propiedades"
@@ -34,7 +36,7 @@ Public Class ClsSeguimiento
Catch ex As Exception Catch ex As Exception
OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex) OnError("Ocurrió un error al intentar conectarse a la base de datos.", ex)
End Try End Try
ConexionAdd()
End Sub End Sub
Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) Private Sub DataAdapter(pStrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure)
@@ -45,7 +47,44 @@ Public Class ClsSeguimiento
End With End With
Data = New DataTable Data = New DataTable
End Sub 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 " #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. ' Visual Basic agregó este código para implementar correctamente el modelo descartable.
Public Sub Dispose() Implements IDisposable.Dispose 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). ' No cambie este código. Coloque el código de limpieza en Dispose (ByVal que se dispone como Boolean).
ConexionClose()
Dispose(True) Dispose(True)
GC.SuppressFinalize(Me) GC.SuppressFinalize(Me)
End Sub End Sub