From c9577c30ad4c59baea829c0229b3c7711038a76e Mon Sep 17 00:00:00 2001 From: Digital Data - Marlon Schreiber Date: Tue, 18 Dec 2018 23:47:18 +0100 Subject: [PATCH] Changes Wisag Pitch --- DD_CommunicationService/MyComService.vb | 9 +++------ GUI_EDMI/frmEmailAccount.vb | 2 +- Message/Email.vb | 15 +++++++++------ Modules.Database/Firebird.vb | 17 +++++++++++------ Modules.Database/My Project/AssemblyInfo.vb | 2 +- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/DD_CommunicationService/MyComService.vb b/DD_CommunicationService/MyComService.vb index 14e47018..515669c6 100644 --- a/DD_CommunicationService/MyComService.vb +++ b/DD_CommunicationService/MyComService.vb @@ -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]", "here") 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 diff --git a/GUI_EDMI/frmEmailAccount.vb b/GUI_EDMI/frmEmailAccount.vb index 9ab45ab9..b2d74d01 100644 --- a/GUI_EDMI/frmEmailAccount.vb +++ b/GUI_EDMI/frmEmailAccount.vb @@ -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) diff --git a/Message/Email.vb b/Message/Email.vb index ce81e2f4..327e1aef 100644 --- a/Message/Email.vb +++ b/Message/Email.vb @@ -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 = "" & mailBody & "

>> Service: " & SENDER_INSTANCE & "
" & + ">> DateTime: " & My.Computer.Clock.LocalTime.ToShortDateString & " " & + My.Computer.Clock.LocalTime.ToLongTimeString & "
" + 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 diff --git a/Modules.Database/Firebird.vb b/Modules.Database/Firebird.vb index 8891f2bd..5dbb834e 100644 --- a/Modules.Database/Firebird.vb +++ b/Modules.Database/Firebird.vb @@ -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.. ''' 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 ''' ''' 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) diff --git a/Modules.Database/My Project/AssemblyInfo.vb b/Modules.Database/My Project/AssemblyInfo.vb index 2c942633..1ad3a483 100644 --- a/Modules.Database/My Project/AssemblyInfo.vb +++ b/Modules.Database/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - +