Hilos en envio de correo,

This commit is contained in:
2020-06-06 13:20:37 -07:00
parent 561fab5f3e
commit e14db2ad9a

View File

@@ -209,24 +209,25 @@ Public Class ClsSisNotificaciones
#Region "C O R R E O" #Region "C O R R E O"
Private Sub EnviarCorreos(DTNotificacionesCorreo As DataTable) Private Sub EnviarCorreos(DTNotificacionesCorreo As DataTable)
For Each notificacion As DataRow In DTNotificacionesCorreo.Rows For Each notificacion As DataRow In DTNotificacionesCorreo.Rows
MandaMail(notificacion("CveNotificacionBitacora").ToString.ToEntero, notificacion("Encabezado").ToString, notificacion("Cuerpo").ToString, notificacion("Correo").ToString, "") Dim Hilo As New System.Threading.Thread(Sub() MandaMail(notificacion("CveNotificacionBitacora").ToString.ToEntero, notificacion("Encabezado").ToString, notificacion("Cuerpo").ToString, notificacion("Correo").ToString, ""))
Hilo.Start()
Next Next
End Sub End Sub
Private Sub MandaMail(CveNotificacionBitacora As Integer, Asunto As String, Cuerpo As String, Mail As String, MailCC As String) Private Sub MandaMail(CveNotificacionBitacora As Integer, Asunto As String, Cuerpo As String, Mail As String, MailCC As String)
Dim ObjMail As New ClsSisMail() Dim ObjMail As New ClsSisMail()
Dim ObjNotificacion As New ClsSisNotificaciones
Try Try
Dim ResultadoMail As Integer = 0 Dim ResultadoMail As Integer = 0
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail) Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Mail, Asunto, Cuerpo, MailCC, LSRutasMail) Then If ObjMail.SendMail(ClsPaginas.EmpresaNotificaciones, Mail, Asunto, Cuerpo, MailCC, LSRutasMail) Then
UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1) ObjNotificacion.UpdateNotificacionesBitacoraNotifico(CveNotificacionBitacora, 1)
End If End If
Catch ex As Exception Catch ex As Exception
OnError("Ocurrió error al mandar el Mail", ex) OnError("Ocurrió error al mandar el Mail", ex)
End Try End Try
ObjNotificacion.Dispose()
End Sub End Sub
#End Region #End Region
@@ -1328,10 +1329,6 @@ Public Class ClsSisNotificaciones
Next Next
End If End If
If DTNotificacionesCorreo IsNot Nothing AndAlso DTNotificacionesCorreo.Rows.Count > 0 Then
EnviarCorreos(DTNotificacionesCorreo)
End If
If DTNotificacionesApp IsNot Nothing AndAlso DTNotificacionesApp.Rows.Count > 0 Then If DTNotificacionesApp IsNot Nothing AndAlso DTNotificacionesApp.Rows.Count > 0 Then
Dim DtTokens As DataTable = Nothing Dim DtTokens As DataTable = Nothing
@@ -1389,6 +1386,10 @@ Public Class ClsSisNotificaciones
DtTokens.Dispose() DtTokens.Dispose()
End If End If
End If End If
End If
If DTNotificacionesCorreo IsNot Nothing AndAlso DTNotificacionesCorreo.Rows.Count > 0 Then
EnviarCorreos(DTNotificacionesCorreo)
End If End If
If Not DTNotificacionesApp Is Nothing Then DTNotificacionesApp.Dispose() If Not DTNotificacionesApp Is Nothing Then DTNotificacionesApp.Dispose()