Compare commits
9 Commits
49aedfb44c
...
757a8616dc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
757a8616dc | ||
|
|
e096f11b5e | ||
|
|
d8c534c3e3 | ||
|
|
b81d6a1314 | ||
|
|
9f2cbc17e5 | ||
|
|
aec9f58c84 | ||
|
|
df4c1691f4 | ||
|
|
f358661297 | ||
|
|
5866123893 |
@@ -134,6 +134,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "MonoRepoUtils", "ConfigCrea
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Encryption", "Encryption\Encryption.vbproj", "{8A8F20FC-C46E-41AC-BEE7-218366CFFF99}"
|
||||
EndProject
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Config.Test", "Config.Test\Config.Test.vbproj", "{B9A63193-1391-4E20-B578-0867F330396C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
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}.Release|Any CPU.ActiveCfg = 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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -415,6 +421,7 @@ Global
|
||||
{E24E8D40-0361-4C07-8FAE-3621DE316E70} = {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}
|
||||
{B9A63193-1391-4E20-B578-0867F330396C} = {3E2008C8-27B1-41DD-9B1A-0C4029F6AECC}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C1BE4090-A0FD-48AF-86CB-39099D14B286}
|
||||
|
||||
@@ -86,7 +86,10 @@ Public Class Form1
|
||||
End Function
|
||||
|
||||
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 = LoadPropertyMapFor(args, "DEFAULT")
|
||||
args.InsertIntoSQLServer = True
|
||||
@@ -169,9 +172,10 @@ Public Class Form1
|
||||
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
|
||||
Dim oExtractor = New PDFEmbeds(_logConfig)
|
||||
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
|
||||
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 Sub
|
||||
End Class
|
||||
|
||||
@@ -56,6 +56,8 @@ Public Class Firebird
|
||||
Private _connectionString As String
|
||||
Public _DBInitialized As Boolean = False
|
||||
|
||||
Public Const MAX_POOL_SIZE = 1000
|
||||
|
||||
Public Enum TransactionMode
|
||||
<Description("Use no transaction, neither internal nor external")>
|
||||
NoTransaction
|
||||
@@ -147,7 +149,8 @@ Public Class Firebird
|
||||
.Database = Database,
|
||||
.UserID = User,
|
||||
.Password = Password,
|
||||
.Charset = "UTF8"
|
||||
.Charset = "UTF8",
|
||||
.MaxPoolSize = MAX_POOL_SIZE
|
||||
}.ToString()
|
||||
End Function
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ Public Class Client
|
||||
Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel)
|
||||
Private ReadOnly _IPAddressServer As String
|
||||
|
||||
|
||||
Private _dummy_table_attributes As DataTable
|
||||
Private _channel As IEDMIServiceChannel
|
||||
|
||||
@@ -32,6 +31,29 @@ Public Class Client
|
||||
Public AccessRight As AccessRight
|
||||
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)
|
||||
Dim oSplit() As String = AddressWithOptionalPort.Split(":"c)
|
||||
Dim oAppServerAddress As String = oSplit(0)
|
||||
@@ -108,6 +130,10 @@ Public Class Client
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function PreloadAttributes()
|
||||
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' TODO: Creates a new object
|
||||
''' </summary>
|
||||
@@ -245,8 +271,7 @@ Public Class Client
|
||||
|
||||
If oType = GetType(DataTable).Name Then
|
||||
Dim oValueTable As DataTable = pValue
|
||||
Dim oCurrentValue As Object
|
||||
Dim oCurrentValueType As String
|
||||
Dim oCurrentValue As VariableValue
|
||||
|
||||
If pOptions.CheckDeleted = True Then
|
||||
Dim oOptions As New GetVariableValueOptions With {
|
||||
@@ -257,19 +282,16 @@ Public Class Client
|
||||
' Get current value
|
||||
oCurrentValue = GetVariableValue(pObjectId, pAttributeName, pAttributeType, oOptions)
|
||||
|
||||
' Get current type
|
||||
oCurrentValueType = oCurrentValue.GetType.Name
|
||||
|
||||
' If current value is datatable
|
||||
If oCurrentValueType = GetType(DataTable).Name Then
|
||||
If oCurrentValue.Type = GetType(DataTable) Then
|
||||
|
||||
' 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
|
||||
For Each oRow As DataRow In oCurrentTable.Rows
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oExists As Boolean = False
|
||||
For Each oNewValueRow As DataRow In oValueTable.Rows
|
||||
Dim oInfo = $"Checking oldValue[{oRow.Item(0)}] vs NewValue [{oNewValueRow.Item(1)}]"
|
||||
@@ -301,12 +323,12 @@ Public Class Client
|
||||
Next
|
||||
If oExists = False Then
|
||||
_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
|
||||
|
||||
Else
|
||||
_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
|
||||
|
||||
@@ -342,18 +364,17 @@ Public Class Client
|
||||
End Function
|
||||
|
||||
Public Class GetVariableValueOptions
|
||||
Public FromIDB As Boolean = False
|
||||
Public Username As String = String.Empty
|
||||
Public Language As String = String.Empty
|
||||
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
|
||||
pOptions = New GetVariableValueOptions()
|
||||
End If
|
||||
|
||||
Dim oLanguage = NotNull(pOptions.Language, GetUserLanguage())
|
||||
Dim oUsername = NotNull(pOptions.Username, Environment.UserName)
|
||||
pOptions.Language = NotNull(pOptions.Language, GetUserLanguage())
|
||||
pOptions.Username = NotNull(pOptions.Username, Environment.UserName)
|
||||
|
||||
' Check if ObjectId exists
|
||||
Try
|
||||
@@ -368,29 +389,9 @@ Public Class Client
|
||||
End Try
|
||||
|
||||
' Get Attributes and Values from Database
|
||||
Dim oTable As DataTable
|
||||
|
||||
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
|
||||
Dim oAttributes As DataTable = GetAttributesForObject(pObjectId, pOptions.Language)
|
||||
|
||||
' TODO: Check if Attribute exists & REfactor
|
||||
|
||||
|
||||
|
||||
Try
|
||||
Dim oVectorAttribute As Boolean = False
|
||||
Select Case pAttributeType
|
||||
@@ -402,44 +403,112 @@ Public Class Client
|
||||
oVectorAttribute = False
|
||||
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 = True And _dummy_table_attributes.Rows.Count = 1 And pOptions.FromIDB = False Then
|
||||
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
|
||||
If oVectorAttribute = False Then
|
||||
Dim oRow As DataRow = oRows.FirstOrDefault()
|
||||
Dim oType As String = oRow.Item("AttributeType")
|
||||
|
||||
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
|
||||
Dim oValue = GetValueByType(oRow, oType)
|
||||
'oValues.Add(oValue)
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not IsNothing(oAttributeValue) Then
|
||||
Return oAttributeValue
|
||||
Return New VariableValue(oValue)
|
||||
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}','{oLanguage}',CONVERT(BIT,'0'))"
|
||||
Dim oDatatable As TableResult = _channel.ReturnDatatable_MSSQL_IDB(oFNSQL)
|
||||
For Each oRow As DataRow In oRows
|
||||
Dim oType As String = oRow.Item("AttributeType")
|
||||
|
||||
If oDatatable.OK = False Then
|
||||
Throw New ApplicationException(oDatatable.ErrorMessage)
|
||||
Dim oValue = GetValueByType(oRow, oType)
|
||||
oValues.Add(oValue)
|
||||
Next
|
||||
|
||||
Return New VariableValue(oValues)
|
||||
End If
|
||||
|
||||
If oDatatable.Table.Rows.Count = 1 Then
|
||||
oAttributeValue = oDatatable.Table.Rows.Item(0).Item(0)
|
||||
End If
|
||||
'If Not IsNothing(oAttributes) Then
|
||||
' If oVectorAttribute = True And _dummy_table_attributes.Rows.Count = 1 And pOptions.FromIDB = False Then
|
||||
' 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
|
||||
|
||||
Catch ex As Exception
|
||||
@@ -449,6 +518,29 @@ Public Class Client
|
||||
End Try
|
||||
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
|
||||
Try
|
||||
Dim oLanguage = NotNull(pLanguage, GetUserLanguage())
|
||||
@@ -516,8 +608,6 @@ Public Class Client
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
''' <summary>
|
||||
''' Return infos about a file object
|
||||
''' </summary>
|
||||
|
||||
@@ -17,4 +17,16 @@
|
||||
VectorString = 8
|
||||
VectorInteger = 9
|
||||
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
|
||||
|
||||
@@ -75,7 +75,9 @@ Public Class EmailFunctions
|
||||
Dim oEmailTo = ""
|
||||
Dim oSubject = EmailStrings.EMAIL_SUBJECT_REJECTED
|
||||
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 oAttachment = pEmailData.Attachment
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
|
||||
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 = """
|
||||
<p>Ihre Email enthielt ein ZUGFeRD Dokument, welches aber inkorrekt formatiert wurde.</p>
|
||||
<p>Mögliche Gründe für ein inkorrektes Format:<ul>
|
||||
|
||||
@@ -206,11 +206,24 @@ Public Class ImportZUGFeRDFiles
|
||||
If Not oFile.Name.EndsWith(".pdf") Then
|
||||
_logger.Debug("Skipping non-pdf file {0}", oFile.Name)
|
||||
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
|
||||
End If
|
||||
|
||||
_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
|
||||
oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(oFile.FullName)
|
||||
Catch ex As ZUGFeRDExecption
|
||||
@@ -241,7 +254,7 @@ Public Class ImportZUGFeRDFiles
|
||||
End If
|
||||
|
||||
' 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
|
||||
If oZUGFeRDCount = 1 Then
|
||||
@@ -334,8 +347,6 @@ Public Class ImportZUGFeRDFiles
|
||||
Catch ex As MD5HashException
|
||||
_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)"
|
||||
Update_HistoryEntry(oMessageId, oMD5CheckSum, oMessage, oFBTransaction)
|
||||
|
||||
@@ -347,9 +358,6 @@ Public Class ImportZUGFeRDFiles
|
||||
Catch ex As InvalidFerdException
|
||||
_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.
|
||||
' That 's why we set it to String.Empty here.
|
||||
Create_HistoryEntry(oMessageId, String.Empty, "REJECTED - ZUGFeRD yes but incorrect format", oFBTransaction)
|
||||
@@ -362,8 +370,6 @@ Public Class ImportZUGFeRDFiles
|
||||
Catch ex As TooMuchFerdsException
|
||||
_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)
|
||||
|
||||
Dim oBody = EmailStrings.EMAIL_TOO_MUCH_FERDS
|
||||
@@ -374,8 +380,6 @@ Public Class ImportZUGFeRDFiles
|
||||
Catch ex As NoFerdsException
|
||||
_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)
|
||||
|
||||
Dim oBody = EmailStrings.EMAIL_NO_FERDS
|
||||
@@ -390,8 +394,7 @@ Public Class ImportZUGFeRDFiles
|
||||
For Each prop In oMissingProperties
|
||||
oMessage &= $"- {prop}"
|
||||
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)
|
||||
|
||||
Dim oBody = CreateBodyForMissingProperties(ex.File.Name, oMissingProperties)
|
||||
@@ -399,6 +402,17 @@ Public Class ImportZUGFeRDFiles
|
||||
_email.AddToEmailQueueMSSQL(oMessageId, oBody, oEmailData, "MissingValueException", _EmailOutAccountId)
|
||||
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
|
||||
_logger.Warn("OutOfMemory Error occurred: {0}", ex.Message)
|
||||
_logger.Error(ex)
|
||||
@@ -644,6 +658,9 @@ Public Class ImportZUGFeRDFiles
|
||||
' entry needs to be accessed by MoveAndRenameEmailToRejected shortly after
|
||||
_firebird.ExecuteNonQueryWithConnection(oSQL, oConnection, Firebird.TransactionMode.WithTransaction)
|
||||
|
||||
' Close the connection
|
||||
oConnection.Close()
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
_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>
|
||||
''' <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>
|
||||
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)
|
||||
|
||||
' Exit if MD5 could not be created
|
||||
@@ -737,4 +754,23 @@ Public Class ImportZUGFeRDFiles
|
||||
|
||||
Return oMD5CheckSum
|
||||
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
|
||||
|
||||
@@ -13,6 +13,7 @@ Public Class WorkerArgs
|
||||
|
||||
Public ExceptionEmailAddress As String
|
||||
Public IgnoreRejectionStatus As Boolean
|
||||
Public MaxAttachmentSizeInMegaBytes As Integer
|
||||
|
||||
Public Sub New()
|
||||
WatchDirectories = New List(Of String)
|
||||
@@ -26,5 +27,6 @@ Public Class WorkerArgs
|
||||
|
||||
ExceptionEmailAddress = Nothing
|
||||
IgnoreRejectionStatus = False
|
||||
MaxAttachmentSizeInMegaBytes = -1
|
||||
End Sub
|
||||
End Class
|
||||
@@ -21,6 +21,14 @@ Public Class Exceptions
|
||||
End Sub
|
||||
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
|
||||
Inherits ApplicationException
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
<Assembly: AssemblyVersion("1.6.6.0")>
|
||||
<Assembly: AssemblyFileVersion("1.6.6.0")>
|
||||
<Assembly: AssemblyVersion("1.7.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.7.0.0")>
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
''' regardless of the REJECTED status.
|
||||
''' </summary>
|
||||
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
|
||||
|
||||
Public Class FirebirdConfig
|
||||
|
||||
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' übernehmen, indem Sie "*" eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.4.0.0")>
|
||||
<Assembly: AssemblyVersion("1.5.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
||||
|
||||
@@ -51,7 +51,8 @@ Public Class ThreadRunner
|
||||
|
||||
Dim oArgs As New WorkerArgs With {
|
||||
.ExceptionEmailAddress = _config.Config.ExceptionEmailAddress,
|
||||
.IgnoreRejectionStatus = _config.Config.Custom.IgnoreRejectionStatus
|
||||
.IgnoreRejectionStatus = _config.Config.Custom.IgnoreRejectionStatus,
|
||||
.MaxAttachmentSizeInMegaBytes = _config.Config.Custom.MaxAttachmentSizeInMegaBytes
|
||||
}
|
||||
oArgs = LoadFolderConfig(oArgs)
|
||||
oArgs = LoadPropertyMapFor(oArgs, "DEFAULT")
|
||||
|
||||
Reference in New Issue
Block a user