Modules.Jobs: MIME-Typen (pdf, xlsx, odt) - Fehlerhandling ergänzt, wenn Dateien nicht erstellt werden können.
This commit is contained in:
parent
04a408ab97
commit
717909d7e8
@ -28,6 +28,10 @@ Public Class ImportZUGFeRDFiles
|
|||||||
|
|
||||||
Private Const DIRECTORY_DONT_MOVE = "DIRECTORY_DONT_MOVE"
|
Private Const DIRECTORY_DONT_MOVE = "DIRECTORY_DONT_MOVE"
|
||||||
|
|
||||||
|
Private Const MIME_TYPE_PDF = "application/pdf"
|
||||||
|
Private Const MIME_TYPE_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||||
|
Private Const MIME_TYPE_ODT = "application/vnd.oasis.opendocument.spreadsheet"
|
||||||
|
|
||||||
' List of allowed extensions for PDF/A Attachments
|
' List of allowed extensions for PDF/A Attachments
|
||||||
' This list should not contain xml so the zugferd xml file will be filtered out
|
' This list should not contain xml so the zugferd xml file will be filtered out
|
||||||
Private ReadOnly AllowedExtensions As New List(Of String) From {"docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt"}
|
Private ReadOnly AllowedExtensions As New List(Of String) From {"docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt"}
|
||||||
@ -41,14 +45,16 @@ Public Class ImportZUGFeRDFiles
|
|||||||
' Allowed Values are:
|
' Allowed Values are:
|
||||||
'- application/pdf
|
'- application/pdf
|
||||||
'- application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx)
|
'- application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx)
|
||||||
'- application/vnd.oasis.opendocument.spreadsheet
|
'- application/vnd.oasis.opendocument.spreadsheet (odt)
|
||||||
'- image/jpeg
|
'- image/jpeg
|
||||||
'- image/png
|
'- image/png
|
||||||
'- image/tiff (UBL)
|
'- image/tiff (UBL)
|
||||||
'- text/csv
|
'- text/csv
|
||||||
'- text/xml (UBL)
|
'- text/xml (UBL)
|
||||||
Private ReadOnly AllowedMimeTypesInEmbeddedFiles As List(Of String) = New List(Of String) From {
|
Private ReadOnly AllowedMimeTypesInEmbeddedFiles As List(Of String) = New List(Of String) From {
|
||||||
"application/pdf", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
MIME_TYPE_PDF,
|
||||||
|
MIME_TYPE_XLSX,
|
||||||
|
MIME_TYPE_ODT
|
||||||
}
|
}
|
||||||
|
|
||||||
Private ReadOnly _logger As Logger
|
Private ReadOnly _logger As Logger
|
||||||
@ -806,12 +812,16 @@ Public Class ImportZUGFeRDFiles
|
|||||||
pProcessFileResult.EmailAttachmentFiles.Add(New FileInfo(embeddedFilePath))
|
pProcessFileResult.EmailAttachmentFiles.Add(New FileInfo(embeddedFilePath))
|
||||||
Else
|
Else
|
||||||
_logger.Error("Could not save File to Disk!")
|
_logger.Error("Could not save File to Disk!")
|
||||||
Return False
|
Dim oReasonString = "Could not save file " + newAttachmentFilename + " to disk."
|
||||||
|
AddRejectedState(pMessageId, oReasonString, "EMBEDDED FILE CONSISTENCY NOT OK", "Info GUI", pConnections.SQLServerTransaction)
|
||||||
|
Continue For
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If TestFileOnDisk(embeddedFilePath, oMimeCodeString) = False Then
|
If TestFileOnDisk(embeddedFilePath, oMimeCodeString) = False Then
|
||||||
_logger.Error("Could not save File to Disk!")
|
_logger.Error("Could not save File to Disk!")
|
||||||
Return False
|
Dim oReasonString = "Validation of file " + newAttachmentFilename + " on disk was NOT succesfully."
|
||||||
|
AddRejectedState(pMessageId, oReasonString, "EMBEDDED FILE CONSISTENCY NOT OK", "Info GUI", pConnections.SQLServerTransaction)
|
||||||
|
Continue For
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If InsertAttachmentHistoryEntry(pMessageId, oOrgFilename, embeddedFilePath) = False Then
|
If InsertAttachmentHistoryEntry(pMessageId, oOrgFilename, embeddedFilePath) = False Then
|
||||||
@ -832,7 +842,7 @@ Public Class ImportZUGFeRDFiles
|
|||||||
|
|
||||||
Private Function TestFileOnDisk(pEmbeddedFilePath As String, pMimeCodeString As String) As Boolean
|
Private Function TestFileOnDisk(pEmbeddedFilePath As String, pMimeCodeString As String) As Boolean
|
||||||
Try
|
Try
|
||||||
If pMimeCodeString = "application/pdf" Then
|
If pMimeCodeString = MIME_TYPE_PDF Then
|
||||||
Dim oGdPicturePDF As New GdPicturePDF
|
Dim oGdPicturePDF As New GdPicturePDF
|
||||||
Dim oStatus As GdPictureStatus = oGdPicturePDF.LoadFromFile(pEmbeddedFilePath, True)
|
Dim oStatus As GdPictureStatus = oGdPicturePDF.LoadFromFile(pEmbeddedFilePath, True)
|
||||||
If oStatus <> GdPictureStatus.OK Then
|
If oStatus <> GdPictureStatus.OK Then
|
||||||
@ -864,11 +874,11 @@ Public Class ImportZUGFeRDFiles
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Select Case pMimeTypeValue.ToLower()
|
Select Case pMimeTypeValue.ToLower()
|
||||||
Case "application/pdf"
|
Case MIME_TYPE_PDF
|
||||||
Return "pdf"
|
Return "pdf"
|
||||||
Case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
Case MIME_TYPE_XLSX
|
||||||
Return "xlsx"
|
Return "xlsx"
|
||||||
Case "application/vnd.oasis.opendocument.spreadsheet"
|
Case MIME_TYPE_ODT
|
||||||
Return "odt"
|
Return "odt"
|
||||||
Case "image/jpeg"
|
Case "image/jpeg"
|
||||||
Return "jpg"
|
Return "jpg"
|
||||||
@ -971,18 +981,20 @@ Public Class ImportZUGFeRDFiles
|
|||||||
|
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Speichere base64 als Datei auf der Platte ab
|
''' Speichere base64 als Datei auf der Platte ab.
|
||||||
''' </summary>
|
''' </summary>
|
||||||
Private Function SaveBase64ToDisk(pExportFilePath As String, pBase64String As String) As Boolean
|
Private Function SaveBase64ToDisk(pExportFilePath As String, pBase64String As String) As Boolean
|
||||||
|
|
||||||
Try
|
Try
|
||||||
Dim base64BinaryDataString As String = pBase64String ' Hier Base64-String einfügen
|
|
||||||
Dim binaryDataString As Byte() = Convert.FromBase64String(base64BinaryDataString)
|
|
||||||
Dim oFilename As String = pExportFilePath
|
Dim oFilename As String = pExportFilePath
|
||||||
' Using verwenden, um blockieren des PDF zu verhindern
|
Dim base64BinaryDataString As String = pBase64String
|
||||||
Using Stream As FileStream = New FileStream(oFilename, FileMode.Create)
|
Dim binaryDataString As Byte() = Convert.FromBase64String(base64BinaryDataString)
|
||||||
Stream.Write(binaryDataString, 0, binaryDataString.Length)
|
|
||||||
Stream.Close()
|
' Using verwenden, um blockieren der Datei zu verhindern
|
||||||
|
Using fs = New FileStream(oFilename, FileMode.Create, FileAccess.ReadWrite)
|
||||||
|
fs.Write(binaryDataString, 0, binaryDataString.Length)
|
||||||
|
fs.Flush()
|
||||||
|
fs.Close()
|
||||||
End Using
|
End Using
|
||||||
|
|
||||||
Return True
|
Return True
|
||||||
@ -1174,6 +1186,15 @@ Public Class ImportZUGFeRDFiles
|
|||||||
_logger.Warn("Step [{0}] with SQL [{1}] was not successful.", oStep, oDelSQL)
|
_logger.Warn("Step [{0}] with SQL [{1}] was not successful.", oStep, oDelSQL)
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
|
Try
|
||||||
|
oDelSQL = $"DELETE FROM TBEDMI_ITEM_FILES where REFERENCE_GUID = '{pMessageId}'"
|
||||||
|
oStep = "TBEDMI_ITEM_FILES Delete MessageID Items"
|
||||||
|
Dim retValue As Boolean = _mssql.ExecuteNonQueryWithConnectionObject(oDelSQL, pConnections.SQLServerConnection, MSSQLServer.TransactionMode.ExternalTransaction, pConnections.SQLServerTransaction)
|
||||||
|
Return retValue
|
||||||
|
Catch ex As Exception
|
||||||
|
_logger.Warn("Step [{0}] with SQL [{1}] was not successful.", oStep, oDelSQL)
|
||||||
|
End Try
|
||||||
|
|
||||||
Return False
|
Return False
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@ -1197,6 +1218,10 @@ Public Class ImportZUGFeRDFiles
|
|||||||
Return True
|
Return True
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
''' <summary>
|
||||||
|
''' Fügt neue Datensätze in Tabelle TBEMLP_HISTORY_STATE ein,
|
||||||
|
''' per Prozedur DD_ECM.[dbo].[PRCUST_ADD_HISTORY_STATE]
|
||||||
|
''' </summary>
|
||||||
Private Sub AddRejectedState(pMessageID As String, pTitle As String, pTitle1 As String, pComment As String, pTransaction As SqlTransaction)
|
Private Sub AddRejectedState(pMessageID As String, pTitle As String, pTitle1 As String, pComment As String, pTransaction As SqlTransaction)
|
||||||
Try
|
Try
|
||||||
'PRCUST_ADD_HISTORY_STATE: @MessageID VARCHAR(250), @TITLE1 VARCHAR(250), @TITLE2 VARCHAR(250)
|
'PRCUST_ADD_HISTORY_STATE: @MessageID VARCHAR(250), @TITLE1 VARCHAR(250), @TITLE2 VARCHAR(250)
|
||||||
@ -1206,4 +1231,5 @@ Public Class ImportZUGFeRDFiles
|
|||||||
_logger.Error(ex)
|
_logger.Error(ex)
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user