This commit is contained in:
SchreiberM 2024-01-05 08:23:19 +01:00
commit 07d26cf70c
8 changed files with 35 additions and 23 deletions

View File

@ -1,5 +1,4 @@
Imports System.IO Imports System.IO
Imports System.Windows.Forms
Imports DigitalData.Modules.Base Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging

View File

@ -1,4 +1,6 @@
Imports DigitalData.Modules.Logging Imports System.IO
Imports DigitalData.Modules.Interfaces.Exceptions
Imports DigitalData.Modules.Logging
Imports GdPicture14 Imports GdPicture14
Public Class PDFConverter Public Class PDFConverter
@ -58,5 +60,9 @@ Public Class PDFConverter
_Logger.Error(ex) _Logger.Error(ex)
Return False Return False
End Try End Try
End Function End Function
End Class End Class

View File

@ -9,7 +9,6 @@ Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Interfaces Imports DigitalData.Modules.Interfaces
Imports DigitalData.Modules.Jobs.GraphQL Imports DigitalData.Modules.Jobs.GraphQL
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports Newtonsoft.Json.Linq Imports Newtonsoft.Json.Linq

View File

@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")> <Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("Modules.Jobs")> <Assembly: AssemblyProduct("Modules.Jobs")>
<Assembly: AssemblyCopyright("Copyright © 2023")> <Assembly: AssemblyCopyright("Copyright © 2023")>
<Assembly: AssemblyTrademark("2.2.0.0")> <Assembly: AssemblyTrademark("2.3.0.1")>
<Assembly: ComVisible(False)> <Assembly: ComVisible(False)>
@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern ' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
<Assembly: AssemblyVersion("2.2.0.0")> <Assembly: AssemblyVersion("2.3.0.1")>
<Assembly: AssemblyFileVersion("2.2.0.0")> <Assembly: AssemblyFileVersion("2.3.0.1")>

View File

@ -141,17 +141,6 @@ Namespace ZUGFeRD
End If End If
End Function End Function
Public Function GetEmailPathWithSubjectAsName(RejectedEmailDirectory As String, UncleanedSubject As String) As String
Dim oCleanSubject = String.Join("", UncleanedSubject.Split(Path.GetInvalidPathChars()))
Dim oAttachmentDirectory = RejectedEmailDirectory
Dim oAttachmentFile = oCleanSubject & ".eml"
_logger.Debug("Email Filename is [{0}]", oAttachmentFile)
Dim oAttachmentPath = Path.Combine(oAttachmentDirectory, oAttachmentFile)
Return oAttachmentPath
End Function
Private Function RandomValue(lowerBound As Integer, upperBound As Integer) As Integer Private Function RandomValue(lowerBound As Integer, upperBound As Integer) As Integer
Dim oRandomValue = CInt(Math.Floor((upperBound - lowerBound + 1) * Rnd())) + lowerBound Dim oRandomValue = CInt(Math.Floor((upperBound - lowerBound + 1) * Rnd())) + lowerBound
Return oRandomValue Return oRandomValue

View File

@ -10,18 +10,20 @@ Namespace ZUGFeRD
Public Class FileFunctions Public Class FileFunctions
Private ReadOnly _logConfig As LogConfig Private ReadOnly _logConfig As LogConfig
Private ReadOnly _logger As Logger Private ReadOnly _logger As Logger
Private ReadOnly _mssql As MSSQLServer
Private ReadOnly _filesystem As FilesystemEx Private ReadOnly _filesystem As FilesystemEx
Private ReadOnly _email As ZUGFeRD.EmailFunctions Private ReadOnly _email As ZUGFeRD.EmailFunctions
Public Sub New(pLogConfig As LogConfig, pMSSQL As MSSQLServer) Public Sub New(pLogConfig As LogConfig, pMSSQL As MSSQLServer)
_logConfig = pLogConfig _logConfig = pLogConfig
_logger = _logConfig.GetLogger() _logger = _logConfig.GetLogger()
_mssql = pMSSQL
_email = New EmailFunctions(pLogConfig, pMSSQL) _email = New EmailFunctions(pLogConfig, pMSSQL)
_filesystem = New FilesystemEx(pLogConfig) _filesystem = New FilesystemEx(pLogConfig)
End Sub End Sub
Public Function CheckFileAge(oFiles As List(Of FileInfo), pMinFileAge As Integer)
Return oFiles.Where(Function(f) Now.Subtract(f.CreationTime).Minutes < pMinFileAge).Any()
End Function
Public Sub MoveFiles( Public Sub MoveFiles(
pArgs As WorkerArgs, pArgs As WorkerArgs,
pMessageId As String, pMessageId As String,
@ -143,9 +145,9 @@ Namespace ZUGFeRD
' If oEmailData is Nothing, TBEDM_EMAIL_PROFILER_HISTORY for MessageId was not found. ' If oEmailData is Nothing, TBEDM_EMAIL_PROFILER_HISTORY for MessageId was not found.
' This only should happen when testing and db-tables are deleted frequently ' This only should happen when testing and db-tables are deleted frequently
If oEmailData Is Nothing Then If oEmailData Is Nothing Then
oDestination = _email.GetEmailPathWithSubjectAsName(oRejectedDirectory, pMessageId) oDestination = GetEmailPathWithSubjectAsName(oRejectedDirectory, pMessageId)
Else Else
oDestination = _email.GetEmailPathWithSubjectAsName(oRejectedDirectory, StringEx.ConvertTextToSlug(oEmailData.Subject)) oDestination = GetEmailPathWithSubjectAsName(oRejectedDirectory, StringEx.ConvertTextToSlug(oEmailData.Subject))
End If End If
_logger.Debug("Destination for eml file is {0}", oDestination) _logger.Debug("Destination for eml file is {0}", oDestination)
@ -175,6 +177,17 @@ Namespace ZUGFeRD
Return oEmailData Return oEmailData
End Function End Function
Public Function GetEmailPathWithSubjectAsName(RejectedEmailDirectory As String, UncleanedSubject As String) As String
Dim oCleanSubject = String.Join("", UncleanedSubject.Split(Path.GetInvalidPathChars()))
Dim oAttachmentDirectory = RejectedEmailDirectory
Dim oAttachmentFile = oCleanSubject & ".eml"
_logger.Debug("Email Filename is [{0}]", oAttachmentFile)
Dim oAttachmentPath = Path.Combine(oAttachmentDirectory, oAttachmentFile)
Return oAttachmentPath
End Function
End Class End Class
End Namespace End Namespace

View File

@ -160,7 +160,12 @@ Public Class ImportZUGFeRDFiles
Dim oMessageId As String = oFileGroup.Key Dim oMessageId As String = oFileGroup.Key
Dim oMD5CheckSum As String = String.Empty Dim oMD5CheckSum As String = String.Empty
_logger.Info("Start processing file group {0}", oMessageId) _logger.Info("START processing file group {0}", oMessageId)
If _file.CheckFileAge(oFileGroupFiles, oArgs.MinFileAgeInMinutes) Then
_logger.Info("At least one file was created less than [{0}] minutes ago. Skipping file group.", oArgs.MinFileAgeInMinutes)
Continue For
End If
Dim oEmailDataBase = _email.GetEmailDataForMessageId(oMessageId) Dim oEmailDataBase = _email.GetEmailDataForMessageId(oMessageId)
@ -373,7 +378,7 @@ Public Class ImportZUGFeRDFiles
' Move all files of the current group ' Move all files of the current group
_file.MoveFiles(oArgs, oMessageId, oFileGroupFiles, oEmailAttachmentFiles, oEmbeddedAttachmentFiles, oMoveDirectory, oIsSuccess) _file.MoveFiles(oArgs, oMessageId, oFileGroupFiles, oEmailAttachmentFiles, oEmbeddedAttachmentFiles, oMoveDirectory, oIsSuccess)
End If End If
_logger.Info("Finished processing file group {0}", oMessageId) _logger.Info("END processing file group {0}", oMessageId)
Catch ex As Exception Catch ex As Exception
' Send Email to Digital Data ' Send Email to Digital Data
Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex) Dim oBody = _email.CreateBodyForUnhandledException(oMessageId, ex)

View File

@ -21,6 +21,7 @@ Public Class WorkerArgs
Public ExceptionEmailAddress As String = Nothing Public ExceptionEmailAddress As String = Nothing
Public IgnoreRejectionStatus As Boolean = False Public IgnoreRejectionStatus As Boolean = False
Public MaxAttachmentSizeInMegaBytes As Integer = -1 Public MaxAttachmentSizeInMegaBytes As Integer = -1
Public MinFileAgeInMinutes As Integer = 5
Public NamePortal As String = "NO PORTAL_NAME IN CONFIG" Public NamePortal As String = "NO PORTAL_NAME IN CONFIG"
Public AllowFacturX As Boolean = True Public AllowFacturX As Boolean = True