ZUGFeRD: Exit early when there are no files to process

This commit is contained in:
Jonathan Jenne 2019-03-13 12:49:17 +01:00
parent edc6d38def
commit e4ba39f19c

View File

@ -131,7 +131,6 @@ Public Class ImportZUGFeRDFiles
End Function End Function
Private Function GroupFiles(Files As List(Of FileInfo)) As Dictionary(Of String, List(Of FileInfo)) Private Function GroupFiles(Files As List(Of FileInfo)) As Dictionary(Of String, List(Of FileInfo))
Dim oRegex = New Regex("([\w\d]+)_.+")
Dim oGrouped As New Dictionary(Of String, List(Of FileInfo)) Dim oGrouped As New Dictionary(Of String, List(Of FileInfo))
If Files.Count = 0 Then If Files.Count = 0 Then
@ -177,7 +176,12 @@ Public Class ImportZUGFeRDFiles
Dim oFileCount = oFiles.Count Dim oFileCount = oFiles.Count
Dim oCurrentFileCount = 0 Dim oCurrentFileCount = 0
_logger.Info("Found {0} files", oFileCount) If oFileCount = 0 Then
_logger.Info("No files to process.")
Continue For
Else
_logger.Info("Found {0} files", oFileCount)
End If
' Group files by messageId ' Group files by messageId
Dim oGrouped As Dictionary(Of String, List(Of FileInfo)) = GroupFiles(oFiles) Dim oGrouped As Dictionary(Of String, List(Of FileInfo)) = GroupFiles(oFiles)
@ -209,6 +213,7 @@ Public Class ImportZUGFeRDFiles
oMissingProperties = New List(Of String) oMissingProperties = New List(Of String)
oCurrentFileCount += 1 oCurrentFileCount += 1
' Only pdf files are allowed from here on
If Not oFile.Name.EndsWith(".pdf") Then If Not oFile.Name.EndsWith(".pdf") Then
_logger.Debug("Skipping non-pdf file {0}", oFile.Name) _logger.Debug("Skipping non-pdf file {0}", oFile.Name)
Continue For Continue For