diff --git a/.gitignore b/.gitignore index 3c4efe20..61494a68 100644 --- a/.gitignore +++ b/.gitignore @@ -258,4 +258,13 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc \ No newline at end of file +*.pyc +/GUIs.Test.ZUGFeRDTest/Form1.vb +/GUIs.Test.ZUGFeRDTest/Form1.resx +/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb +/GUIs.Test.ZUGFeRDTest/Form1.vb +/GUIs.Test.ZUGFeRDTest/Form1.resx +/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb +/GUIs.Test.ZUGFeRDTest/Form1.vb +/GUIs.Test.ZUGFeRDTest/Form1.resx +/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb diff --git a/ConfigCreator/App.config b/ConfigCreator/App.config index fc73d3ca..14d631fc 100644 --- a/ConfigCreator/App.config +++ b/ConfigCreator/App.config @@ -46,7 +46,7 @@ - + diff --git a/ConfigCreator/MonoRepoUtils.vbproj b/ConfigCreator/MonoRepoUtils.vbproj index 7e08b36e..51d85c72 100644 --- a/ConfigCreator/MonoRepoUtils.vbproj +++ b/ConfigCreator/MonoRepoUtils.vbproj @@ -11,7 +11,7 @@ DigitalData.GUIs.MonoRepoUtils 512 WindowsForms - v4.8 + v4.6.2 true true diff --git a/ConfigCreator/My Project/Settings.Designer.vb b/ConfigCreator/My Project/Settings.Designer.vb index ac0cef39..b6300054 100644 --- a/ConfigCreator/My Project/Settings.Designer.vb +++ b/ConfigCreator/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/Controls.DocumentViewer/App.config b/Controls.DocumentViewer/App.config index a86c6465..ac126d38 100644 --- a/Controls.DocumentViewer/App.config +++ b/Controls.DocumentViewer/App.config @@ -1,6 +1,6 @@ - + diff --git a/Controls.DocumentViewer/DocumentViewer.vbproj b/Controls.DocumentViewer/DocumentViewer.vbproj index 26ea61c8..f7fa0295 100644 --- a/Controls.DocumentViewer/DocumentViewer.vbproj +++ b/Controls.DocumentViewer/DocumentViewer.vbproj @@ -12,7 +12,7 @@ DigitalData.Controls.DocumentViewer 512 Windows - v4.8 + v4.6.2 true diff --git a/Controls.DocumentViewer/My Project/AssemblyInfo.vb b/Controls.DocumentViewer/My Project/AssemblyInfo.vb index af56e964..69c95351 100644 --- a/Controls.DocumentViewer/My Project/AssemblyInfo.vb +++ b/Controls.DocumentViewer/My Project/AssemblyInfo.vb @@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices - - + + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Controls.DocumentViewer/My Project/Settings.Designer.vb b/Controls.DocumentViewer/My Project/Settings.Designer.vb index 08d06809..c104f696 100644 --- a/Controls.DocumentViewer/My Project/Settings.Designer.vb +++ b/Controls.DocumentViewer/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/Controls.LookupGrid/LookupControl.vbproj b/Controls.LookupGrid/LookupControl.vbproj index adf9b550..31d7357d 100644 --- a/Controls.LookupGrid/LookupControl.vbproj +++ b/Controls.LookupGrid/LookupControl.vbproj @@ -10,7 +10,7 @@ DigitalData.Controls.LookupGrid 512 Windows - v4.8 + v4.6.2 diff --git a/Controls.LookupGrid/My Project/Settings.Designer.vb b/Controls.LookupGrid/My Project/Settings.Designer.vb index 9cb6d7be..5ce79aea 100644 --- a/Controls.LookupGrid/My Project/Settings.Designer.vb +++ b/Controls.LookupGrid/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/GUIs.ClipboardWatcher/ClipboardWatcher.vbproj b/GUIs.ClipboardWatcher/ClipboardWatcher.vbproj index 430bc363..65c8d8bf 100644 --- a/GUIs.ClipboardWatcher/ClipboardWatcher.vbproj +++ b/GUIs.ClipboardWatcher/ClipboardWatcher.vbproj @@ -10,7 +10,7 @@ DigitalData.GUIs.ClipboardWatcher 512 Windows - v4.8 + v4.6.2 diff --git a/GUIs.ClipboardWatcher/My Project/Settings.Designer.vb b/GUIs.ClipboardWatcher/My Project/Settings.Designer.vb index 5ea56273..fadcf464 100644 --- a/GUIs.ClipboardWatcher/My Project/Settings.Designer.vb +++ b/GUIs.ClipboardWatcher/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/GUIs.ClipboardWatcher/app.config b/GUIs.ClipboardWatcher/app.config index 8cd7d77d..f13a22ef 100644 --- a/GUIs.ClipboardWatcher/app.config +++ b/GUIs.ClipboardWatcher/app.config @@ -57,4 +57,4 @@ - + diff --git a/GUIs.Common/Common.vbproj b/GUIs.Common/Common.vbproj index 0a152c12..f497b7f8 100644 --- a/GUIs.Common/Common.vbproj +++ b/GUIs.Common/Common.vbproj @@ -10,7 +10,7 @@ DigitalData.GUIs.Common 512 Windows - v4.8 + v4.6.2 diff --git a/GUIs.Common/My Project/AssemblyInfo.vb b/GUIs.Common/My Project/AssemblyInfo.vb index 98ed3f4e..58af0811 100644 --- a/GUIs.Common/My Project/AssemblyInfo.vb +++ b/GUIs.Common/My Project/AssemblyInfo.vb @@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices - - + + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/GUIs.Common/My Project/Settings.Designer.vb b/GUIs.Common/My Project/Settings.Designer.vb index d4814251..aebc86e6 100644 --- a/GUIs.Common/My Project/Settings.Designer.vb +++ b/GUIs.Common/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/GUIs.Common/app.config b/GUIs.Common/app.config index 62c7d3c0..bf89aeae 100644 --- a/GUIs.Common/app.config +++ b/GUIs.Common/app.config @@ -53,4 +53,4 @@ - + diff --git a/GUIs.GlobalIndexer/GlobalIndexer.vbproj b/GUIs.GlobalIndexer/GlobalIndexer.vbproj index 4168c5d4..e9eaf094 100644 --- a/GUIs.GlobalIndexer/GlobalIndexer.vbproj +++ b/GUIs.GlobalIndexer/GlobalIndexer.vbproj @@ -10,7 +10,7 @@ DigitalData.GUIs.GlobalIndexer 512 Windows - v4.8 + v4.6.2 true diff --git a/GUIs.GlobalIndexer/My Project/Settings.Designer.vb b/GUIs.GlobalIndexer/My Project/Settings.Designer.vb index 1660b0bb..0cd6cd67 100644 --- a/GUIs.GlobalIndexer/My Project/Settings.Designer.vb +++ b/GUIs.GlobalIndexer/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/GUIs.Test.TestGUI/App.config b/GUIs.Test.TestGUI/App.config index d0f7e844..d9614f15 100644 --- a/GUIs.Test.TestGUI/App.config +++ b/GUIs.Test.TestGUI/App.config @@ -6,7 +6,7 @@ - + diff --git a/GUIs.Test.TestGUI/My Project/Resources.Designer.vb b/GUIs.Test.TestGUI/My Project/Resources.Designer.vb index cd2e2168..6d281b27 100644 --- a/GUIs.Test.TestGUI/My Project/Resources.Designer.vb +++ b/GUIs.Test.TestGUI/My Project/Resources.Designer.vb @@ -22,7 +22,7 @@ Namespace My.Resources ''' ''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. ''' - _ diff --git a/GUIs.Test.TestGUI/My Project/Settings.Designer.vb b/GUIs.Test.TestGUI/My Project/Settings.Designer.vb index 2fc680a8..c4297d73 100644 --- a/GUIs.Test.TestGUI/My Project/Settings.Designer.vb +++ b/GUIs.Test.TestGUI/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/GUIs.Test.TestGUI/TestGUI.vbproj b/GUIs.Test.TestGUI/TestGUI.vbproj index 66208b76..0a226bdf 100644 --- a/GUIs.Test.TestGUI/TestGUI.vbproj +++ b/GUIs.Test.TestGUI/TestGUI.vbproj @@ -11,7 +11,7 @@ TestGUI 512 WindowsForms - v4.7.2 + v4.6.2 true @@ -109,7 +109,7 @@ ..\packages\NLog.5.0.5\lib\net46\NLog.dll - ..\packages\Quartz.3.5.0\lib\net472\Quartz.dll + ..\packages\Quartz.3.5.0\lib\net462\Quartz.dll diff --git a/GUIs.Test.TestGUI/packages.config b/GUIs.Test.TestGUI/packages.config index bf432ae4..b7736126 100644 --- a/GUIs.Test.TestGUI/packages.config +++ b/GUIs.Test.TestGUI/packages.config @@ -2,7 +2,7 @@ - + diff --git a/GUIs.Test.ZUGFeRDTest/App.config b/GUIs.Test.ZUGFeRDTest/App.config index b9eee8df..f5e56d48 100644 --- a/GUIs.Test.ZUGFeRDTest/App.config +++ b/GUIs.Test.ZUGFeRDTest/App.config @@ -9,7 +9,7 @@ - + diff --git a/GUIs.Test.ZUGFeRDTest/Form1.vb b/GUIs.Test.ZUGFeRDTest/Form1.vb index 91cb7341..23c94dd0 100644 --- a/GUIs.Test.ZUGFeRDTest/Form1.vb +++ b/GUIs.Test.ZUGFeRDTest/Form1.vb @@ -59,8 +59,8 @@ Public Class Form1 Return args End Function - Private Function LoadPropertyMapFor(Args As WorkerArgs, Specification As String) - Dim oSQL As String = $"SELECT * FROM TBEDM_XML_ITEMS WHERE SPECIFICATION = '{Specification}' AND ACTIVE = True ORDER BY XML_PATH" + Private Function LoadPropertyMapFor(Args As WorkerArgs) + Dim oSQL As String = $"SELECT * FROM TBEDM_XML_ITEMS WHERE ACTIVE = True ORDER BY XML_PATH" Dim oResult As DataTable = _firebird.GetDatatable(oSQL) For Each oRow As DataRow In oResult.Rows @@ -71,6 +71,7 @@ Public Class Form1 Dim isRequired = oRow.Item("IS_REQUIRED") Dim isGrouped = oRow.Item("IS_GROUPED") Dim groupScope = oRow.Item("GROUP_SCOPE") + Dim specification = oRow.Item("SPECIFICATION") Args.PropertyMap.Add(xmlPath, New XmlItemProperty() With { .Description = description, @@ -78,7 +79,8 @@ Public Class Form1 .TableColumn = tableColumn, .IsRequired = isRequired, .IsGrouped = isGrouped, - .GroupScope = groupScope + .GroupScope = groupScope, + .Specification = specification }) Next @@ -92,10 +94,10 @@ Public Class Form1 .NamePortal = "TEST FROM FORM" } args = LoadFolderConfig(args) - args = LoadPropertyMapFor(args, "DEFAULT") + args = LoadPropertyMapFor(args) args.InsertIntoSQLServer = True - Dim job As New Jobs.ImportZUGFeRDFiles(_logConfig, _firebird, 1, "TEST", _mssql) + Dim job As New Jobs.ImportZUGFeRDFiles(_logConfig, _firebird, _mssql) job.Start(args) End Sub @@ -115,19 +117,45 @@ Public Class Form1 End If End Sub + Public Sub WriteLog(pMessage As String, ParamArray pParams As String()) + ListBox1.Items.Add(String.Format(pMessage, pParams)) + End Sub + Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click - Dim oResult = OpenFileDialog1.ShowDialog() + Dim oDialogResult = OpenFileDialog1.ShowDialog() Dim oArgs As New WorkerArgs() - oArgs = LoadPropertyMapFor(oArgs, "DEFAULT") + oArgs = LoadPropertyMapFor(oArgs) - If oResult = DialogResult.OK Then + If oDialogResult = DialogResult.OK Then Dim oDoc = _zugferd.ValidateZUGFeRDFileWithGDPicture(OpenFileDialog1.FileName) - Dim oZUGFERD = _zugferd.SerializeZUGFeRDDocument(oDoc) - Console.WriteLine() + Dim oResult = _zugferd.SerializeZUGFeRDDocument(oDoc) - Dim oResult2 = _zugferd.PropertyValues.CheckPropertyValues(oZUGFERD, oArgs.PropertyMap, "test") + WriteLog("Specification: " & oResult.Specification) + WriteLog("Embedded File Name: " & oResult.DataFileName) - Console.WriteLine() + Dim oSpecification = oResult.Specification + + If oSpecification = ZUGFeRDInterface.ZUGFERD_SPEC_10 Then + oSpecification = ZUGFeRDInterface.ZUGFERD_SPEC_DEFAULT + End If + + Dim oPropertyMap = oArgs.PropertyMap. + Where(Function(kv) kv.Value.Specification = oSpecification). + ToDictionary(Function(kv) kv.Key, Function(kv) kv.Value) + + Dim oResult2 = _zugferd.PropertyValues.CheckPropertyValues(oResult.SchemaObject, oPropertyMap, "test") + + WriteLog("Valid Properties: [{0}]", oResult2.ValidProperties.Count) + For Each Prop In oResult2.ValidProperties + WriteLog("Property: [{0}] = [{1}]", Prop.Description, Prop.Value) + Next + + WriteLog("Missing Properties: [{0}]", oResult2.MissingProperties.Count) + For Each Prop In oResult2.MissingProperties + WriteLog("Missing Property: [{0}]", Prop) + Next + + WriteLog("--------------------------------") End If End Sub diff --git a/GUIs.Test.ZUGFeRDTest/My Project/Settings.Designer.vb b/GUIs.Test.ZUGFeRDTest/My Project/Settings.Designer.vb index 124edc9e..09e1823e 100644 --- a/GUIs.Test.ZUGFeRDTest/My Project/Settings.Designer.vb +++ b/GUIs.Test.ZUGFeRDTest/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj b/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj index 20736e98..8853d80a 100644 --- a/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj +++ b/GUIs.Test.ZUGFeRDTest/ZUGFeRDTest.vbproj @@ -11,7 +11,7 @@ ZUGFeRDTest 512 WindowsForms - v4.8 + v4.6.2 true @@ -48,7 +48,7 @@ On - + False ..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll @@ -68,15 +68,14 @@ ..\packages\FirebirdSql.Data.FirebirdClient.7.5.0\lib\net452\FirebirdSql.Data.FirebirdClient.dll - - ..\packages\NLog.4.7.10\lib\net45\NLog.dll + + ..\packages\NLog.5.1.0\lib\net46\NLog.dll - diff --git a/GUIs.Test.ZUGFeRDTest/packages.config b/GUIs.Test.ZUGFeRDTest/packages.config index f5252b7d..068365d4 100644 --- a/GUIs.Test.ZUGFeRDTest/packages.config +++ b/GUIs.Test.ZUGFeRDTest/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/Services.EmailService/App.config b/Services.EmailService/App.config index e773d4eb..c5280b07 100644 --- a/Services.EmailService/App.config +++ b/Services.EmailService/App.config @@ -3,7 +3,7 @@ - + diff --git a/Services.EmailService/Config.vb b/Services.EmailService/Config.vb index 7542cafe..b1cd2d4a 100644 --- a/Services.EmailService/Config.vb +++ b/Services.EmailService/Config.vb @@ -16,4 +16,13 @@ Public Class Config Public Property SQLServerTestConnectionString As String = "" Public Property Debug As Boolean = False + + Public Class TlsConfig + Public Property EnableDefault As Boolean = True + Public Property EnableTls1_1 As Boolean = False + Public Property EnableTls1_2 As Boolean = False + End Class + + + Public Property TlsVersion As New TlsConfig End Class diff --git a/Services.EmailService/DDEmailService.vbproj b/Services.EmailService/DDEmailService.vbproj index 43eae557..0d4b5809 100644 --- a/Services.EmailService/DDEmailService.vbproj +++ b/Services.EmailService/DDEmailService.vbproj @@ -11,7 +11,7 @@ DDEmailService 512 Console - v4.8 + v4.6.2 true diff --git a/Services.EmailService/EmailService.vb b/Services.EmailService/EmailService.vb index 430ecbd7..0b2935b7 100644 --- a/Services.EmailService/EmailService.vb +++ b/Services.EmailService/EmailService.vb @@ -348,7 +348,13 @@ Public Class EmailService ' ======= Connect to server ======= - Dim oResult = _MailSender.ConnectToServer(oAccount.Server, oAccount.Port, oAccount.Username, oAccount.Password, oAccount.AuthType) + Dim oOptions As New MailSender.MailSenderOptions() With { + .EnableTls1_1 = _Config.TlsVersion.EnableTls1_1, + .EnableTls1_2 = _Config.TlsVersion.EnableTls1_2, + .EnableDefault = _Config.TlsVersion.EnableDefault + } + + Dim oResult = _MailSender.ConnectToServer(oAccount.Server, oAccount.Port, oAccount.Username, oAccount.Password, oAccount.AuthType, oOptions) If oResult = False Then _Logger.Warn("Could not connect to server. Skipping.") diff --git a/Services.EmailService/My Project/AssemblyInfo.vb b/Services.EmailService/My Project/AssemblyInfo.vb index 480c0e1a..5f4fafd8 100644 --- a/Services.EmailService/My Project/AssemblyInfo.vb +++ b/Services.EmailService/My Project/AssemblyInfo.vb @@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices - - + + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/Services.EmailService/My Project/Settings.Designer.vb b/Services.EmailService/My Project/Settings.Designer.vb index 79cbc909..a7bdc920 100644 --- a/Services.EmailService/My Project/Settings.Designer.vb +++ b/Services.EmailService/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/Services.LicenseService/App.config b/Services.LicenseService/App.config index 10680153..b3f62cde 100644 --- a/Services.LicenseService/App.config +++ b/Services.LicenseService/App.config @@ -11,4 +11,4 @@ - + diff --git a/Services.LicenseService/DDEDMLicenseService.vbproj b/Services.LicenseService/DDEDMLicenseService.vbproj index ae39f5e7..24f2898e 100644 --- a/Services.LicenseService/DDEDMLicenseService.vbproj +++ b/Services.LicenseService/DDEDMLicenseService.vbproj @@ -10,7 +10,7 @@ DDEDMLicenseService 512 Console - v4.8 + v4.6.2 True diff --git a/Services.LicenseService/My Project/Settings.Designer.vb b/Services.LicenseService/My Project/Settings.Designer.vb index 30df6fab..81d5952e 100644 --- a/Services.LicenseService/My Project/Settings.Designer.vb +++ b/Services.LicenseService/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/Services.ZUGFeRDService/App.config b/Services.ZUGFeRDService/App.config index e773d4eb..c5280b07 100644 --- a/Services.ZUGFeRDService/App.config +++ b/Services.ZUGFeRDService/App.config @@ -3,7 +3,7 @@ - + diff --git a/Services.ZUGFeRDService/Config.vb b/Services.ZUGFeRDService/Config.vb index 26f2b27e..12f30ca8 100644 --- a/Services.ZUGFeRDService/Config.vb +++ b/Services.ZUGFeRDService/Config.vb @@ -35,9 +35,10 @@ Public Property RejectionTransferTimeUnit As String = "HOUR" Public Property RejectionTransferTimeValue As Integer = 12 - Public Property AllowFacturX As Boolean = True - Public Property AllowXRechnung As Boolean = True - + Public Property AllowFacturX As Boolean = False + Public Property AllowXRechnung As Boolean = False + Public Property AllowZugferd10 As Boolean = True + Public Property AllowZugferd2x As Boolean = True End Class Public Class FirebirdConfig diff --git a/Services.ZUGFeRDService/DDZUGFeRDService.vbproj b/Services.ZUGFeRDService/DDZUGFeRDService.vbproj index da87b4e4..d8b84fbe 100644 --- a/Services.ZUGFeRDService/DDZUGFeRDService.vbproj +++ b/Services.ZUGFeRDService/DDZUGFeRDService.vbproj @@ -11,7 +11,7 @@ DDZUGFeRDService 512 Console - v4.8 + v4.6.2 true diff --git a/Services.ZUGFeRDService/My Project/AssemblyInfo.vb b/Services.ZUGFeRDService/My Project/AssemblyInfo.vb index 708a09eb..bf801f77 100644 --- a/Services.ZUGFeRDService/My Project/AssemblyInfo.vb +++ b/Services.ZUGFeRDService/My Project/AssemblyInfo.vb @@ -12,8 +12,8 @@ Imports System.Runtime.InteropServices - - + + @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Services.ZUGFeRDService/My Project/Settings.Designer.vb b/Services.ZUGFeRDService/My Project/Settings.Designer.vb index 4f688893..73fbe196 100644 --- a/Services.ZUGFeRDService/My Project/Settings.Designer.vb +++ b/Services.ZUGFeRDService/My Project/Settings.Designer.vb @@ -15,7 +15,7 @@ Option Explicit On Namespace My _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase diff --git a/Services.ZUGFeRDService/ThreadRunner.vb b/Services.ZUGFeRDService/ThreadRunner.vb index 8897e943..7b6ee427 100644 --- a/Services.ZUGFeRDService/ThreadRunner.vb +++ b/Services.ZUGFeRDService/ThreadRunner.vb @@ -53,11 +53,13 @@ Public Class ThreadRunner .NamePortal = _config.Config.PORTAL_NAME, .EmailOutProfileId = _config.Config.MSSQLEmailOutAccountID, .AllowFacturX = _config.Config.Custom.AllowFacturX, - .AllowXRechnung = _config.Config.Custom.AllowXRechnung + .AllowXRechnung = _config.Config.Custom.AllowXRechnung, + .AllowZugferd10 = _config.Config.Custom.AllowZugferd10, + .AllowZugferd2x = _config.Config.Custom.AllowZugferd2x } oArgs = LoadFolderConfig(oArgs) - oArgs = LoadPropertyMapFor(oArgs, "DEFAULT") + oArgs = LoadPropertyMap(oArgs) ' Use MSSQL Server if available If Not IsNothing(_mssql) Then @@ -243,18 +245,19 @@ Public Class ThreadRunner Return pArgs End Function - Private Function LoadPropertyMapFor(pArgs As WorkerArgs, pSpecification As String) As WorkerArgs - Dim oSQL As String = $"SELECT * FROM TBEDM_XML_ITEMS WHERE SPECIFICATION = '{pSpecification}' AND ACTIVE = True ORDER BY XML_PATH" - Dim oResult As DataTable = _firebird.GetDatatable(oSQL) + Private Function LoadPropertyMap(pArgs As WorkerArgs) As WorkerArgs + Dim oSQL As String = $"SELECT * FROM TBEDM_XML_ITEMS WHERE ACTIVE = True ORDER BY XML_PATH" + Dim oResult As DataTable = _firebird.GetDatatable(oSQL) - For Each row As DataRow In oResult.Rows - Dim oXmlPath = row.Item("XML_PATH") - Dim oTableName = row.Item("TABLE_NAME") - Dim oTableColumn = row.Item("TABLE_COLUMN") - Dim oDescription = row.Item("DESCRIPTION") - Dim oIsRequired = row.Item("IS_REQUIRED") - Dim oIsGrouped = row.Item("IS_GROUPED") - Dim oGroupScope = row.Item("GROUP_SCOPE") + For Each oRow As DataRow In oResult.Rows + Dim oXmlPath = oRow.Item("XML_PATH") + Dim oTableName = oRow.Item("TABLE_NAME") + Dim oTableColumn = oRow.Item("TABLE_COLUMN") + Dim oDescription = oRow.Item("DESCRIPTION") + Dim oIsRequired = oRow.Item("IS_REQUIRED") + Dim oIsGrouped = oRow.Item("IS_GROUPED") + Dim oGroupScope = oRow.Item("GROUP_SCOPE") + Dim oSpecification = oRow.Item("SPECIFICATION") pArgs.PropertyMap.Add(oXmlPath, New XmlItemProperty() With { .Description = oDescription, @@ -262,7 +265,8 @@ Public Class ThreadRunner .TableColumn = oTableColumn, .IsRequired = oIsRequired, .IsGrouped = oIsGrouped, - .GroupScope = oGroupScope + .GroupScope = oGroupScope, + .Specification = oSpecification }) Next diff --git a/WEBSERVICES/ZUGFeRDRESTService/Config.cs b/WEBSERVICES/ZUGFeRDRESTService/Config.cs index f9734783..cd90e496 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/Config.cs +++ b/WEBSERVICES/ZUGFeRDRESTService/Config.cs @@ -5,10 +5,20 @@ public string Name { get; set; } public string LogPath { get; set; } public string MSSQLConnectionString { get; set; } - + public string MaxFileSizeInMegabytes { get; set; } + public ZugferdConfig Zugferd { get; set; } public FirebirdConfig Firebird { get; set; } } + public class ZugferdConfig + { + public bool AllowFacturX { get; set; } = false; + public bool AllowXRechnung { get; set; } = false; + public bool AllowZugferd10 { get; set; } = true; + public bool AllowZugferd2x { get; set; } = true; + + } + public class FirebirdConfig { public string Datasource { get; set; } diff --git a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs index 77299759..841f70dc 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs +++ b/WEBSERVICES/ZUGFeRDRESTService/Controllers/ValidationController.cs @@ -9,6 +9,7 @@ using static DigitalData.Modules.Interfaces.Exceptions; using static DigitalData.Modules.Interfaces.ZUGFeRDInterface; using static DigitalData.Modules.Interfaces.PropertyValues; using System.Data.SqlClient; +using Microsoft.Extensions.Configuration; namespace ZUGFeRDRESTService.Controllers { @@ -22,19 +23,29 @@ namespace ZUGFeRDRESTService.Controllers public const string ADDED_WHO = "ZUGFeRD REST Service"; public const string MESSAGEID_DOMAIN = "test.wisag.de"; + private const int MAX_FILE_SIZE_DEFAULT = 25; + private readonly ZUGFeRDInterface _zugferd; private readonly IDatabase _database; private readonly DigitalData.Modules.Logging.LogConfig _logConfig; private readonly DigitalData.Modules.Logging.Logger _logger; + private readonly DigitalData.Modules.Filesystem.File _file; private readonly PropertyValues _props; - private readonly Dictionary _propertyMap; + private readonly Dictionary _propertyMap = new Dictionary(); - public ValidationController(ILogging logging, IDatabase database) + private int _MaxFileSizeInMegabytes; + private bool _AllowFacturX; + private bool _AllowXRechnung; + private bool _AllowZugferd2x; + private bool _AllowZugferd10; + + public ValidationController(ILogging logging, IDatabase database, IConfiguration Config) { _logConfig = logging.LogConfig; _logger = _logConfig.GetLogger(); + _file = new DigitalData.Modules.Filesystem.File(_logConfig); _logger.Debug("Validation Controller initializing"); @@ -42,14 +53,75 @@ namespace ZUGFeRDRESTService.Controllers var oGDPictureKey = database.GetGDPictureKey(); var oPropertyMap = database.GetPropertyMap(); - _propertyMap = oPropertyMap; + // Read config file and assign all option flags related to + // - Zugferd files + // - Filesizes + ParseConfig(Config); - _zugferd = new ZUGFeRDInterface(_logConfig, oGDPictureKey); + _zugferd = new ZUGFeRDInterface(_logConfig, oGDPictureKey, new ZugferdOptions() + { + AllowFacturX_Filename = _AllowFacturX, + AllowXRechnung_Filename = _AllowXRechnung, + AllowZugferd_1_0_Schema = _AllowZugferd10, + AllowZugferd_2_x_Schema = _AllowZugferd2x + }); _props = new PropertyValues(_logConfig); + _logger.Debug("Property Map initial: [{0}] entries found.", oPropertyMap.Count); + + if (_AllowZugferd10 == true) + _propertyMap = oPropertyMap. + Where(kv => kv.Value.Specification == ZUGFERD_SPEC_10 || kv.Value.Specification == ZUGFERD_SPEC_DEFAULT). + Concat(_propertyMap). + ToDictionary(kv => kv.Key, kv => kv.Value); + + if (_AllowZugferd2x == true) + _propertyMap = oPropertyMap. + Where(kv => kv.Value.Specification == ZUGFERD_SPEC_2x). + Concat(_propertyMap). + ToDictionary(kv => kv.Key, kv => kv.Value); + + _logger.Debug("Property Map filtered: [{0}] entries found.", _propertyMap.Count); + _logger.Debug("Validation Controller initialized!"); } + private void ParseConfig(IConfiguration Config) + { + var oAppConfig = Config.GetSection("Config"); + var oZugferdConfig = oAppConfig.GetSection("Zugferd"); + + if (!bool.TryParse(oZugferdConfig["AllowFacturX"], out _AllowFacturX)) + { + _logger.Info("Configuration AllowFacturX was not set. Using default value [{0}]", false); + _AllowFacturX = false; + } + + if (!bool.TryParse(oZugferdConfig["AllowXRechnung"], out _AllowXRechnung)) + { + _logger.Info("Configuration AllowXRechnung was not set. Using default value [{0}]", false); + _AllowXRechnung = false; + } + + if (!bool.TryParse(oZugferdConfig["AllowZugferd2x"], out _AllowZugferd2x)) + { + _logger.Info("Configuration Zugferd2x was not set. Using default value [{0}]", false); + _AllowZugferd2x = false; + } + + if (!bool.TryParse(oZugferdConfig["AllowZugferd10"], out _AllowZugferd10)) + { + _logger.Info("Configuration Zugferd10 was not set. Using default value [{0}]", true); + _AllowZugferd10 = true; + } + + if (!int.TryParse(oAppConfig["MaxFileSizeInMegabytes"], out _MaxFileSizeInMegabytes)) + { + _logger.Info("Configuration MaxFileSizeInMegabytes was not set. Using default value [{0}]", MAX_FILE_SIZE_DEFAULT); + _MaxFileSizeInMegabytes = MAX_FILE_SIZE_DEFAULT; + } + } + /// /// POST: /api/validation /// @@ -60,43 +132,66 @@ namespace ZUGFeRDRESTService.Controllers { _logger.Info("Start processing request to ValidationController"); - object oDocument; - PropertyValues.CheckPropertyValuesResult oResult = new PropertyValues.CheckPropertyValuesResult(); + ZugferdResult oZugferdResult; + CheckPropertyValuesResult oPropertyResult = new CheckPropertyValuesResult(); try { using Stream oStream = file.OpenReadStream(); { + _logger.Info("Checking Filesize of file [{0}]", file.FileName); + + long maxFileSize = _MaxFileSizeInMegabytes * 1024 * 1024; + bool oFileSizeIsOK = file.Length < maxFileSize; + + if (oFileSizeIsOK == false) + { + throw new ZUGFeRDExecption(ErrorType.FileTooBig, "FileTooBig"); + } + _logger.Info("Extracting ZUGFeRD Data from file [{0}]", file.FileName); - oDocument = _zugferd.ExtractZUGFeRDFileWithGDPicture(oStream); + oZugferdResult = _zugferd.ExtractZUGFeRDFileWithGDPicture(oStream); + _logger.Info("Detected Specification was: [{0}]", oZugferdResult.Specification); + + var oFilteredPropertyMap = _zugferd.FilterPropertyMap(_propertyMap, oZugferdResult.Specification); + + if (oFilteredPropertyMap.Count == 0) + { + _logger.Warn("No properties found in property map for specification [{0}]", oZugferdResult.Specification); + throw new ZUGFeRDExecption(ErrorType.UnsupportedFormat, "Unsupported Format"); + } + else + { + _logger.Debug("Property map contains [{0}] entries for specification [{1}]", oFilteredPropertyMap.Count, oZugferdResult.Specification); + } + _logger.Info("Starting structural check against the database."); - oResult = _props.CheckPropertyValues(oDocument, _propertyMap, "MESSAGEID"); + oPropertyResult = _props.CheckPropertyValues(oZugferdResult.SchemaObject, oFilteredPropertyMap, "MESSAGEID"); - var oRequiredProperties = _propertyMap. + var oRequiredProperties = oFilteredPropertyMap. Where(prop => { return prop.Value.IsRequired == true; }). - Select(prop => { return prop.Value.Description; }) - .ToList(); + Select(prop => { return prop.Value.Description; }). + ToList(); _logger.Debug("Found [{0}] required properties", oRequiredProperties.Count); _logger.Debug(string.Join(",", oRequiredProperties.ToArray())); _logger.Info("Result of checking against the database: {0} valid properties, {1} missing properties", - oResult.ValidProperties.Count, oResult.MissingProperties.Count); + oPropertyResult.ValidProperties.Count, oPropertyResult.MissingProperties.Count); - if (oResult.MissingProperties.Count > 0) + if (oPropertyResult.MissingProperties.Count > 0) { - throw new ZUGFeRDExecption(ErrorType.MissingProperties, - "Die hochgeladene Datei ist eine gültige ZUGFeRD-Rechnung, allerdings fehlen benötigte Daten."); + throw new ZUGFeRDExecption(ErrorType.MissingProperties, "Missing Properties"); } - Tuple oValidateResult = ValidateBuyerOrderReference(oResult.ValidProperties); + Tuple oValidateResult = ValidateBuyerOrderReference(oPropertyResult.ValidProperties); if (oValidateResult.Item1 == false) { - throw new ZUGFeRDExecption(ErrorType.UnknownError, "Die hochgeladene Datei kann nicht validiert werden, weil ein unbekannter Fehler aufgetreten ist."); + throw new ZUGFeRDExecption(ErrorType.UnknownError, "Unknown Error"); } string oValidateResultString = oValidateResult.Item2; @@ -136,7 +231,9 @@ namespace ZUGFeRDRESTService.Controllers ErrorType.NoValidFile => "Die hochgeladene Datei ist keine gültige Datei.", ErrorType.NoZugferd => "Die hochgeladene Datei ist keine ZUGFeRD-Rechnung.", ErrorType.NoValidZugferd => "Die hochgeladene Datei ist keine gültige ZUGFeRD-Rechnung.", - ErrorType.MissingProperties => "Die hochgeladene Datei ist keine gültige ZUGFeRD-Rechnung, es fehlen einige Metadaten", + ErrorType.MissingProperties => "Die hochgeladene Datei ist keine gültige ZUGFeRD-Rechnung, es fehlen einige Metadaten.", + ErrorType.FileTooBig => string.Format("Die hochgeladene Datei überschreitet die zulässige Dateigröße [{0}].", _MaxFileSizeInMegabytes), + ErrorType.UnsupportedFormat => "Die hochgeladene Datei enthält ein falsches oder nicht unterstütztes ZUGFeRD Format.", _ => "Die hochgeladene Datei kann nicht validiert werden.", }; @@ -144,7 +241,7 @@ namespace ZUGFeRDRESTService.Controllers List oErrors = ex.ErrorType switch { // Errors contains the list of missing fields - ErrorType.MissingProperties => oResult.MissingProperties, + ErrorType.MissingProperties => oPropertyResult.MissingProperties, _ => new List() }; @@ -239,7 +336,7 @@ namespace ZUGFeRDRESTService.Controllers new SqlParameter("@CREATEDWHO", ADDED_WHO), new SqlParameter("@GROUP_COUNTER", pProperty.GroupCounter), new SqlParameter("@SPEC_NAME", pProperty.TableColumn), - new SqlParameter("@IS_REQUIRED", pProperty.ISRequired) + new SqlParameter("@IS_REQUIRED", pProperty.IsRequired) }; var oCommand = new SqlCommand(oSql); diff --git a/WEBSERVICES/ZUGFeRDRESTService/Database.cs b/WEBSERVICES/ZUGFeRDRESTService/Database.cs index 31f56346..ac19132a 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/Database.cs +++ b/WEBSERVICES/ZUGFeRDRESTService/Database.cs @@ -14,11 +14,12 @@ namespace ZUGFeRDRESTService { public class Database: IDatabase { + private DigitalData.Modules.Logging.Logger _Logger = null; private string _gdPictureKey = null; private Dictionary _propertyMap = null; private const string QUERY_GET_GDPICTURE_KEY = "SELECT LICENSE FROM TBDD_3RD_PARTY_MODULES WHERE NAME = 'GDPICTURE'"; - private const string QUERY_GET_PROPERTY_MAP = "SELECT * FROM TBEDM_XML_ITEMS WHERE SPECIFICATION = '{0}' AND ACTIVE = True ORDER BY XML_PATH"; + private const string QUERY_GET_PROPERTY_MAP = "SELECT * FROM TBEDM_XML_ITEMS WHERE ACTIVE = True ORDER BY XML_PATH"; public MSSQLServer MSSQL { get; set; } public Firebird Firebird { get; set; } @@ -42,6 +43,8 @@ namespace ZUGFeRDRESTService oLogger.Debug("MSSQL Connection: [{0}]", MSSQL.CurrentConnectionString); oLogger.Debug("Firebird Connection: [{0}]", Firebird.ConnectionString); + + _Logger = oLogger; } public string GetGDPictureKey() @@ -52,12 +55,16 @@ namespace ZUGFeRDRESTService return _gdPictureKey; } - public Dictionary GetPropertyMap() + public Dictionary GetPropertyMap() { if (_propertyMap == null) { + _Logger.Debug("Property map does not exist, creating."); + _propertyMap = new Dictionary(); - var oDatatable = Firebird.GetDatatable(string.Format(QUERY_GET_PROPERTY_MAP, "DEFAULT")); + var oDatatable = Firebird.GetDatatable(QUERY_GET_PROPERTY_MAP); + + _Logger.Debug("Datatable Rows: [{0}]", oDatatable.Rows); foreach (DataRow oRow in oDatatable.Rows) { @@ -68,10 +75,16 @@ namespace ZUGFeRDRESTService TableColumn = oRow["TABLE_COLUMN"].ToString(), GroupScope = oRow["GROUP_SCOPE"].ToString(), IsRequired = (bool)oRow["IS_REQUIRED"], - IsGrouped = (bool)oRow["IS_GROUPED"] + IsGrouped = (bool)oRow["IS_GROUPED"], + Specification = oRow["SPECIFICATION"].ToString() }); } - } + } else + { + _Logger.Debug("Property map already exists, returning."); + } + + _Logger.Debug("Returning Property Map with [{0}] entries.", _propertyMap.Count); return _propertyMap; } diff --git a/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj b/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj index 311cfff2..15d1c7eb 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj +++ b/WEBSERVICES/ZUGFeRDRESTService/ZUGFeRDRESTService.csproj @@ -21,6 +21,9 @@ ..\..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll + + ..\..\..\DDModules\Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll + ..\..\..\DDModules\Interfaces\bin\Debug\DigitalData.Modules.Interfaces.dll diff --git a/WEBSERVICES/ZUGFeRDRESTService/appsettings.json b/WEBSERVICES/ZUGFeRDRESTService/appsettings.json index 2d200b5a..bff970a1 100644 --- a/WEBSERVICES/ZUGFeRDRESTService/appsettings.json +++ b/WEBSERVICES/ZUGFeRDRESTService/appsettings.json @@ -17,6 +17,13 @@ "Database": ":", "Username": "", "Password": "" - } + }, + "Zugferd": { + "AllowZugferd10": true, + "AllowZugferd2x": false, + "AllowFacturX": false, + "AllowXRechnung": false + }, + "MaxFileSizeInMegabytes": 25 } }