Jobs: Remove obsolete history function

This commit is contained in:
Jonathan Jenne 2023-09-01 13:56:12 +02:00
parent 9cab65f941
commit 2b80e8fa97

View File

@ -1,4 +1,5 @@
Imports System.Data.SqlClient
Imports System.ServiceModel.Channels
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports Microsoft.VisualBasic.FileIO
@ -15,42 +16,30 @@ Namespace ZUGFeRD
_mssql = MSSQL
End Sub
Public Function Create_HistoryEntry(MessageId As String, MD5Checksum As String, Message As String, Transaction As SqlTransaction) As Boolean
Public Function Update_HistoryEntry(pMessageId As String, pMD5Checksum As String, pMessage As String) As Boolean
Try
_logger.Info("Creating History Entry for MessageId [{0}] with comment [{1}]", MessageId, Message)
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, 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
Return True
Catch ex As Exception
_logger.Warn("History Entry count not be created for message id [{0}] and md5 [{1}]", MessageId, MD5Checksum)
_logger.Error(ex)
Return False
End Try
End Function
Public Function Update_HistoryEntry(MessageId As String, MD5Checksum As String, Message As String, Transaction As SqlTransaction) As Boolean
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}]", pMessageId, pMessage)
' Only look for history entry by MessageId since the MD5 Hash might not be generated yet
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
Dim oSQL = $"UPDATE TBEMLP_HISTORY SET COMMENT = '{Message}' WHERE EMAIL_MSGID = '{MessageId}'"
Dim oSQL = $"UPDATE TBEMLP_HISTORY SET
COMMENT = '{pMessage}',
MD5HASH = '{pMD5Checksum}'
WHERE EMAIL_MSGID = '{pMessageId}'"
If pMessage.Contains("REJECTED") Then
oSQL = $"UPDATE TBEMLP_HISTORY SET
COMMENT = '{pMessage}',
MD5HASH = '{pMD5Checksum}',
STATUS = 'REJECTED',
CUST_REJECTED = 1,
CUST_REJECTED_WHEN = GETDATE()
WHERE EMAIL_MSGID = '{pMessageId}'"
End If
_mssql.ExecuteNonQueryWithConnectionObject(oSQL, oConnection)
End Using
@ -58,7 +47,7 @@ Namespace ZUGFeRD
Return True
Catch ex As Exception
_logger.Warn("History Entry count not be updated for message id [{0}] and md5 [{1}]", MessageId, MD5Checksum)
_logger.Warn("History Entry count not be updated for message id [{0}] and md5 [{1}]", pMessageId, pMD5Checksum)
_logger.Error(ex)
Return False