9 Commits

Author SHA1 Message Date
Jonathan Jenne
757a8616dc Jobs: Version 1.7.0 2021-07-13 13:40:22 +02:00
Jonathan Jenne
e096f11b5e ZUGFeRDService: Version 1.5.0 2021-07-13 13:39:30 +02:00
Jonathan Jenne
d8c534c3e3 ZUGFeRDService: Add config option MaxAttachmentSizeInMegaBytes 2021-07-13 13:38:54 +02:00
Jonathan Jenne
b81d6a1314 EDMI.API/Client: WIP GetVariableValue 2021-07-12 13:57:51 +02:00
Jonathan Jenne
9f2cbc17e5 ZUGFeRDTest: Allow xml in test 2021-07-12 13:57:25 +02:00
Jonathan Jenne
aec9f58c84 Database/Firebird: Increase poolsize to 1000 2021-07-12 11:32:38 +02:00
Jonathan Jenne
df4c1691f4 Update project file 2021-07-12 11:32:03 +02:00
Jonathan Jenne
f358661297 ZUGFeRDService: Version 1.4.1 2021-07-12 11:31:36 +02:00
Jonathan Jenne
5866123893 ZUGFeRDService: Mask body test for emails, close connection when inserting history entries 2021-07-12 11:07:27 +02:00
14 changed files with 264 additions and 91 deletions

View File

@@ -134,6 +134,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MonoRepoUtils", "ConfigCrea
EndProject EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Encryption", "Encryption\Encryption.vbproj", "{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}" Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Encryption", "Encryption\Encryption.vbproj", "{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}"
EndProject EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Config.Test", "Config.Test\Config.Test.vbproj", "{B9A63193-1391-4E20-B578-0867F330396C}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -356,6 +358,10 @@ Global
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Debug|Any CPU.Build.0 = Debug|Any CPU {8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Release|Any CPU.ActiveCfg = Release|Any CPU {8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Release|Any CPU.Build.0 = Release|Any CPU {8A8F20FC-C46E-41AC-BEE7-218366CFFF99}.Release|Any CPU.Build.0 = Release|Any CPU
{B9A63193-1391-4E20-B578-0867F330396C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9A63193-1391-4E20-B578-0867F330396C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9A63193-1391-4E20-B578-0867F330396C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9A63193-1391-4E20-B578-0867F330396C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@@ -415,6 +421,7 @@ Global
{E24E8D40-0361-4C07-8FAE-3621DE316E70} = {8FFE925E-8B84-45F1-93CB-32B1C96F41EB} {E24E8D40-0361-4C07-8FAE-3621DE316E70} = {8FFE925E-8B84-45F1-93CB-32B1C96F41EB}
{9D4AC920-C78E-41C3-994E-91690FF79380} = {8FFE925E-8B84-45F1-93CB-32B1C96F41EB} {9D4AC920-C78E-41C3-994E-91690FF79380} = {8FFE925E-8B84-45F1-93CB-32B1C96F41EB}
{8A8F20FC-C46E-41AC-BEE7-218366CFFF99} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC} {8A8F20FC-C46E-41AC-BEE7-218366CFFF99} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC}
{B9A63193-1391-4E20-B578-0867F330396C} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286} SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286}

View File

@@ -86,7 +86,10 @@ Public Class Form1
End Function End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim args As New WorkerArgs() Dim args As New WorkerArgs() With {
.MaxAttachmentSizeInMegaBytes = 10,
.IgnoreRejectionStatus = False
}
args = LoadFolderConfig(args) args = LoadFolderConfig(args)
args = LoadPropertyMapFor(args, "DEFAULT") args = LoadPropertyMapFor(args, "DEFAULT")
args.InsertIntoSQLServer = True args.InsertIntoSQLServer = True
@@ -169,9 +172,10 @@ Public Class Form1
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim oExtractor = New PDFEmbeds(_logConfig) Dim oExtractor = New PDFEmbeds(_logConfig)
Dim oResult = OpenFileDialog1.ShowDialog() Dim oResult = OpenFileDialog1.ShowDialog()
Dim oExtensions = New List(Of String) From {"docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt", "xml"}
If oResult = DialogResult.OK Then If oResult = DialogResult.OK Then
oExtractor.Extract(OpenFileDialog1.FileName, AllowedExtensions:=New List(Of String) From {"docx", "doc", "pdf", "xls", "xlsx", "ppt", "pptx", "txt"}) oExtractor.Extract(OpenFileDialog1.FileName, AllowedExtensions:=oExtensions)
End If End If
End Sub End Sub
End Class End Class

View File

@@ -56,6 +56,8 @@ Public Class Firebird
Private _connectionString As String Private _connectionString As String
Public _DBInitialized As Boolean = False Public _DBInitialized As Boolean = False
Public Const MAX_POOL_SIZE = 1000
Public Enum TransactionMode Public Enum TransactionMode
<Description("Use no transaction, neither internal nor external")> <Description("Use no transaction, neither internal nor external")>
NoTransaction NoTransaction
@@ -147,7 +149,8 @@ Public Class Firebird
.Database = Database, .Database = Database,
.UserID = User, .UserID = User,
.Password = Password, .Password = Password,
.Charset = "UTF8" .Charset = "UTF8",
.MaxPoolSize = MAX_POOL_SIZE
}.ToString() }.ToString()
End Function End Function

View File

@@ -14,7 +14,6 @@ Public Class Client
Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel) Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel)
Private ReadOnly _IPAddressServer As String Private ReadOnly _IPAddressServer As String
Private _dummy_table_attributes As DataTable Private _dummy_table_attributes As DataTable
Private _channel As IEDMIServiceChannel Private _channel As IEDMIServiceChannel
@@ -32,6 +31,29 @@ Public Class Client
Public AccessRight As AccessRight Public AccessRight As AccessRight
End Class End Class
Public Class VariableValue
Public ReadOnly Property IsVector As Boolean = False
Public Property Value As Object
Public Property Type As Type
Public Sub New(pValue As Object)
' Check if value is a collection
If TypeOf pValue Is IEnumerable Then
IsVector = True
End If
' Try to determine the type
If IsNothing(pValue) Then
Type = Nothing
Else
Type = pValue.GetType
End If
Value = pValue
End Sub
End Class
Public Shared Function ParseServiceAddress(AddressWithOptionalPort As String) As Tuple(Of String, Integer) Public Shared Function ParseServiceAddress(AddressWithOptionalPort As String) As Tuple(Of String, Integer)
Dim oSplit() As String = AddressWithOptionalPort.Split(":"c) Dim oSplit() As String = AddressWithOptionalPort.Split(":"c)
Dim oAppServerAddress As String = oSplit(0) Dim oAppServerAddress As String = oSplit(0)
@@ -108,6 +130,10 @@ Public Class Client
End Try End Try
End Function End Function
Private Function PreloadAttributes()
End Function
''' <summary> ''' <summary>
''' TODO: Creates a new object ''' TODO: Creates a new object
''' </summary> ''' </summary>
@@ -245,8 +271,7 @@ Public Class Client
If oType = GetType(DataTable).Name Then If oType = GetType(DataTable).Name Then
Dim oValueTable As DataTable = pValue Dim oValueTable As DataTable = pValue
Dim oCurrentValue As Object Dim oCurrentValue As VariableValue
Dim oCurrentValueType As String
If pOptions.CheckDeleted = True Then If pOptions.CheckDeleted = True Then
Dim oOptions As New GetVariableValueOptions With { Dim oOptions As New GetVariableValueOptions With {
@@ -257,19 +282,16 @@ Public Class Client
' Get current value ' Get current value
oCurrentValue = GetVariableValue(pObjectId, pAttributeName, pAttributeType, oOptions) oCurrentValue = GetVariableValue(pObjectId, pAttributeName, pAttributeType, oOptions)
' Get current type
oCurrentValueType = oCurrentValue.GetType.Name
' If current value is datatable ' If current value is datatable
If oCurrentValueType = GetType(DataTable).Name Then If oCurrentValue.Type = GetType(DataTable) Then
' Convert value to Datatable ' Convert value to Datatable
Dim oCurrentTable As DataTable = oCurrentValue Dim oTable As DataTable = oCurrentValue.Value
If oCurrentTable.Rows.Count > 1 Then If oTable.Rows.Count > 1 Then
'now Checking whether the old row still remains in Vector? If not it will be deleted as it cannot be replaced in multivalues 'now Checking whether the old row still remains in Vector? If not it will be deleted as it cannot be replaced in multivalues
For Each oRow As DataRow In oCurrentTable.Rows For Each oRow As DataRow In oTable.Rows
Dim oExists As Boolean = False Dim oExists As Boolean = False
For Each oNewValueRow As DataRow In oValueTable.Rows For Each oNewValueRow As DataRow In oValueTable.Rows
Dim oInfo = $"Checking oldValue[{oRow.Item(0)}] vs NewValue [{oNewValueRow.Item(1)}]" Dim oInfo = $"Checking oldValue[{oRow.Item(0)}] vs NewValue [{oNewValueRow.Item(1)}]"
@@ -301,12 +323,12 @@ Public Class Client
Next Next
If oExists = False Then If oExists = False Then
_logger.Debug($"Value [{oCurrentValue}] no longer existing in Vector-Attribute [{pAttributeName}] - will be deleted!") _logger.Debug($"Value [{oCurrentValue}] no longer existing in Vector-Attribute [{pAttributeName}] - will be deleted!")
DeleteTermObjectFromMetadata(pObjectId, pAttributeName, oCurrentValue) DeleteTermObjectFromMetadata(pObjectId, pAttributeName, oCurrentValue.Value)
End If End If
Else Else
_logger.Debug($"Value [{oCurrentValue}] of Attribute [{pAttributeName}] obviously was updated during runtime - will be deleted!") _logger.Debug($"Value [{oCurrentValue}] of Attribute [{pAttributeName}] obviously was updated during runtime - will be deleted!")
DeleteTermObjectFromMetadata(pObjectId, pAttributeName, oCurrentValue) DeleteTermObjectFromMetadata(pObjectId, pAttributeName, oCurrentValue.Value)
End If End If
@@ -342,18 +364,17 @@ Public Class Client
End Function End Function
Public Class GetVariableValueOptions Public Class GetVariableValueOptions
Public FromIDB As Boolean = False
Public Username As String = String.Empty Public Username As String = String.Empty
Public Language As String = String.Empty Public Language As String = String.Empty
End Class End Class
Public Function GetVariableValue(pObjectId As Long, pAttributeName As String, pAttributeType As AttributeType, Optional pOptions As GetVariableValueOptions = Nothing) As Object Public Function GetVariableValue(pObjectId As Long, pAttributeName As String, pAttributeType As AttributeType, Optional pOptions As GetVariableValueOptions = Nothing) As VariableValue
If pOptions Is Nothing Then If pOptions Is Nothing Then
pOptions = New GetVariableValueOptions() pOptions = New GetVariableValueOptions()
End If End If
Dim oLanguage = NotNull(pOptions.Language, GetUserLanguage()) pOptions.Language = NotNull(pOptions.Language, GetUserLanguage())
Dim oUsername = NotNull(pOptions.Username, Environment.UserName) pOptions.Username = NotNull(pOptions.Username, Environment.UserName)
' Check if ObjectId exists ' Check if ObjectId exists
Try Try
@@ -368,29 +389,9 @@ Public Class Client
End Try End Try
' Get Attributes and Values from Database ' Get Attributes and Values from Database
Dim oTable As DataTable Dim oAttributes As DataTable = GetAttributesForObject(pObjectId, pOptions.Language)
Try
Dim oResult As TableResult = _channel.ReturnDatatable_MSSQL_IDB($"EXEC [PRIDB_GET_VALUE_DT]({pObjectId}, '{oLanguage}')")
If oResult.OK = False Then
Throw New ApplicationException(oResult.ErrorMessage)
End If
If oResult.Table Is Nothing OrElse oResult.Table.Rows.Count = 0 Then
Return Nothing
End If
oTable = oResult.Table
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
' TODO: Check if Attribute exists & REfactor ' TODO: Check if Attribute exists & REfactor
Try Try
Dim oVectorAttribute As Boolean = False Dim oVectorAttribute As Boolean = False
Select Case pAttributeType Select Case pAttributeType
@@ -402,44 +403,112 @@ Public Class Client
oVectorAttribute = False oVectorAttribute = False
End Select End Select
Dim oAttributeValue As Object = Nothing Dim oValues As New List(Of Object)
Dim oRows As List(Of DataRow) = oAttributes.AsEnumerable().
Where(Function(pRow As DataRow) pRow.Item("AttributeTitle") = pAttributeName).
ToList()
If Not IsNothing(_dummy_table_attributes) Then If oVectorAttribute = False Then
If oVectorAttribute = True And _dummy_table_attributes.Rows.Count = 1 And pOptions.FromIDB = False Then Dim oRow As DataRow = oRows.FirstOrDefault()
Try Dim oType As String = oRow.Item("AttributeType")
If pAttributeName = "IDBCreatedWhen" Then
pAttributeName = "ADDED_WHEN"
ElseIf pAttributeName = "IDBCreatedWho" Then
pAttributeName = "ADDED_WHO"
ElseIf pAttributeName = "IDBChangedWhen" Then
pAttributeName = "CHANGED_WHEN"
ElseIf pAttributeName = "IDBChangedWho" Then
pAttributeName = "CHANGED_WHO"
End If
oAttributeValue = _dummy_table_attributes.Rows(0).Item(pAttributeName) Dim oValue = GetValueByType(oRow, oType)
Catch ex As Exception 'oValues.Add(oValue)
_logger.Debug($"Error getting Attribute from IDB_DT_DOC_DATA: {ex.Message}")
End Try
End If Return New VariableValue(oValue)
End If
If Not IsNothing(oAttributeValue) Then
Return oAttributeValue
Else Else
_logger.Debug($"oAttributeValue for Attribute [{pAttributeName}] is so far nothing..Now trying FNIDB_PM_GET_VARIABLE_VALUE ") For Each oRow As DataRow In oRows
End If Dim oType As String = oRow.Item("AttributeType")
Dim oFNSQL = $"SELECT * FROM [dbo].[FNIDB_PM_GET_VARIABLE_VALUE] ({pObjectId},'{pAttributeName}','{oLanguage}',CONVERT(BIT,'0'))"
Dim oDatatable As TableResult = _channel.ReturnDatatable_MSSQL_IDB(oFNSQL)
If oDatatable.OK = False Then Dim oValue = GetValueByType(oRow, oType)
Throw New ApplicationException(oDatatable.ErrorMessage) oValues.Add(oValue)
Next
Return New VariableValue(oValues)
End If End If
If oDatatable.Table.Rows.Count = 1 Then 'If Not IsNothing(oAttributes) Then
oAttributeValue = oDatatable.Table.Rows.Item(0).Item(0) ' If oVectorAttribute = True And _dummy_table_attributes.Rows.Count = 1 And pOptions.FromIDB = False Then
End If ' Try
' If pAttributeName = "IDBCreatedWhen" Then
' pAttributeName = "ADDED_WHEN"
' ElseIf pAttributeName = "IDBCreatedWho" Then
' pAttributeName = "ADDED_WHO"
' ElseIf pAttributeName = "IDBChangedWhen" Then
' pAttributeName = "CHANGED_WHEN"
' ElseIf pAttributeName = "IDBChangedWho" Then
' pAttributeName = "CHANGED_WHO"
' End If
' oAttributeValue = _dummy_table_attributes.Rows(0).Item(pAttributeName)
' Catch ex As Exception
' _logger.Debug($"Error getting Attribute from IDB_DT_DOC_DATA: {ex.Message}")
' End Try
' End If
'Else
' Throw New ApplicationException($"Could not get Attributes for ObjectId [{pObjectId}]")
'End If
'TODO: BRAUCHEN SIE DAS ÜBERHAUPT??????11111?!!1!1
'If Not IsNothing(oAttributeValue) Then
' Return oAttributeValue
'Else
' _logger.Debug($"oAttributeValue for Attribute [{pAttributeName}] is so far nothing..Now trying FNIDB_PM_GET_VARIABLE_VALUE ")
'End If
'Dim oFNSQL = $"SELECT * FROM [dbo].[FNIDB_PM_GET_VARIABLE_VALUE] ({pObjectId},'{pAttributeName}','{pOptions.Language}',CONVERT(BIT,'0'))"
'Dim oDatatable As TableResult = _channel.ReturnDatatable_MSSQL_IDB(oFNSQL)
'If oDatatable.OK = False Then
' Throw New ApplicationException(oDatatable.ErrorMessage)
'End If
'If oDatatable.Table.Rows.Count = 1 Then
' oAttributeValue = oDatatable.Table.Rows.Item(0).Item(0)
'End If
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
Private Function GetValueByType(pRow As DataRow, pTypeString As String) As Object
Try
Dim oAttributeValue As Object
Select Case pTypeString
Case Constants.AttributeTypeName.BIT
oAttributeValue = pRow.Item("ValueBigInt")
Case Constants.AttributeTypeName.BIG_INTEGER
oAttributeValue = pRow.Item("ValueBigInt")
Case Constants.AttributeTypeName.DATE
oAttributeValue = pRow.Item("ValueDate")
Case Constants.AttributeTypeName.DATETIME
oAttributeValue = pRow.Item("ValueDate")
Case Constants.AttributeTypeName.DECIMAL
oAttributeValue = pRow.Item("ValueDecimal")
Case Constants.AttributeTypeName.FLOAT
oAttributeValue = pRow.Item("ValueDecimal")
Case Constants.AttributeTypeName.VARCHAR
oAttributeValue = pRow.Item("ValueText")
Case Constants.AttributeTypeName.VECTOR_INTEGER
oAttributeValue = pRow.Item("ValueBigInt")
Case Constants.AttributeTypeName.VECTOR_STRING
oAttributeValue = pRow.Item("ValueText")
Case Else
oAttributeValue = Nothing
End Select
Return oAttributeValue Return oAttributeValue
Catch ex As Exception Catch ex As Exception
@@ -449,6 +518,29 @@ Public Class Client
End Try End Try
End Function End Function
Private Function GetAttributesForObject(pObjectId As Long, pLanguage As String) As DataTable
Dim oTable As DataTable
Try
Dim oResult As TableResult = _channel.ReturnDatatable_MSSQL_IDB($"EXEC [PRIDB_GET_VALUE_DT]({pObjectId}, '{pLanguage}')")
If oResult.OK = False Then
Throw New ApplicationException(oResult.ErrorMessage)
End If
If oResult.Table Is Nothing OrElse oResult.Table.Rows.Count = 0 Then
Return Nothing
End If
oTable = oResult.Table
Return oTable
Catch ex As Exception
_logger.Error(ex)
Return Nothing
End Try
End Function
Private Function DeleteTermObjectFromMetadata(pObjectId As Long, pAttributeName As String, pTerm2Delete As String, Optional pUsername As String = "", Optional pLanguage As String = "") As Boolean Private Function DeleteTermObjectFromMetadata(pObjectId As Long, pAttributeName As String, pTerm2Delete As String, Optional pUsername As String = "", Optional pLanguage As String = "") As Boolean
Try Try
Dim oLanguage = NotNull(pLanguage, GetUserLanguage()) Dim oLanguage = NotNull(pLanguage, GetUserLanguage())
@@ -516,8 +608,6 @@ Public Class Client
End Try End Try
End Function End Function
''' <summary> ''' <summary>
''' Return infos about a file object ''' Return infos about a file object
''' </summary> ''' </summary>

View File

@@ -17,4 +17,16 @@
VectorString = 8 VectorString = 8
VectorInteger = 9 VectorInteger = 9
End Enum End Enum
Public Class AttributeTypeName
Public Const VARCHAR = "VARCHAR"
Public Const BIG_INTEGER = "BIG INTEGER"
Public Const FLOAT = "FLOAT"
Public Const [DECIMAL] = "DECIMAL"
Public Const [DATE] = "DATE"
Public Const [DATETIME] = "DATETIME"
Public Const BIT = "BIT"
Public Const VECTOR_STRING = "VECTOR STRING"
Public Const VECTOR_INTEGER = "VECTOR INTEGER"
End Class
End Class End Class

View File

@@ -75,7 +75,9 @@ Public Class EmailFunctions
Dim oEmailTo = "" Dim oEmailTo = ""
Dim oSubject = EmailStrings.EMAIL_SUBJECT_REJECTED Dim oSubject = EmailStrings.EMAIL_SUBJECT_REJECTED
Dim oCreatedWho = "ZUGFeRD Service" Dim oCreatedWho = "ZUGFeRD Service"
Dim oFinalBodyText = String.Format(EmailStrings.EMAIL_WRAPPING_TEXT, BodyText)
Dim oMaskedBodyText = BodyText.Replace("'", "''")
Dim oFinalBodyText = String.Format(EmailStrings.EMAIL_WRAPPING_TEXT, oMaskedBodyText)
Dim oEmailAddress = pEmailData.From Dim oEmailAddress = pEmailData.From
Dim oAttachment = pEmailData.Attachment Dim oAttachment = pEmailData.Attachment

View File

@@ -23,6 +23,8 @@
Public Const EMAIL_NO_FERDS = "<p>Ihre Email enthielt keine ZUGFeRD-Dokumente.</p>" Public Const EMAIL_NO_FERDS = "<p>Ihre Email enthielt keine ZUGFeRD-Dokumente.</p>"
Public Const EMAIL_FILE_SIZE_REACHED = "<p>Ihre Email enthielt Dateien, die die erlaubte Größe von {0}MB überschreiten.</p>"
Public Const EMAIL_INVALID_DOCUMENT = """ Public Const EMAIL_INVALID_DOCUMENT = """
<p>Ihre Email enthielt ein ZUGFeRD Dokument, welches aber inkorrekt formatiert wurde.</p> <p>Ihre Email enthielt ein ZUGFeRD Dokument, welches aber inkorrekt formatiert wurde.</p>
<p>Mögliche Gründe für ein inkorrektes Format:<ul> <p>Mögliche Gründe für ein inkorrektes Format:<ul>

View File

@@ -206,11 +206,24 @@ Public Class ImportZUGFeRDFiles
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)
oEmailAttachmentFiles.Add(oFile) oEmailAttachmentFiles.Add(oFile)
' Checking filesize for attachment files
If Check_FileSize(oFile, 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
Continue For Continue For
End If End If
_logger.Info("Start processing file {0}", oFile.Name) _logger.Info("Start processing file {0}", oFile.Name)
' Checking filesize for pdf files
If Check_FileSize(oFile, 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
Try Try
oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(oFile.FullName) oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(oFile.FullName)
Catch ex As ZUGFeRDExecption Catch ex As ZUGFeRDExecption
@@ -241,7 +254,7 @@ Public Class ImportZUGFeRDFiles
End If End If
' Check the Checksum and rejection status ' Check the Checksum and rejection status
oMD5CheckSum = Check_MD5Sum(oFile.FullName, oArgs.IgnoreRejectionStatus) oMD5CheckSum = GenerateAndCheck_MD5Sum(oFile.FullName, oArgs.IgnoreRejectionStatus)
' Check if there are more than one ZUGFeRD files ' Check if there are more than one ZUGFeRD files
If oZUGFeRDCount = 1 Then If oZUGFeRDCount = 1 Then
@@ -334,8 +347,6 @@ Public Class ImportZUGFeRDFiles
Catch ex As MD5HashException Catch ex As MD5HashException
_logger.Error(ex) _logger.Error(ex)
'Dim oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET COMMENT = '{oMessage}' WHERE MESSAGE_ID = '{oMessageId}'"
'_firebird.ExecuteNonQuery(oSQL, oFBTransaction)
Dim oMessage = "REJECTED - Already processed (MD5Hash)" Dim oMessage = "REJECTED - Already processed (MD5Hash)"
Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage, oFBTransaction) Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage, oFBTransaction)
@@ -347,9 +358,6 @@ Public Class ImportZUGFeRDFiles
Catch ex As InvalidFerdException Catch ex As InvalidFerdException
_logger.Error(ex) _logger.Error(ex)
'Dim oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET COMMENT = 'REJECTED - ZUGFeRD yes but incorrect format' WHERE GUID = '{HISTORY_ID}'"
'_firebird.ExecuteNonQuery(oSQL, oFBTransaction)
' When InvalidFerdException is thrown, we don't have a MD5Hash yet. ' When InvalidFerdException is thrown, we don't have a MD5Hash yet.
' That 's why we set it to String.Empty here. ' That 's why we set it to String.Empty here.
Create_HistoryEntry(oMessageId, String.Empty, "REJECTED - ZUGFeRD yes but incorrect format", oFBTransaction) Create_HistoryEntry(oMessageId, String.Empty, "REJECTED - ZUGFeRD yes but incorrect format", oFBTransaction)
@@ -362,8 +370,6 @@ Public Class ImportZUGFeRDFiles
Catch ex As TooMuchFerdsException Catch ex As TooMuchFerdsException
_logger.Error(ex) _logger.Error(ex)
'Dim oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET COMMENT = 'REJECTED - More than one ZUGFeRD-document in email' WHERE GUID = '{HISTORY_ID}'"
'_firebird.ExecuteNonQuery(oSQL, oFBTransaction)
Create_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - More than one ZUGFeRD-document in email", oFBTransaction) Create_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - More than one ZUGFeRD-document in email", oFBTransaction)
Dim oBody = EmailStrings.EMAIL_TOO_MUCH_FERDS Dim oBody = EmailStrings.EMAIL_TOO_MUCH_FERDS
@@ -374,8 +380,6 @@ Public Class ImportZUGFeRDFiles
Catch ex As NoFerdsException Catch ex As NoFerdsException
_logger.Error(ex) _logger.Error(ex)
'Dim oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET COMMENT = 'REJECTED - no ZUGFeRD-Document in email' WHERE GUID = '{HISTORY_ID}'"
'_firebird.ExecuteNonQuery(oSQL, oFBTransaction)
Create_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - no ZUGFeRD-Document in email", oFBTransaction) Create_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - no ZUGFeRD-Document in email", oFBTransaction)
Dim oBody = EmailStrings.EMAIL_NO_FERDS Dim oBody = EmailStrings.EMAIL_NO_FERDS
@@ -390,8 +394,7 @@ Public Class ImportZUGFeRDFiles
For Each prop In oMissingProperties For Each prop In oMissingProperties
oMessage &= $"- {prop}" oMessage &= $"- {prop}"
Next Next
'Dim oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET COMMENT = 'REJECTED - Missing Required Properties: [{oMessage}]' WHERE GUID = '{HISTORY_ID}'"
'_firebird.ExecuteNonQuery(oSQL, oFBTransaction)
Create_HistoryEntry(oMessageId, oMD5CheckSum, $"REJECTED - Missing Required Properties: [{oMessage}]", oFBTransaction) Create_HistoryEntry(oMessageId, oMD5CheckSum, $"REJECTED - Missing Required Properties: [{oMessage}]", oFBTransaction)
Dim oBody = CreateBodyForMissingProperties(ex.File.Name, oMissingProperties) Dim oBody = CreateBodyForMissingProperties(ex.File.Name, oMissingProperties)
@@ -399,6 +402,17 @@ Public Class ImportZUGFeRDFiles
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MissingValueException", _EmailOutAccountId) _email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MissingValueException", _EmailOutAccountId)
AddRejectedState(oMessageId, "MissingValueException", "Es fehlten ZugferdSpezifikationen", oMessage, oSQLTransaction) AddRejectedState(oMessageId, "MissingValueException", "Es fehlten ZugferdSpezifikationen", oMessage, oSQLTransaction)
Catch ex As FileSizeLimitReachedException
_logger.Error(ex)
Create_HistoryEntry(oMessageId, oMD5CheckSum, "REJECTED - File size limit reached", oFBTransaction)
Dim oBody = String.Format(EmailStrings.EMAIL_FILE_SIZE_REACHED, oArgs.MaxAttachmentSizeInMegaBytes)
Dim oEmailData = MoveAndRenameEmailToRejected(oArgs, oMessageId)
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "FileSizeLimitReachedException", _EmailOutAccountId)
AddRejectedState(oMessageId, "FileSizeLimitReachedException", "Erlaubte Dateigröße überschritten", "", oSQLTransaction)
Catch ex As OutOfMemoryException Catch ex As OutOfMemoryException
_logger.Warn("OutOfMemory Error occurred: {0}", ex.Message) _logger.Warn("OutOfMemory Error occurred: {0}", ex.Message)
_logger.Error(ex) _logger.Error(ex)
@@ -644,6 +658,9 @@ Public Class ImportZUGFeRDFiles
' entry needs to be accessed by MoveAndRenameEmailToRejected shortly after ' entry needs to be accessed by MoveAndRenameEmailToRejected shortly after
_firebird.ExecuteNonQueryWithConnection(oSQL, oConnection, Firebird.TransactionMode.WithTransaction) _firebird.ExecuteNonQueryWithConnection(oSQL, oConnection, Firebird.TransactionMode.WithTransaction)
' Close the connection
oConnection.Close()
Return True Return True
Catch ex As Exception Catch ex As Exception
_logger.Warn("History Entry count not be created for message id [{0}] and md5 [{1}]", MessageId, MD5Checksum) _logger.Warn("History Entry count not be created for message id [{0}] and md5 [{1}]", MessageId, MD5Checksum)
@@ -675,7 +692,7 @@ Public Class ImportZUGFeRDFiles
''' <param name="pIgnoreRejectionStatus">Should the check take into account the rejection status of the file?</param> ''' <param name="pIgnoreRejectionStatus">Should the check take into account the rejection status of the file?</param>
''' <returns>The MD5 Checksum of the file, or an empty string, if the Checksum could not be created</returns> ''' <returns>The MD5 Checksum of the file, or an empty string, if the Checksum could not be created</returns>
''' <exception cref="MD5HashException">Throws, when the file should be rejected, ie. if it already exists in the table</exception> ''' <exception cref="MD5HashException">Throws, when the file should be rejected, ie. if it already exists in the table</exception>
Private Function Check_MD5Sum(pFilePath As String, pIgnoreRejectionStatus As Boolean) As String Private Function GenerateAndCheck_MD5Sum(pFilePath As String, pIgnoreRejectionStatus As Boolean) As String
Dim oMD5CheckSum = CreateMD5(pFilePath) Dim oMD5CheckSum = CreateMD5(pFilePath)
' Exit if MD5 could not be created ' Exit if MD5 could not be created
@@ -737,4 +754,23 @@ Public Class ImportZUGFeRDFiles
Return oMD5CheckSum Return oMD5CheckSum
End Function End Function
''' <summary>
''' Checks the size of the supplied file.
''' </summary>
''' <param name="pFileInfo"></param>
''' <param name="pMaxFileSizeInMegaBytes"></param>
''' <returns></returns>
Private Function Check_FileSize(pFileInfo As FileInfo, pMaxFileSizeInMegaBytes As Integer) As Boolean
If pMaxFileSizeInMegaBytes <= 0 Then
Return True
End If
Dim oMaxSize = pMaxFileSizeInMegaBytes * 1024 * 1024
If oMaxSize > 0 And pFileInfo.Length > oMaxSize Then
Return False
Else
Return True
End If
End Function
End Class End Class

View File

@@ -13,6 +13,7 @@ Public Class WorkerArgs
Public ExceptionEmailAddress As String Public ExceptionEmailAddress As String
Public IgnoreRejectionStatus As Boolean Public IgnoreRejectionStatus As Boolean
Public MaxAttachmentSizeInMegaBytes As Integer
Public Sub New() Public Sub New()
WatchDirectories = New List(Of String) WatchDirectories = New List(Of String)
@@ -26,5 +27,6 @@ Public Class WorkerArgs
ExceptionEmailAddress = Nothing ExceptionEmailAddress = Nothing
IgnoreRejectionStatus = False IgnoreRejectionStatus = False
MaxAttachmentSizeInMegaBytes = -1
End Sub End Sub
End Class End Class

View File

@@ -21,6 +21,14 @@ Public Class Exceptions
End Sub End Sub
End Class End Class
Public Class FileSizeLimitReachedException
Inherits ApplicationException
Public Sub New(pFilePath As String, pFileSizeLimitInMegaBytes As Integer)
MyBase.New($"At least one file exceeded the filesize limit of {pFileSizeLimitInMegaBytes}MB: {pFilePath}")
End Sub
End Class
Public Class InvalidFerdException Public Class InvalidFerdException
Inherits ApplicationException Inherits ApplicationException

View File

@@ -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("1.6.6.0")> <Assembly: AssemblyVersion("1.7.0.0")>
<Assembly: AssemblyFileVersion("1.6.6.0")> <Assembly: AssemblyFileVersion("1.7.0.0")>

View File

@@ -21,6 +21,12 @@
''' regardless of the REJECTED status. ''' regardless of the REJECTED status.
''' </summary> ''' </summary>
Public Property IgnoreRejectionStatus As Boolean = False Public Property IgnoreRejectionStatus As Boolean = False
''' <summary>
''' Maximum Size for attachment files in MB. If This is set to -1,
''' there's no size limit.
''' </summary>
Public Property MaxAttachmentSizeInMegaBytes As Integer = -1
End Class End Class
Public Class FirebirdConfig Public Class FirebirdConfig

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.4.0.0")> <Assembly: AssemblyVersion("1.5.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")> <Assembly: AssemblyFileVersion("1.0.0.0")>

View File

@@ -51,7 +51,8 @@ Public Class ThreadRunner
Dim oArgs As New WorkerArgs With { Dim oArgs As New WorkerArgs With {
.ExceptionEmailAddress = _config.Config.ExceptionEmailAddress, .ExceptionEmailAddress = _config.Config.ExceptionEmailAddress,
.IgnoreRejectionStatus = _config.Config.Custom.IgnoreRejectionStatus .IgnoreRejectionStatus = _config.Config.Custom.IgnoreRejectionStatus,
.MaxAttachmentSizeInMegaBytes = _config.Config.Custom.MaxAttachmentSizeInMegaBytes
} }
oArgs = LoadFolderConfig(oArgs) oArgs = LoadFolderConfig(oArgs)
oArgs = LoadPropertyMapFor(oArgs, "DEFAULT") oArgs = LoadPropertyMapFor(oArgs, "DEFAULT")