From 3fcb0324c853b88437bb974b9c2e3817795a7342 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 18 Sep 2023 09:56:39 +0200 Subject: [PATCH] zugferd test --- GUIs.Test.ZUGFeRDTest/Form1.Designer.vb | 14 +-- GUIs.Test.ZUGFeRDTest/Form1.resx | 3 + GUIs.Test.ZUGFeRDTest/Form1.vb | 114 ++++++++++-------------- 3 files changed, 50 insertions(+), 81 deletions(-) diff --git a/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb b/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb index 42e34114..3379288a 100644 --- a/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb +++ b/GUIs.Test.ZUGFeRDTest/Form1.Designer.vb @@ -29,7 +29,6 @@ Partial Class Form1 Me.Button3 = New System.Windows.Forms.Button() Me.Button4 = New System.Windows.Forms.Button() Me.txtMD5Checksum = New System.Windows.Forms.TextBox() - Me.Button5 = New System.Windows.Forms.Button() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.GroupBox2 = New System.Windows.Forms.GroupBox() Me.Button7 = New System.Windows.Forms.Button() @@ -37,6 +36,7 @@ Partial Class Form1 Me.txtPropName = New System.Windows.Forms.TextBox() Me.GroupBox4 = New System.Windows.Forms.GroupBox() Me.Button6 = New System.Windows.Forms.Button() + Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog() Me.GroupBox1.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.GroupBox3.SuspendLayout() @@ -100,19 +100,9 @@ Partial Class Form1 Me.txtMD5Checksum.TabIndex = 5 Me.txtMD5Checksum.Text = Global.ZUGFeRDTest.My.MySettings.Default.MD5Cheksum ' - 'Button5 - ' - Me.Button5.Location = New System.Drawing.Point(6, 48) - Me.Button5.Name = "Button5" - Me.Button5.Size = New System.Drawing.Size(221, 23) - Me.Button5.TabIndex = 6 - Me.Button5.Text = "Open Input Folder" - Me.Button5.UseVisualStyleBackColor = True - ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.Button1) - Me.GroupBox1.Controls.Add(Me.Button5) Me.GroupBox1.Location = New System.Drawing.Point(12, 12) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(360, 92) @@ -208,7 +198,6 @@ Partial Class Form1 Friend WithEvents Button3 As Button Friend WithEvents Button4 As Button Friend WithEvents txtMD5Checksum As TextBox - Friend WithEvents Button5 As Button Friend WithEvents GroupBox1 As GroupBox Friend WithEvents GroupBox2 As GroupBox Friend WithEvents GroupBox3 As GroupBox @@ -216,4 +205,5 @@ Partial Class Form1 Friend WithEvents GroupBox4 As GroupBox Friend WithEvents Button6 As Button Friend WithEvents Button7 As Button + Friend WithEvents FolderBrowserDialog1 As FolderBrowserDialog End Class diff --git a/GUIs.Test.ZUGFeRDTest/Form1.resx b/GUIs.Test.ZUGFeRDTest/Form1.resx index 33c7f672..038d372b 100644 --- a/GUIs.Test.ZUGFeRDTest/Form1.resx +++ b/GUIs.Test.ZUGFeRDTest/Form1.resx @@ -120,4 +120,7 @@ 17, 17 + + 159, 17 + \ No newline at end of file diff --git a/GUIs.Test.ZUGFeRDTest/Form1.vb b/GUIs.Test.ZUGFeRDTest/Form1.vb index 01a70351..0714d37b 100644 --- a/GUIs.Test.ZUGFeRDTest/Form1.vb +++ b/GUIs.Test.ZUGFeRDTest/Form1.vb @@ -12,6 +12,7 @@ Imports DigitalData.Modules.Logging Public Class Form1 Private _logConfig As LogConfig + Private _logger As Logger Private _firebird As Firebird Private _mssql As MSSQLServer Private _zugferd As ZUGFeRDInterface @@ -23,82 +24,61 @@ Public Class Form1 _logConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath & "\Log", Nothing, My.Application.Info.CompanyName, My.Application.Info.ProductName) With { .Debug = True } + _logger = _logConfig.GetLogger() _mssql = New MSSQLServer(_logConfig, My.Settings.MSSQL_CONNECTIONSTRING) _zugferd = New ZUGFeRDInterface(_logConfig, "21182889975216572111813147150675976632") End Sub - Private Function LoadFolderConfig(args As WorkerArgs) - Dim oSQL As String = "SELECT T1.FOLDER_TYPE, T.FOLDER_PATH FROM TBEDM_FOLDER T, TBEDM_FOLDER_TYPE T1 WHERE T.FOLDER_TYPE_ID = T1.GUID AND T1.""ACTIVE"" = True AND T.""ACTIVE"" = True" - Dim oResult As DataTable = _firebird.GetDatatable(oSQL) - - For Each row As DataRow In oResult.Rows - Dim oFolderType = row.Item("FOLDER_TYPE") - - Select Case oFolderType - Case ZUGFERD_IN - args.WatchDirectory = row.Item("FOLDER_PATH") - - Case ZUGFERD_SUCCESS - args.SuccessDirectory = row.Item("FOLDER_PATH") - - Case ZUGFERD_ERROR - args.ErrorDirectory = row.Item("FOLDER_PATH") - - Case ZUGFERD_EML - args.OriginalEmailDirectory = row.Item("FOLDER_PATH") - - Case ZUGFERD_REJECTED_EML - args.RejectedEmailDirectory = row.Item("FOLDER_PATH") - - Case ZUGFERD_ATTACHMENTS - args.AttachmentsSubDirectory = row.Item("FOLDER_PATH") - End Select - Next - - Return args - End Function - 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 - Dim xmlPath = oRow.Item("XML_PATH") - Dim tableName = oRow.Item("TABLE_NAME") - Dim tableColumn = oRow.Item("TABLE_COLUMN") - Dim description = oRow.Item("DESCRIPTION") - 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, - .TableName = tableName, - .TableColumn = tableColumn, - .IsRequired = isRequired, - .IsGrouped = isGrouped, - .GroupScope = groupScope, - .Specification = specification - }) - Next - - Return Args + Try + Dim oSQL As String = $"SELECT * FROM TBDD_ZUGFERD_XML_ITEMS WHERE ACTIVE = 1 ORDER BY XML_PATH" + Dim oResult As DataTable = _mssql.GetDatatable(oSQL) + + For Each oRow As DataRow In oResult.Rows + Dim xmlPath = oRow.Item("XML_PATH") + Dim tableName = oRow.Item("TABLE_NAME") + Dim tableColumn = oRow.Item("TABLE_COLUMN") + Dim description = oRow.Item("DESCRIPTION") + 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, + .TableName = tableName, + .TableColumn = tableColumn, + .IsRequired = isRequired, + .IsGrouped = isGrouped, + .GroupScope = groupScope, + .Specification = specification + }) + Next + + Return Args + Catch ex As Exception + _Logger.Error(ex) + Return Args + End Try End Function Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click - Dim args As New WorkerArgs() With { - .MaxAttachmentSizeInMegaBytes = 10, - .IgnoreRejectionStatus = False, - .NamePortal = "TEST FROM FORM" - } - args = LoadFolderConfig(args) - args = LoadPropertyMapFor(args) + Dim oResult = FolderBrowserDialog1.ShowDialog() - Dim job As New Jobs.ImportZUGFeRDFiles(_logConfig, _mssql) + If oResult = DialogResult.OK Then + Dim args As New WorkerArgs() With { + .MaxAttachmentSizeInMegaBytes = 10, + .IgnoreRejectionStatus = False, + .NamePortal = "TEST FROM FORM", + .WatchDirectory = FolderBrowserDialog1.SelectedPath + } + args = LoadPropertyMapFor(args) - job.Start(args) + Dim job As New Jobs.ImportZUGFeRDFiles(_logConfig, _mssql) + + job.Start(args) + End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click @@ -192,10 +172,6 @@ Public Class Form1 End Try End Function - Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click - Process.Start("\\dd-sto01\DD-DFSR01\SharedObjects\Public\Projekte\Test\Import\ZUGFerD\Email_in") - End Sub - Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click Dim oResult = OpenFileDialog1.ShowDialog()