From 41bba8b214b68a21795037d1805649790b6db5ee Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 2 Feb 2023 13:11:16 +0100 Subject: [PATCH 1/7] Filesystem: Add TestFileSizeIsLessThanMaxFileSize --- Filesystem/File.vb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Filesystem/File.vb b/Filesystem/File.vb index 3a20856d..a053c798 100644 --- a/Filesystem/File.vb +++ b/Filesystem/File.vb @@ -404,6 +404,34 @@ Public Class File Return oIsDirectory End Function + ''' + ''' Checks the size of the supplied file. + ''' + ''' + ''' + ''' + Public Function TestFileSizeIsLessThanMaxFileSize(pFilePath As String, pMaxFileSizeInMegabytes As Integer) + Dim oFileInfo As New FileInfo(pFilePath) + + _Logger.Info("Checking Filesize of {0}", oFileInfo.Name) + _Logger.Debug("Filesize threshold is {0} MB.", pMaxFileSizeInMegabytes) + + If pMaxFileSizeInMegabytes <= 0 Then + _Logger.Debug("Filesize is not configured. Skipping check.") + Return True + End If + + Dim oMaxSize = pMaxFileSizeInMegabytes * 1024 * 1024 + + If oMaxSize > 0 And oFileInfo.Length > oMaxSize Then + _Logger.Debug("Filesize is bigger than threshold.") + Return False + Else + _Logger.Debug("Filesize is smaller than threshold. All fine.") + Return True + End If + End Function + Public Function GetDateDirectory(pBaseDirectory As String, pDate As Date) As String Dim oDateDirectory = GetDateString(pDate) Dim oFinalDirectory As String = IO.Path.Combine(pBaseDirectory, oDateDirectory) From 1013dd3c301a6be3fbd09b0a7944eef4b2765b63 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 2 Feb 2023 13:11:41 +0100 Subject: [PATCH 2/7] Jobs: Use TestFileSizeIsLessThanMaxFileSize --- Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb index 00fd4714..e14b4ec9 100644 --- a/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb +++ b/Jobs/ZUGFeRD/ImportZUGFeRDFiles.vb @@ -222,7 +222,7 @@ Public Class ImportZUGFeRDFiles oEmailAttachmentFiles.Add(oFile) ' Checking filesize for attachment files - If Check_FileSize(oFile, oArgs.MaxAttachmentSizeInMegaBytes) = False Then + If _filesystem.TestFileSizeIsLessThanMaxFileSize(oFile.FullName, oArgs.MaxAttachmentSizeInMegaBytes) = False Then _logger.Warn("Filesize for File [{0}] exceeded limit of {1} MB", oFile.Name, oArgs.MaxAttachmentSizeInMegaBytes) Throw New FileSizeLimitReachedException(oFile.Name, oArgs.MaxAttachmentSizeInMegaBytes) End If @@ -233,7 +233,7 @@ Public Class ImportZUGFeRDFiles _logger.Info("Start processing file {0}", oFile.Name) ' Checking filesize for pdf files - If Check_FileSize(oFile, oArgs.MaxAttachmentSizeInMegaBytes) = False Then + If _filesystem.TestFileSizeIsLessThanMaxFileSize(oFile.FullName, oArgs.MaxAttachmentSizeInMegaBytes) = False Then _logger.Warn("Filesize for File [{0}] exceeded limit of {1} MB", oFile.Name, oArgs.MaxAttachmentSizeInMegaBytes) Throw New FileSizeLimitReachedException(oFile.Name, oArgs.MaxAttachmentSizeInMegaBytes) End If @@ -844,30 +844,4 @@ Public Class ImportZUGFeRDFiles Return oMD5CheckSum End Function - - ''' - ''' Checks the size of the supplied file. - ''' - ''' - ''' - ''' - Private Function Check_FileSize(pFileInfo As FileInfo, pMaxFileSizeInMegaBytes As Integer) As Boolean - _logger.Info("Checking Filesize of {0}", pFileInfo.Name) - _logger.Debug("Filesize threshold is {0} MB.", pMaxFileSizeInMegaBytes) - - If pMaxFileSizeInMegaBytes <= 0 Then - _logger.Debug("Filesize is not configured. Skipping check.") - Return True - End If - - Dim oMaxSize = pMaxFileSizeInMegaBytes * 1024 * 1024 - - If oMaxSize > 0 And pFileInfo.Length > oMaxSize Then - _logger.Debug("Filesize is bigger than threshold. Rejecting.") - Return False - Else - _logger.Debug("Filesize is smaller than threshold. All fine.") - Return True - End If - End Function End Class From 46ce5342a0cd182a79944e01794d5c346ca4632a Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 2 Feb 2023 13:12:41 +0100 Subject: [PATCH 3/7] Filesystem: Version 1.5.0 --- Filesystem/My Project/AssemblyInfo.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Filesystem/My Project/AssemblyInfo.vb b/Filesystem/My Project/AssemblyInfo.vb index dffefb47..4136ea50 100644 --- a/Filesystem/My Project/AssemblyInfo.vb +++ b/Filesystem/My Project/AssemblyInfo.vb @@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices - + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + From 39a0c8b8ec969c3522ff9c3205c569bb6b7f281a Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 2 Feb 2023 13:13:12 +0100 Subject: [PATCH 4/7] Jobs: Version 1.13.0.0 --- Jobs/My Project/AssemblyInfo.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jobs/My Project/AssemblyInfo.vb b/Jobs/My Project/AssemblyInfo.vb index 393c6a9a..1f675ad7 100644 --- a/Jobs/My Project/AssemblyInfo.vb +++ b/Jobs/My Project/AssemblyInfo.vb @@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices - + @@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices ' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern ' übernehmen, indem Sie "*" eingeben: - - + + From ad5443adae4d30c515ae342190ae1fee4829de1e Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 2 Feb 2023 13:30:37 +0100 Subject: [PATCH 5/7] Filesystem: fix typo --- Filesystem/File.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Filesystem/File.vb b/Filesystem/File.vb index a053c798..c8823aca 100644 --- a/Filesystem/File.vb +++ b/Filesystem/File.vb @@ -410,7 +410,7 @@ Public Class File ''' ''' ''' - Public Function TestFileSizeIsLessThanMaxFileSize(pFilePath As String, pMaxFileSizeInMegabytes As Integer) + Public Function TestFileSizeIsLessThanMaxFileSize(pFilePath As String, pMaxFileSizeInMegabytes As Integer) As Boolean Dim oFileInfo As New FileInfo(pFilePath) _Logger.Info("Checking Filesize of {0}", oFileInfo.Name) From fd0876a1cbf5df2eab8477c469d6356506b1abec Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 22 Feb 2023 11:07:34 +0100 Subject: [PATCH 6/7] Language: Add FieldOrDefault method --- Language/DataTableEx.vb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Language/DataTableEx.vb b/Language/DataTableEx.vb index 936d29c0..70f3ac78 100644 --- a/Language/DataTableEx.vb +++ b/Language/DataTableEx.vb @@ -19,6 +19,16 @@ Public Module DataTableEx End Try End Function + + Public Function FieldOrDefault(Of T)(pRow As DataRow, pFieldName As String, Optional pDefaultValue As T = Nothing) As T + Return ItemEx(pRow, pFieldName, pDefaultValue) + End Function + + + Public Function FieldOrDefault(Of T)(pRow As DataRow, pFieldIndex As Integer, Optional pDefaultValue As T = Nothing) As T + Return ItemEx(pRow, pFieldIndex, pDefaultValue) + End Function + Public Function First(pTable As DataTable) As DataRow Try From f6acae9185dabeaf812eb8d5e2d631ae56bdac98 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 22 Feb 2023 11:07:43 +0100 Subject: [PATCH 7/7] Language: Version 1.7.1 --- Language/My Project/AssemblyInfo.vb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Language/My Project/AssemblyInfo.vb b/Language/My Project/AssemblyInfo.vb index 4788f939..374ae372 100644 --- a/Language/My Project/AssemblyInfo.vb +++ b/Language/My Project/AssemblyInfo.vb @@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices - - + + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + +