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
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

View File

@@ -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,21 +752,21 @@ 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)
_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
_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
Catch ex As Exception
_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
_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!")