Fix references to Firebird tables

This commit is contained in:
Jonathan Jenne
2023-07-27 15:46:30 +02:00
parent d73fa2a1c5
commit 28538bcf41
2 changed files with 17 additions and 21 deletions

View File

@@ -141,7 +141,7 @@ Public Class EmailFunctions
End Sub End Sub
Public Function GetEmailDataForMessageId(MessageId As String) As EmailData 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 Try
Dim oDatatable = _mssql.GetDatatable(oSQL) Dim oDatatable = _mssql.GetDatatable(oSQL)
Dim oRow As DataRow Dim oRow As DataRow
@@ -159,15 +159,11 @@ Public Class EmailFunctions
Dim oFromDefault = String.Format("No Sender found for ({0})", MessageId) Dim oFromDefault = String.Format("No Sender found for ({0})", MessageId)
Dim oFrom = oRow.ItemEx("EMAIL_FROM", oFromDefault) 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 oSubjectDefault = String.Format("No Subject found for ({0})", MessageId)
Dim oSubject = oRow.ItemEx("EMAIL_SUBJECT", oSubjectDefault) Dim oSubject = oRow.ItemEx("EMAIL_SUBJECT", oSubjectDefault)
Return New EmailData() With { Return New EmailData() With {
.From = oFrom, .From = oFrom,
.Attachment = oAttachment,
.Subject = oSubject .Subject = oSubject
} }
Catch ex As Exception Catch ex As Exception

View File

@@ -309,11 +309,11 @@ Public Class ImportZUGFeRDFiles
End If End If
DeleteExistingPropertyValues(oMessageId, oArgs, oConnections) DeleteExistingPropertyValues(oMessageId, oConnections)
Dim oFirstProperty = oCheckResult.ValidProperties.FirstOrDefault() Dim oFirstProperty = oCheckResult.ValidProperties.FirstOrDefault()
If oFirstProperty IsNot Nothing Then If oFirstProperty IsNot Nothing Then
InsertPropertyValue(oMessageId, oArgs, oConnections, New PropertyValues.ValidProperty() With { InsertPropertyValue(oMessageId, oConnections, New PropertyValues.ValidProperty() With {
.MessageId = oMessageId, .MessageId = oMessageId,
.Description = "ZUGFeRDSpezifikation", .Description = "ZUGFeRDSpezifikation",
.GroupCounter = 0, .GroupCounter = 0,
@@ -325,7 +325,7 @@ Public Class ImportZUGFeRDFiles
End If End If
For Each oProperty In oCheckResult.ValidProperties For Each oProperty In oCheckResult.ValidProperties
InsertPropertyValue(oMessageId, oArgs, oConnections, oProperty) InsertPropertyValue(oMessageId, oConnections, oProperty)
Next Next
Next Next
@@ -580,7 +580,7 @@ Public Class ImportZUGFeRDFiles
End Try End Try
End Sub 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 oDelSQL = $"DELETE FROM TBEDMI_ITEM_VALUE where REFERENCE_GUID = '{pMessageId}'"
Dim oStep As String Dim oStep As String
@@ -592,7 +592,7 @@ Public Class ImportZUGFeRDFiles
End Try End Try
End Sub 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 Dim oGroupCounterValue = pProperty.GroupCounter
' If GroupCounter is -1, it means this is a default property that can only occur once. ' If GroupCounter is -1, it means this is a default property that can only occur once.
@@ -752,21 +752,21 @@ Public Class ImportZUGFeRDFiles
Private Function Create_HistoryEntry(MessageId As String, MD5Checksum As String, Message As String, Transaction As SqlTransaction) As Boolean Private Function Create_HistoryEntry(MessageId As String, MD5Checksum As String, Message As String, Transaction As SqlTransaction) As Boolean
Try Try
_logger.Info("Creating History Entry for MessageId [{0}] with comment [{1}]", MessageId, Message) _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() Using oConnection = _mssql.GetConnection()
' 09.07.2021: This can't be in the transaction since the history ' 09.07.2021: This can't be in the transaction since the history
' Entry needs to be accessed by MoveAndRenameEmailToRejected shortly after ' Entry needs to be accessed by MoveAndRenameEmailToRejected shortly after
_mssql.ExecuteNonQueryWithConnectionObject(oSQL, Transaction.Connection, MSSQLServer.TransactionMode.NoTransaction) _mssql.ExecuteNonQueryWithConnectionObject(oSQL, oConnection)
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
_logger.Debug("History Entry created!")
End Using End Using
_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.ExecuteNonQuery(oSQL)
End If
Return True Return True
Catch ex As Exception Catch ex As Exception
_logger.Warn("History Entry count not be created for message id [{0}] and md5 [{1}]", MessageId, MD5Checksum) _logger.Warn("History Entry count not be created for message id [{0}] and md5 [{1}]", MessageId, MD5Checksum)
@@ -780,12 +780,12 @@ Public Class ImportZUGFeRDFiles
Try Try
_logger.Info("Updating History Entry for MessageId [{0}] with comment [{1}]", MessageId, Message) _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 ' 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() Using oConnection = _mssql.GetConnection()
' 09.07.2021: This can't be in the transaction since the history ' 09.07.2021: This can't be in the transaction since the history
' Entry needs to be accessed by MoveAndRenameEmailToRejected shortly after ' 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 End Using
_logger.Debug("History Entry created!") _logger.Debug("History Entry created!")