From 28538bcf4133c3bd6a21f558004dda205d561e17 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 27 Jul 2023 15:46:30 +0200 Subject: [PATCH] Fix references to Firebird tables --- Jobs/ZUGFeRD/EmailFunctions.vb | 6 +----- Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Jobs/ZUGFeRD/EmailFunctions.vb b/Jobs/ZUGFeRD/EmailFunctions.vb index 949d95a0..4473ea29 100644 --- a/Jobs/ZUGFeRD/EmailFunctions.vb +++ b/Jobs/ZUGFeRD/EmailFunctions.vb @@ -141,7 +141,7 @@ Public Class EmailFunctions End Sub Public Function GetEmailDataForMessageId(MessageId As String) As EmailData - Dim oSQL = $"SELECT EMAIL_FROM, EMAIL_SUBJECT, EMAIL_ATTMT1 FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{MessageId}'" + Dim oSQL = $"SELECT EMAIL_FROM, EMAIL_SUBJECT FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{MessageId}'" Try Dim oDatatable = _mssql.GetDatatable(oSQL) Dim oRow As DataRow @@ -159,15 +159,11 @@ Public Class EmailFunctions Dim oFromDefault = String.Format("No Sender found for ({0})", MessageId) Dim oFrom = oRow.ItemEx("EMAIL_FROM", oFromDefault) - Dim oAttachmentDefault = String.Format("No Attachment found for ({0})", MessageId) - Dim oAttachment = oRow.ItemEx("EMAIL_ATTMT1", oAttachmentDefault) - Dim oSubjectDefault = String.Format("No Subject found for ({0})", MessageId) Dim oSubject = oRow.ItemEx("EMAIL_SUBJECT", oSubjectDefault) Return New EmailData() With { .From = oFrom, - .Attachment = oAttachment, .Subject = oSubject } Catch ex As Exception diff --git a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb index 5bd4fa93..8e82e6c8 100644 --- a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -309,11 +309,11 @@ Public Class ImportZUGFeRDFiles End If - DeleteExistingPropertyValues(oMessageId, oArgs, oConnections) + DeleteExistingPropertyValues(oMessageId, oConnections) Dim oFirstProperty = oCheckResult.ValidProperties.FirstOrDefault() If oFirstProperty IsNot Nothing Then - InsertPropertyValue(oMessageId, oArgs, oConnections, New PropertyValues.ValidProperty() With { + InsertPropertyValue(oMessageId, oConnections, New PropertyValues.ValidProperty() With { .MessageId = oMessageId, .Description = "ZUGFeRDSpezifikation", .GroupCounter = 0, @@ -325,7 +325,7 @@ Public Class ImportZUGFeRDFiles End If For Each oProperty In oCheckResult.ValidProperties - InsertPropertyValue(oMessageId, oArgs, oConnections, oProperty) + InsertPropertyValue(oMessageId, oConnections, oProperty) Next Next @@ -580,7 +580,7 @@ Public Class ImportZUGFeRDFiles End Try End Sub - Private Sub DeleteExistingPropertyValues(pMessageId As String, pArgs As WorkerArgs, pConnections As DatabaseConnections) + Private Sub DeleteExistingPropertyValues(pMessageId As String, pConnections As DatabaseConnections) Dim oDelSQL = $"DELETE FROM TBEDMI_ITEM_VALUE where REFERENCE_GUID = '{pMessageId}'" Dim oStep As String @@ -592,7 +592,7 @@ Public Class ImportZUGFeRDFiles End Try End Sub - Private Sub InsertPropertyValue(pMessageId As String, pArgs As WorkerArgs, pConnections As DatabaseConnections, pProperty As PropertyValues.ValidProperty) + Private Sub InsertPropertyValue(pMessageId As String, pConnections As DatabaseConnections, pProperty As PropertyValues.ValidProperty) Dim oGroupCounterValue = pProperty.GroupCounter ' If GroupCounter is -1, it means this is a default property that can only occur once. @@ -752,20 +752,20 @@ Public Class ImportZUGFeRDFiles Private Function Create_HistoryEntry(MessageId As String, MD5Checksum As String, Message As String, Transaction As SqlTransaction) As Boolean Try _logger.Info("Creating History Entry for MessageId [{0}] with comment [{1}]", MessageId, Message) - Dim oSQL = $"INSERT INTO TBEDM_ZUGFERD_HISTORY_IN (COMMENT, MD5HASH, MESSAGE_ID) VALUES ('{Message}', '{MD5Checksum}', '{MessageId}')" + Dim oSQL = $"INSERT INTO TBEMLP_HISTORY (COMMENT, MD5HASH, EMAIL_MSGID) VALUES ('{Message}', '{MD5Checksum}', '{MessageId}')" Using oConnection = _mssql.GetConnection() ' 09.07.2021: This can't be in the transaction since the history ' Entry needs to be accessed by MoveAndRenameEmailToRejected shortly after - _mssql.ExecuteNonQueryWithConnectionObject(oSQL, Transaction.Connection, MSSQLServer.TransactionMode.NoTransaction) - End Using + _mssql.ExecuteNonQueryWithConnectionObject(oSQL, oConnection) - _logger.Debug("History Entry created!") + If Message.Contains("REJECTED") Then + oSQL = $"UPDATE TBEMLP_HISTORY SET STATUS = 'REJECTED', COMMENT = '{Message}', CUST_REJECTED = 1,CUST_REJECTED_WHEN = GETDATE() WHERE EMAIL_MSGID = '{MessageId}'" + _mssql.ExecuteNonQueryWithConnectionObject(oSQL, oConnection) + End If - If Message.Contains("REJECTED") Then - oSQL = $"UPDATE TBEMLP_HISTORY SET STATUS = 'REJECTED', COMMENT = '{Message}', CUST_REJECTED = 1,CUST_REJECTED_WHEN = GETDATE() WHERE EMAIL_MSGID = '{MessageId}'" - _mssql.ExecuteNonQuery(oSQL) - End If + _logger.Debug("History Entry created!") + End Using Return True Catch ex As Exception @@ -780,12 +780,12 @@ Public Class ImportZUGFeRDFiles Try _logger.Info("Updating History Entry for MessageId [{0}] with comment [{1}]", MessageId, Message) ' Only look for history entry by MessageId since the MD5 Hash might not be generated yet - Dim oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET COMMENT = '{Message}' WHERE MESSAGE_ID = '{MessageId}'" Using oConnection = _mssql.GetConnection() ' 09.07.2021: This can't be in the transaction since the history ' Entry needs to be accessed by MoveAndRenameEmailToRejected shortly after - _mssql.ExecuteNonQueryWithConnectionObject(oSQL, Transaction.Connection, MSSQLServer.TransactionMode.NoTransaction) + Dim oSQL = $"UPDATE TBEMLP_HISTORY SET COMMENT = '{Message}' WHERE EMAIL_MSGID = '{MessageId}'" + _mssql.ExecuteNonQueryWithConnectionObject(oSQL, oConnection) End Using _logger.Debug("History Entry created!")