This commit is contained in:
Jonathan Jenne 2018-12-20 18:11:55 +01:00
commit 941b4ad5c4
5 changed files with 25 additions and 20 deletions

View File

@ -64,13 +64,13 @@ Public Class MyComService
_Logger.Warn("Firebird-DB could not be intitialized!")
Exit Sub
End If
Dim oSQL = "SELECT * FROM TBEDM_EMAIL_ACCOUNT WHERE GUID IN (SELECT DISTINCT EMAIL_ACCOUNT_ID FROM TBEDM_EMAIL_QUEUE WHERE EMAIL_SENT IS NULL and EMAIL_TO is not null)"
Dim oSQL = "SELECT * FROM TBEDM_EMAIL_ACCOUNT WHERE ACTIVE = True"
Dim oDT_EMAIL_ACCOUNT As DataTable = _firebird.GetDatatable(oSQL)
If IsNothing(oDT_EMAIL_ACCOUNT) Then
_Logger.Warn("DT_EMAIL_ACCOUNT is nothing!")
Exit Sub
End If
oSQL = "SELECT * FROM TBEDM_EMAIL_QUEUE WHERE EMAIL_SENT IS NULL and EMAIL_TO is not null"
oSQL = "SELECT * FROM TBEDM_EMAIL_QUEUE WHERE EMAIL_SENT IS NULL and EMAIL_TO <> ''"
Dim oDT_EMAIL_QUEUE As DataTable = _firebird.GetDatatable(oSQL)
If Not IsNothing(oDT_EMAIL_QUEUE) And oDT_EMAIL_ACCOUNT.Rows.Count >= 1 Then
Dim oEmailTo, oSubject, oBody As String
@ -119,7 +119,7 @@ Public Class MyComService
oBody = oBody.Replace("[%PMOLINK_US]", "<a href=""" & link & """>here</a>")
End If
If _Email.NewEmail(oEmailTo, oSubject, oBody, oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType) = True Then
If _Email.NewEmail(oEmailTo, oSubject, oBody, oMailFrom, oMailSMTP, oMailport, oMailUser, oMailPW, oAuthType, "DDEDMI_ComService") = True Then
Dim upd = "UPDATE TBEDM_EMAIL_QUEUE SET EMAIL_SENT = CURRENT_TIMESTAMP WHERE GUID = " & oGUID
_firebird.ExecuteNonQuery(upd)
End If
@ -132,9 +132,6 @@ Public Class MyComService
End If
End If
Catch ex As Exception
_Logger.Error(ex)
End Try

View File

@ -163,7 +163,7 @@ Public Class frmEmailAccount
Dim PWPlain = wrapper.DecryptData(txtEMAIL_PW.Text)
If _Email.NewEmail(txtTestmail.Text, "Testmail DD Windream-ResultHandler", "This is the body (text will be replaced within profile)", txtEMAIL_FROM.Text, txtSERVER_OUT.Text, txtPORT_OUT.Text, txtEMAIL_USER.Text, PWPlain, cmbAUTH_TYPE.Text) = True Then
If _Email.NewEmail(txtTestmail.Text, "Testmail DD Windream-ResultHandler", "This is the body (text will be replaced within profile)", txtEMAIL_FROM.Text, txtSERVER_OUT.Text, txtPORT_OUT.Text, txtEMAIL_USER.Text, PWPlain, cmbAUTH_TYPE.Text, "EDMI GUI") = True Then
MsgBox("Email was send successfully.", MsgBoxStyle.Information)
Else
MsgBox("Could not send the testmail. Please check the log.", MsgBoxStyle.Exclamation)

View File

@ -13,7 +13,7 @@ Public Class Email
End Sub
Public Function NewEmail(mailto As String, mailSubject As String, mailBody As String,
mailfrom As String, mailsmtp As String, mailport As Integer, mailUser As String, mailPW As String,
AUTH_TYPE As String, Optional attment As String = "")
AUTH_TYPE As String, SENDER_INSTANCE As String, Optional attment As String = "")
Try
_logger.Debug($"in NewEmail..")
Dim oEmpfaenger As String()
@ -35,8 +35,12 @@ Public Class Email
_logger.Debug($"Message created..")
Dim oTextBodyPart As New BodyPart()
oTextBodyPart.ContentType = New ContentType("text", "html", "utf-8")
oTextBodyPart.ContentTransferEncoding = ContentTransferEncoding.QuotedPrintable
oTextBodyPart.Body = mailBody
Dim formattedBody = "<font face=""Tahoma"">" & mailBody & "<br><br>>> Service: " & SENDER_INSTANCE & "<br>" &
">> DateTime: " & My.Computer.Clock.LocalTime.ToShortDateString & " " &
My.Computer.Clock.LocalTime.ToLongTimeString & "</font>"
oTextBodyPart.Body = formattedBody
oMessage.BodyParts.Add(oTextBodyPart)
If attment <> String.Empty Then
If System.IO.File.Exists(attment) Then
@ -68,11 +72,11 @@ Public Class Email
oError = True
' Continue For
End Try
_logger.Info("Connected to Client!")
_logger.Debug("Connected to Client!")
If AUTH_TYPE = "SSL" Then
oEmailCient.EnableSsl = True
'client.ValidateRemoteCertificate = True
_logger.Info("Authentification via SSL.")
_logger.Debug("Authentification via SSL.")
ElseIf AUTH_TYPE = "TLS" Then
' client.ValidateRemoteCertificate = False
oEmailCient.StartTls()
@ -83,7 +87,6 @@ Public Class Email
_logger.Info("Authentification NONE. SSL disabled")
End If
Try
oEmailCient.Connect()
Catch ex As Exception
_logger.Warn("clsEmail.Client.Connect: " & ex.Message)
@ -97,7 +100,7 @@ Public Class Email
oEmailCient.Login(mailUser, mailPW)
End If
_logger.Info("Logged in!")
_logger.Debug("Logged in!")
Catch ex As Exception
Try
If mailsmtp.Contains("office365.com") Then

View File

@ -7,7 +7,7 @@ Imports DigitalData.Modules.Logging
'''
''' VERSION: 0.0.0.4
'''
''' DATE: 05.12.2018
''' DATE: 18.12.2018
'''
''' DESCRIPTION:
'''
@ -46,8 +46,8 @@ Imports DigitalData.Modules.Logging
''' REMARKS: If the connection fails due to "wrong username or password", the cause might be that the server harddrive is full..
''' </summary>
Public Class Firebird
Private _logger As Logger
Private _logConfig As LogConfig
Private _Logger As Logger
Private _MyLogger As LogConfig
Private _connectionServer As String
Private _connectionDatabase As String
Private _connectionUsername As String
@ -85,8 +85,12 @@ Public Class Firebird
''' <param name="Password"></param>
''' <exception cref="Exceptions.DatabaseException"></exception>
Public Sub New(LogConfig As LogConfig, Datasource As String, Database As String, User As String, Password As String)
_logger = LogConfig.GetLogger()
_logConfig = LogConfig
_MyLogger = LogConfig
_Logger = _MyLogger.GetLogger()
Dim oConnectionString = GetConnectionString(Datasource, Database, User, Password)
@ -199,7 +203,8 @@ Public Class Firebird
oCommand.ExecuteNonQuery()
Catch ex As Exception
_logger.Error(ex, $"Error in ExecuteNonQuery while executing command: '{SqlCommand}'")
_Logger.Error(ex, $"Error in ExecuteNonQuery while executing command: '{SqlCommand}'")
_Logger.Warn($"Unexpected error in ExecuteNonQueryWithConnection: '{SqlCommand}'")
Throw ex
Finally
MaybeCommitTransaction(oTransaction, TransactionMode)

View File

@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("0.0.0.3")>
<Assembly: AssemblyVersion("1.0.0.4")>
<Assembly: AssemblyFileVersion("1.0.0.0")>