Modules.Jobs: Dateien löschen, falls Prüfung fehlschlägt

This commit is contained in:
2026-11-09 14:01:33 +01:00
parent a6ae874873
commit 462600d1b3

View File

@@ -868,6 +868,7 @@ Public Class ImportZUGFeRDFiles
_logger.Error("Could not save File to Disk!")
Dim oReasonString = "Could not save file " + newAttachmentFilename + " to disk."
AddRejectedState(pMessageId, oReasonString, "EMBEDDED FILE CONSISTENCY NOT OK", "Info GUI", pConnections.SQLServerTransaction)
nextAttachmentIndex += 1
Continue For
End If
@@ -875,6 +876,11 @@ Public Class ImportZUGFeRDFiles
_logger.Error("Could not save File to Disk!")
Dim oReasonString = "Validation of file " + newAttachmentFilename + " on disk was NOT succesfully."
AddRejectedState(pMessageId, oReasonString, "EMBEDDED FILE CONSISTENCY NOT OK", "Info GUI", pConnections.SQLServerTransaction)
' Datei ist Murks und muss gelöscht werden, wenn möglich
DeleteFileFromDisk(embeddedFilePath)
nextAttachmentIndex += 1
Continue For
End If
@@ -920,6 +926,20 @@ Public Class ImportZUGFeRDFiles
End Try
End Function
Private Function DeleteFileFromDisk(pEmbeddedFilePath As String) As Boolean
Try
Dim oFile As FileInfo = New FileInfo(pEmbeddedFilePath)
If oFile IsNot Nothing Then
oFile.Delete()
End If
Return True
Catch ex As Exception
_logger.Warn("Coul not delete file {0}.", pEmbeddedFilePath)
Return False
End Try
End Function
Private Function GetEmbeddedFileExtension(pMimeTypeValue As String) As String
If pMimeTypeValue.IsNullOrEmpty() Then