-- transaccion compartida

This commit is contained in:
rrene
2020-05-27 13:46:55 -07:00
parent b8d4cd1fbf
commit 9288e4ce8e
10 changed files with 81 additions and 41 deletions

View File

@@ -19,6 +19,7 @@ Public Class ClsCGame
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'REGISTRAR CONEXIÓN 'REGISTRAR CONEXIÓN
Private CveConexion As Integer = 0 Private CveConexion As Integer = 0
Private EsTransaccionCompartida As Boolean = False
Public ReadOnly Property DtResultados() As DataTable Public ReadOnly Property DtResultados() As DataTable
Get Get
@@ -54,6 +55,7 @@ Public Class ClsCGame
Else Else
SqlConexion = TransaccionCompartida.Connection SqlConexion = TransaccionCompartida.Connection
SqlTransacc = TransaccionCompartida SqlTransacc = TransaccionCompartida
EsTransaccionCompartida = True
End If End If
SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion)
@@ -71,7 +73,7 @@ Public Class ClsCGame
#Region "Conexiones" #Region "Conexiones"
Private Sub ConexionAdd() Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
Try Try
DataAdapter("PA_Sis_RegistrarConexion") DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters

View File

@@ -194,6 +194,10 @@ Public Class ClsClaseBase
SqlAdapter.Dispose() SqlAdapter.Dispose()
End If End If
If DTSet IsNot Nothing Then
DTSet.Dispose()
End If
GC.SuppressFinalize(Me) GC.SuppressFinalize(Me)
End Sub End Sub

View File

@@ -25,6 +25,7 @@ Public Class ClsContabilidad
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'REGISTRAR CONEXIONES ABIERTAS 'REGISTRAR CONEXIONES ABIERTAS
Private CveConexion As Integer = 0 Private CveConexion As Integer = 0
Private EsTransaccionCompartida As Boolean = False
Public Property CvePrePolizaDetalle As Integer Public Property CvePrePolizaDetalle As Integer
#End Region #End Region
@@ -97,6 +98,7 @@ Public Class ClsContabilidad
Else Else
SqlConexion = TransaccionCompartida.Connection SqlConexion = TransaccionCompartida.Connection
SqlTransacc = TransaccionCompartida SqlTransacc = TransaccionCompartida
EsTransaccionCompartida = True
End If End If
Mensaje = New StringBuilder Mensaje = New StringBuilder
SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion)
@@ -115,7 +117,7 @@ Public Class ClsContabilidad
#Region "Conexiones" #Region "Conexiones"
Private Sub ConexionAdd() Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
Try Try
DataAdapter("PA_Sis_RegistrarConexion") DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters
@@ -1120,7 +1122,11 @@ Public Class ClsContabilidad
If Empresa.TipoContabilizacion = 1 Then ' contabilidad en SIG If Empresa.TipoContabilizacion = 1 Then ' contabilidad en SIG
ContabilizaDesContabilizaPrePoliza(CvePrePoliza, True, Empresa.CveEmpresa) Retorno = ContabilizaDesContabilizaPrePoliza(CvePrePoliza, True, Empresa.CveEmpresa)
If Retorno Then
Mensaje.Append(String.Format("<a href='/Contabilidad/RegPrePolizaS.aspx?CvePrePoliza={0}' class='Texto' target='_blank'>{1}</a><br/>", CvePrePoliza, _ContaFolio))
End If
Else Else
If CvePrePoliza <= 0 Then Return False If CvePrePoliza <= 0 Then Return False

View File

@@ -18,6 +18,7 @@ Public Class ClsContratos
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'REGISTRAR CONEXIONES ABIERTAS 'REGISTRAR CONEXIONES ABIERTAS
Private CveConexion As Integer = 0 Private CveConexion As Integer = 0
Private EsTransaccionCompartida As Boolean = False
#End Region #End Region
#Region "Propiedades" #Region "Propiedades"
@@ -65,6 +66,7 @@ Public Class ClsContratos
Else Else
SqlConexion = TransaccionCompartida.Connection SqlConexion = TransaccionCompartida.Connection
SqlTransacc = TransaccionCompartida SqlTransacc = TransaccionCompartida
EsTransaccionCompartida = True
End If End If
SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion)
@@ -85,7 +87,7 @@ Public Class ClsContratos
#Region "Conexiones" #Region "Conexiones"
Private Sub ConexionAdd() Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
Try Try
DataAdapter("PA_Sis_RegistrarConexion") DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters

View File

@@ -19,6 +19,7 @@ Public Class ClsEdocumentacion
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'REGISTRAR CONEXIONES ABIERTAS 'REGISTRAR CONEXIONES ABIERTAS
Private CveConexion As Integer = 0 Private CveConexion As Integer = 0
Private EsTransaccionCompartida As Boolean = False
Private Sub SqlDataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure) Private Sub SqlDataAdapter(StrSQL As String, Optional TipoComando As CommandType = CommandType.StoredProcedure)
With SqlAdapter.SelectCommand With SqlAdapter.SelectCommand
@@ -56,6 +57,7 @@ Public Class ClsEdocumentacion
Else Else
SqlConexion = TransaccionCompartida.Connection SqlConexion = TransaccionCompartida.Connection
SqlTransacc = TransaccionCompartida SqlTransacc = TransaccionCompartida
EsTransaccionCompartida = True
End If End If
SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion)
@@ -69,11 +71,11 @@ Public Class ClsEdocumentacion
End With End With
If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc If Not SqlTransacc Is Nothing Then SqlAdapter.SelectCommand.Transaction = SqlTransacc
Data = New DataTable Data = New DataTable
End Sub End Sub
#Region "Conexiones" #Region "Conexiones"
Private Sub ConexionAdd() Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
Try Try
DataAdapter("PA_Sis_RegistrarConexion") DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters

View File

@@ -18,6 +18,7 @@ Public Class ClsInventarios
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
'REGISTRAR CONEXIONES ABIERTAS 'REGISTRAR CONEXIONES ABIERTAS
Private CveConexion As Integer = 0 Private CveConexion As Integer = 0
Private EsTransaccionCompartida As Boolean = False
#End Region #End Region
@@ -151,6 +152,7 @@ Public Class ClsInventarios
Else Else
SqlConexion = TransaccionCompartida.Connection SqlConexion = TransaccionCompartida.Connection
SqlTransacc = TransaccionCompartida SqlTransacc = TransaccionCompartida
EsTransaccionCompartida = True
End If End If
SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion)
@@ -169,7 +171,7 @@ Public Class ClsInventarios
#Region "Conexiones" #Region "Conexiones"
Private Sub ConexionAdd() Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
Try Try
DataAdapter("PA_Sis_RegistrarConexion") DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters

View File

@@ -2042,6 +2042,7 @@ Public Class ClsProductosServicios
' 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

@@ -50,20 +50,27 @@ Public Class ClsRH
Get Get
DSResultados = DSet DSResultados = DSet
End Get End Get
End Property End Property
#End Region #End Region
Sub New() Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing)
SqlConexion = New SqlConnection
SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString If TransaccionCompartida Is Nothing Then
SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlConexion = New SqlConnection
Try SqlConexion.ConnectionString = ConfigurationManager.ConnectionStrings("Conexion").ConnectionString
SqlConexion.Open() Try
ConexionAdd() SqlConexion.Open()
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
Else
SqlConexion = TransaccionCompartida.Connection
SqlTransacc = TransaccionCompartida
EsTransaccionCompartida = True
End If
SqlAdapter = New SqlDataAdapter("", SqlConexion)
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)
With SqlAdapter.SelectCommand With SqlAdapter.SelectCommand
@@ -73,21 +80,23 @@ Public Class ClsRH
End With End With
Data = New DataTable Data = New DataTable
End Sub End Sub
Private CveConexion As Integer = 0 Private CveConexion As Integer = 0
Private EsTransaccionCompartida As Boolean = False
#Region "Conexiones" #Region "Conexiones"
Private Sub ConexionAdd() Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then If Not EsTransaccionCompartida AndAlso 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(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 Try
DataAdapter("PA_Sis_RegistrarConexion") DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters
.Add("@Clase", SqlDbType.VarChar).Value = Me.GetType().Name .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("@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 .Add("@IDConexion", SqlDbType.Int).Direction = ParameterDirection.Output
End With End With
SqlAdapter.Fill(Data) SqlAdapter.Fill(Data)
CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero CveConexion = SqlAdapter.SelectCommand.Parameters("@IDConexion").Value.ToString.ToEntero
@@ -95,6 +104,7 @@ Public Class ClsRH
OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) OnError("Ocurrió un error registrar la conexión.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try End Try
End If End If
End Sub End Sub

View File

@@ -22,6 +22,8 @@ Public Class ClsVentas
'Atributos de la clase 'Atributos de la clase
Private disposedValue As Boolean = False ' Para detectar llamadas redundantes Private disposedValue As Boolean = False ' Para detectar llamadas redundantes
Private CveConexion As Integer = 0
Private EsTransaccionCompartida As Boolean = False
#End Region #End Region
@@ -75,7 +77,7 @@ Public Class ClsVentas
Public Sub RollBack() Public Sub RollBack()
SqlTransacc.Rollback() SqlTransacc.Rollback()
End Sub End Sub
Private CveConexion As Integer = 0
Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing) Sub New(Optional TransaccionCompartida As SqlTransaction = Nothing)
If TransaccionCompartida Is Nothing Then If TransaccionCompartida Is Nothing Then
@@ -89,6 +91,7 @@ Public Class ClsVentas
Else Else
SqlConexion = TransaccionCompartida.Connection SqlConexion = TransaccionCompartida.Connection
SqlTransacc = TransaccionCompartida SqlTransacc = TransaccionCompartida
EsTransaccionCompartida = True
End If End If
SqlAdapter = New SqlDataAdapter("", SqlConexion) SqlAdapter = New SqlDataAdapter("", SqlConexion)
ConexionAdd() ConexionAdd()
@@ -107,7 +110,7 @@ Public Class ClsVentas
#Region "Conexiones" #Region "Conexiones"
Private Sub ConexionAdd() Private Sub ConexionAdd()
If ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then If Not EsTransaccionCompartida AndAlso ConfigurationManager.AppSettings("RegistraConexion") IsNot Nothing AndAlso ConfigurationManager.AppSettings("RegistraConexion").ToString() = "1" Then
Try Try
DataAdapter("PA_Sis_RegistrarConexion") DataAdapter("PA_Sis_RegistrarConexion")
With SqlAdapter.SelectCommand.Parameters With SqlAdapter.SelectCommand.Parameters
@@ -740,11 +743,13 @@ Public Class ClsVentas
.Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa
.Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC .Add("@CvePAC", SqlDbType.SmallInt).Value = CvePAC
.Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion .Add("@CveEstatusRefacturacion", SqlDbType.TinyInt).Value = CveEstatusRefacturacion
.Add("@Cancelada", SqlDbType.SmallInt).Direction = ParameterDirection.Output
End With End With
Try Try
SqlAdapter.Fill(Data) SqlAdapter.Fill(Data)
Retorno = True Retorno = If(SqlAdapter.SelectCommand.Parameters("@Cancelada").Value.ToString.ToEntero = 1, True, False)
Catch ex As Exception Catch ex As Exception
OnError("Ocurrió un error al Guardar el estatus de cancelacion Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) OnError("Ocurrió un error al Guardar el estatus de cancelacion Factura.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo)
End Try End Try

View File

@@ -247,6 +247,7 @@ Namespace ADSSession
Dim resultado As String = "" Dim resultado As String = ""
Try Try
Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest) Dim request As Net.HttpWebRequest = CType(Net.HttpWebRequest.Create(URL), Net.HttpWebRequest)
request.Timeout = maxTimeMilliseconds request.Timeout = maxTimeMilliseconds
request.Method = "POST" request.Method = "POST"
@@ -263,10 +264,15 @@ Namespace ADSSession
End Using End Using
End Using End Using
Dim response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse) Using response As Net.WebResponse = CType(request.GetResponse(), Net.WebResponse)
Dim sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream()) Using sr As IO.StreamReader = New IO.StreamReader(response.GetResponseStream())
resultado = sr.ReadToEnd()
sr.Close() resultado = sr.ReadToEnd()
sr.Close()
End Using
End Using
request = Nothing
Catch ex As Exception Catch ex As Exception
'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}") 'Extenciones.ApplicationParameter.GuardaLogEx(ex, $"SOAPAction : {SOAPAction} XML : {xml}")
End Try End Try