From a519b93f47cdd2eb09b490bef93265691dd8c30e Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Wed, 27 Oct 2021 10:32:04 +0200 Subject: [PATCH] WIP --- EDIDocumentImport/CREATE_DATABASE.sql | 89 +++++++++----- EDIDocumentImport/Exceptions.vb | 8 ++ EDIDocumentImport/FormHelpers.vb | 16 +++ EDIDocumentImport/GridLoader.vb | 17 ++- EDIDocumentImport/ImporterForm.vbproj | 1 + EDIDocumentImport/frmImportMain.Designer.vb | 37 ++++-- EDIDocumentImport/frmImportMain.vb | 100 +++++++++------- EDIDocumentImport/frmImportMain_old.vb | 7 +- EDIDocumentImport/frmRowEditor.vb | 18 ++- ImporterShared/Constants.vb | 8 ++ ImporterShared/Documents/Document.vb | 5 +- ImporterShared/Documents/DocumentLoader.vb | 124 ++++++++++++-------- ImporterShared/Documents/DocumentRow.vb | 1 + ImporterShared/Exceptions.vb | 49 ++++++++ ImporterShared/ImporterShared.vbproj | 2 + ImporterShared/Schemas/Schema.vb | 12 +- ImporterShared/Schemas/SchemaLoader.vb | 15 ++- ImporterShared/Winline/Configuration.vb | 7 ++ 18 files changed, 351 insertions(+), 165 deletions(-) create mode 100644 EDIDocumentImport/FormHelpers.vb create mode 100644 ImporterShared/Exceptions.vb create mode 100644 ImporterShared/Winline/Configuration.vb diff --git a/EDIDocumentImport/CREATE_DATABASE.sql b/EDIDocumentImport/CREATE_DATABASE.sql index 52dea87..d204484 100644 --- a/EDIDocumentImport/CREATE_DATABASE.sql +++ b/EDIDocumentImport/CREATE_DATABASE.sql @@ -82,7 +82,8 @@ CREATE TABLE [dbo].[TBEDI_XML_ITEMS]( [XML_NAME] [nvarchar](50) NOT NULL, [XML_NODE_ID] [int] NOT NULL, [XML_TYPE_ID] [int] NOT NULL, - [READ_ONLY] [bit] NOT NULL, + [IS_READ_ONLY] [bit] NOT NULL, + [IS_VISIBLE] [bit] NOT NULL, [FUNCTION_ID] [int] NULL ) ON [PRIMARY] GO @@ -96,8 +97,8 @@ ALTER TABLE [dbo].[TBEDI_XML_ITEMS] REFERENCES [dbo].[TBEDI_XML_ITEMS] (GUID) ALTER TABLE [dbo].[TBEDI_XML_ITEMS] - ADD CONSTRAINT DF_TBEDI_XML_ITEMS_READ_ONLY - DEFAULT 0 FOR READ_ONLY + ADD CONSTRAINT DF_TBEDI_XML_ITEMS_IS_READ_ONLY + DEFAULT 0 FOR IS_READ_ONLY DROP VIEW [dbo].[VWEDI_XML_ITEMS] @@ -114,7 +115,8 @@ AS ,[TBFUNCTIONS].[GUID] [FUNCTION_ID] ,[TBFUNCTIONS].[NAME] [FUNCTION_NAME] ,[TBFUNCTIONS].[PARAMETERS] [FUNCTION_PARAMETERS] - ,[TBITEMS].[READ_ONLY] + ,[TBITEMS].[IS_READ_ONLY] + ,[TBITEMS].[IS_VISIBLE] FROM [dbo].[TBEDI_XML_ITEMS] [TBITEMS] INNER JOIN [dbo].[TBEDI_XML_NODES] [TBNODES] ON [TBITEMS].[XML_NODE_ID] = [TBNODES].[GUID] @@ -127,33 +129,58 @@ GO /* Kopfdaten */ -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('BELEGKEY', 1, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Fakt_Kontonummer', 1, 1, 1, 1) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Laufnummer', 1, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Bestellt_von', 1, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Lief_Kontonummer', 1, 1, 1, 1) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Belegart', 1, 2, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Datum_Auftrag-Bestellung', 1, 3, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Auftrags-Bestellnummer', 1, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Leistungsdatum', 1, 3, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Infotext', 1, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('BELEGKEY', 1, 1, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Fakt_Kontonummer', 1, 1, 1, 1, 1) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Laufnummer', 1, 1, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Bestellt_von', 1, 1, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Lief_Kontonummer', 1, 1, 1, 1, 1) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Belegart', 1, 2, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Datum_Auftrag-Bestellung', 1, 3, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Auftrags-Bestellnummer', 1, 1, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Leistungsdatum', 1, 3, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Infotext', 1, 1, 1, 0, NULL) /* Positionsdaten */ -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('BELEGKEY', 2, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Zeilennummer', 2, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Datentyp', 2, 2, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Artikelnummer', 2, 1, 1, 2) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Bezeichnung', 2, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Lieferantenartikelnummer', 2, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Menge_bestellt', 2, 5, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Menge_geliefert', 2, 5, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Colli', 2, 1, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Einzelpreis', 2, 5, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Zeilenrabatt1', 2, 5, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Zeilenrabatt2', 2, 5, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Zeilenrabatt3', 2, 5, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Zeilenrabatt4', 2, 5, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('Umsatzsteuerprozent_Zeile', 2, 2, 1, NULL) -INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, READ_ONLY, FUNCTION_ID) VALUES ('EDI_Infotext', 2, 1, 1, NULL) - +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('BELEGKEY', 2, 1, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Zeilennummer', 2, 1, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Datentyp', 2, 2, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Artikelnummer', 2, 1, 1, 1, 2) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Bezeichnung', 2, 1, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Lieferantenartikelnummer', 2, 1, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Menge_bestellt', 2, 5, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Menge_geliefert', 2, 5, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Colli', 2, 1, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Einzelpreis', 2, 5, 1, 1, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Zeilenrabatt1', 2, 5, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Zeilenrabatt2', 2, 5, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Zeilenrabatt3', 2, 5, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Zeilenrabatt4', 2, 5, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('Umsatzsteuerprozent_Zeile', 2, 2, 1, 0, NULL) +INSERT [dbo].[TBEDI_XML_ITEMS] (XML_NAME, XML_NODE_ID, XML_TYPE_ID, IS_READ_ONLY, IS_VISIBLE, FUNCTION_ID) +VALUES ('EDI_Infotext', 2, 1, 1, 0, NULL) \ No newline at end of file diff --git a/EDIDocumentImport/Exceptions.vb b/EDIDocumentImport/Exceptions.vb index 9bd9be2..ac41eee 100644 --- a/EDIDocumentImport/Exceptions.vb +++ b/EDIDocumentImport/Exceptions.vb @@ -38,4 +38,12 @@ MyBase.New(message) End Sub End Class + + Public Class MalformedXmlException + Inherits ApplicationException + + Public Sub New(message As String) + MyBase.New(message) + End Sub + End Class End Class diff --git a/EDIDocumentImport/FormHelpers.vb b/EDIDocumentImport/FormHelpers.vb new file mode 100644 index 0000000..a34c7ce --- /dev/null +++ b/EDIDocumentImport/FormHelpers.vb @@ -0,0 +1,16 @@ +Imports DigitalData.Modules.Logging + +Public Class Message + Private Logger As Logger + + Public Sub New(pLogConfig As LogConfig) + Logger = pLogConfig.GetLogger() + End Sub + + Public Sub [Error](pException As Exception, pMessage As String) + Logger.Error(pException) + Dim oMessage As String = $"{pMessage}{vbNewLine}{vbNewLine}{pException.Message}" + MsgBox(oMessage, MsgBoxStyle.Critical, "Schwerwiegender Fehler") + End Sub + +End Class diff --git a/EDIDocumentImport/GridLoader.vb b/EDIDocumentImport/GridLoader.vb index 6baf1e7..5a9d199 100644 --- a/EDIDocumentImport/GridLoader.vb +++ b/EDIDocumentImport/GridLoader.vb @@ -18,9 +18,14 @@ Public Class GridLoader } Dim oInvisibleColumns As New List(Of String) From { - "Zeilennummer", "BELEGKEY", - "Infotext" + "Zeilennummer", + "Belegart", + "Infotext", + "Leistungsdatum", + "Projektnummer", + "Auftragsreferenz", + "Laufnummer" } oGrid.ForceInitialize() @@ -63,16 +68,16 @@ Public Class GridLoader Private Function GetColumnType(pColumn As Schemas.Schema.Column) Select Case pColumn.DataType - Case Schemas.Schema.ColumnType.Boolean + Case ImporterShared.Constants.ColumnType.Boolean Return DevExpress.Data.UnboundColumnType.Boolean - Case Schemas.Schema.ColumnType.Date + Case ImporterShared.Constants.ColumnType.Date Return DevExpress.Data.UnboundColumnType.DateTime - Case Schemas.Schema.ColumnType.Integer + Case ImporterShared.Constants.ColumnType.Integer Return DevExpress.Data.UnboundColumnType.Integer - Case Schemas.Schema.ColumnType.Decimal + Case ImporterShared.Constants.ColumnType.Decimal Return DevExpress.Data.UnboundColumnType.Decimal Case Else diff --git a/EDIDocumentImport/ImporterForm.vbproj b/EDIDocumentImport/ImporterForm.vbproj index 671209e..f3f2a01 100644 --- a/EDIDocumentImport/ImporterForm.vbproj +++ b/EDIDocumentImport/ImporterForm.vbproj @@ -151,6 +151,7 @@ + frmImportMain.vb diff --git a/EDIDocumentImport/frmImportMain.Designer.vb b/EDIDocumentImport/frmImportMain.Designer.vb index cf9f402..dd6fc77 100644 --- a/EDIDocumentImport/frmImportMain.Designer.vb +++ b/EDIDocumentImport/frmImportMain.Designer.vb @@ -42,6 +42,7 @@ Partial Class frmImportMain Me.SplitContainerGrids = New DevExpress.XtraEditors.SplitContainerControl() Me.SplitContainerGrids1 = New DevExpress.XtraEditors.SplitContainerControl() Me.SplitContainerGrids2 = New DevExpress.XtraEditors.SplitContainerControl() + Me.txtMandator = New DevExpress.XtraBars.BarStaticItem() CType(Me.RibbonControl, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.SplitContainerControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SplitContainerControl1.SuspendLayout() @@ -60,9 +61,9 @@ Partial Class frmImportMain 'RibbonControl ' Me.RibbonControl.ExpandCollapseItem.Id = 0 - Me.RibbonControl.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl.ExpandCollapseItem, Me.RibbonControl.SearchEditItem, Me.txtVersion, Me.txtFilesLoaded, Me.btnLoadFiles, Me.btnTransferFile, Me.btnOpenInputDirectory, Me.btnOpenOutputDirectory, Me.btnOpenSchemaDirectory, Me.btnReloadFile}) + Me.RibbonControl.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl.ExpandCollapseItem, Me.RibbonControl.SearchEditItem, Me.txtVersion, Me.txtFilesLoaded, Me.btnLoadFiles, Me.btnTransferFile, Me.btnOpenInputDirectory, Me.btnOpenOutputDirectory, Me.btnOpenSchemaDirectory, Me.btnReloadFile, Me.txtMandator}) Me.RibbonControl.Location = New System.Drawing.Point(0, 0) - Me.RibbonControl.MaxItemId = 12 + Me.RibbonControl.MaxItemId = 13 Me.RibbonControl.Name = "RibbonControl" Me.RibbonControl.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1}) Me.RibbonControl.ShowApplicationButton = DevExpress.Utils.DefaultBoolean.[False] @@ -75,15 +76,17 @@ Partial Class frmImportMain 'txtVersion ' Me.txtVersion.Alignment = DevExpress.XtraBars.BarItemLinkAlignment.Right - Me.txtVersion.Caption = "BarStaticItem1" + Me.txtVersion.Caption = "Version 1.0.0.0" Me.txtVersion.Id = 1 Me.txtVersion.Name = "txtVersion" + Me.txtVersion.Tag = "Version {0}" ' 'txtFilesLoaded ' - Me.txtFilesLoaded.Caption = "BarStaticItem2" + Me.txtFilesLoaded.Caption = "0 Dateien geladen" Me.txtFilesLoaded.Id = 2 Me.txtFilesLoaded.Name = "txtFilesLoaded" + Me.txtFilesLoaded.Tag = "{0} Dateien geladen" ' 'btnLoadFiles ' @@ -154,6 +157,7 @@ Partial Class frmImportMain ' Me.RibbonStatusBar.ItemLinks.Add(Me.txtVersion) Me.RibbonStatusBar.ItemLinks.Add(Me.txtFilesLoaded) + Me.RibbonStatusBar.ItemLinks.Add(Me.txtMandator) Me.RibbonStatusBar.Location = New System.Drawing.Point(0, 722) Me.RibbonStatusBar.Name = "RibbonStatusBar" Me.RibbonStatusBar.Ribbon = Me.RibbonControl @@ -169,7 +173,7 @@ Partial Class frmImportMain Me.SplitContainerControl1.Panel2.Controls.Add(Me.SplitContainerMain) Me.SplitContainerControl1.Panel2.Text = "Panel2" Me.SplitContainerControl1.Size = New System.Drawing.Size(1215, 590) - Me.SplitContainerControl1.SplitterPosition = 325 + Me.SplitContainerControl1.SplitterPosition = 362 Me.SplitContainerControl1.TabIndex = 2 ' 'GridControlFiles @@ -179,7 +183,7 @@ Partial Class frmImportMain Me.GridControlFiles.MainView = Me.GridViewFiles Me.GridControlFiles.MenuManager = Me.RibbonControl Me.GridControlFiles.Name = "GridControlFiles" - Me.GridControlFiles.Size = New System.Drawing.Size(325, 590) + Me.GridControlFiles.Size = New System.Drawing.Size(362, 590) Me.GridControlFiles.TabIndex = 0 Me.GridControlFiles.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridViewFiles}) ' @@ -188,6 +192,8 @@ Partial Class frmImportMain Me.GridViewFiles.Columns.AddRange(New DevExpress.XtraGrid.Columns.GridColumn() {Me.colSelected, Me.colFilename}) Me.GridViewFiles.GridControl = Me.GridControlFiles Me.GridViewFiles.Name = "GridViewFiles" + Me.GridViewFiles.OptionsView.ShowDetailButtons = False + Me.GridViewFiles.OptionsView.ShowIndicator = False ' 'colSelected ' @@ -195,6 +201,8 @@ Partial Class frmImportMain Me.colSelected.FieldName = "Selected" Me.colSelected.ImageOptions.SvgImage = CType(resources.GetObject("colSelected.ImageOptions.SvgImage"), DevExpress.Utils.Svg.SvgImage) Me.colSelected.ImageOptions.SvgImageSize = New System.Drawing.Size(16, 16) + Me.colSelected.MaxWidth = 30 + Me.colSelected.MinWidth = 30 Me.colSelected.Name = "colSelected" Me.colSelected.UnboundType = DevExpress.Data.UnboundColumnType.[Boolean] Me.colSelected.Visible = True @@ -208,6 +216,7 @@ Partial Class frmImportMain Me.colFilename.Name = "colFilename" Me.colFilename.Visible = True Me.colFilename.VisibleIndex = 1 + Me.colFilename.Width = 333 ' 'SplitContainerMain ' @@ -218,7 +227,7 @@ Partial Class frmImportMain Me.SplitContainerMain.Panel1.Text = "Panel1" Me.SplitContainerMain.Panel2.Text = "Panel2" Me.SplitContainerMain.PanelVisibility = DevExpress.XtraEditors.SplitPanelVisibility.Panel1 - Me.SplitContainerMain.Size = New System.Drawing.Size(880, 590) + Me.SplitContainerMain.Size = New System.Drawing.Size(843, 590) Me.SplitContainerMain.SplitterPosition = 588 Me.SplitContainerMain.TabIndex = 1 ' @@ -232,7 +241,7 @@ Partial Class frmImportMain Me.SplitContainerGrids.Panel1.Text = "Panel1" Me.SplitContainerGrids.Panel2.Controls.Add(Me.SplitContainerGrids2) Me.SplitContainerGrids.Panel2.Text = "Panel2" - Me.SplitContainerGrids.Size = New System.Drawing.Size(880, 590) + Me.SplitContainerGrids.Size = New System.Drawing.Size(843, 590) Me.SplitContainerGrids.SplitterPosition = 288 Me.SplitContainerGrids.TabIndex = 0 ' @@ -244,7 +253,7 @@ Partial Class frmImportMain Me.SplitContainerGrids1.Name = "SplitContainerGrids1" Me.SplitContainerGrids1.Panel1.Text = "Panel1" Me.SplitContainerGrids1.Panel2.Text = "Panel2" - Me.SplitContainerGrids1.Size = New System.Drawing.Size(880, 288) + Me.SplitContainerGrids1.Size = New System.Drawing.Size(843, 288) Me.SplitContainerGrids1.SplitterPosition = 118 Me.SplitContainerGrids1.TabIndex = 0 ' @@ -256,10 +265,17 @@ Partial Class frmImportMain Me.SplitContainerGrids2.Name = "SplitContainerGrids2" Me.SplitContainerGrids2.Panel1.Text = "Panel1" Me.SplitContainerGrids2.Panel2.Text = "Panel2" - Me.SplitContainerGrids2.Size = New System.Drawing.Size(880, 292) + Me.SplitContainerGrids2.Size = New System.Drawing.Size(843, 292) Me.SplitContainerGrids2.SplitterPosition = 126 Me.SplitContainerGrids2.TabIndex = 0 ' + 'txtMandator + ' + Me.txtMandator.Caption = "Mandant: Keiner" + Me.txtMandator.Id = 12 + Me.txtMandator.Name = "txtMandator" + Me.txtMandator.Tag = "Mandant: {0}" + ' 'frmImportMain ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -312,4 +328,5 @@ Partial Class frmImportMain Friend WithEvents btnOpenSchemaDirectory As DevExpress.XtraBars.BarButtonItem Friend WithEvents SplitContainerMain As DevExpress.XtraEditors.SplitContainerControl Friend WithEvents btnReloadFile As DevExpress.XtraBars.BarButtonItem + Friend WithEvents txtMandator As DevExpress.XtraBars.BarStaticItem End Class diff --git a/EDIDocumentImport/frmImportMain.vb b/EDIDocumentImport/frmImportMain.vb index 40aa533..c6d60c9 100644 --- a/EDIDocumentImport/frmImportMain.vb +++ b/EDIDocumentImport/frmImportMain.vb @@ -24,75 +24,92 @@ Public Class frmImportMain Private PositionData As PositionData Private DocumentLoader As Documents.DocumentLoader Private SchemaLoader As Schemas.SchemaLoader + Private Message As Message Private Grids As List(Of GridControl) Private GridLoader As GridLoader Private GridBuilder As GridBuilder - Private CurrentSchema As String + Private CurrentSchemaName As String + Private CurrentSchema As Schema Private CurrentDocument As Document Private Sub frmImportMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load - txtVersion.Caption = String.Format(txtVersion.Caption, Application.ProductVersion) + Try + txtVersion.Caption = String.Format(txtVersion.Caption, Application.ProductVersion) - LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "EDI Document Importer") - Logger = LogConfig.GetLogger() - Logger.Info("EDI Document Importer, Version [{0}]", Application.ProductVersion) + LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, "Digital Data", "EDI Document Importer") + Logger = LogConfig.GetLogger() + Logger.Info("EDI Document Importer, Version [{0}]", Application.ProductVersion) - ConfigManager = New ConfigManager(Of Config)(LogConfig, + ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath, Application.CommonAppDataPath, Application.StartupPath) - GridBuilder = New GridBuilder(GridViewFiles) - GridBuilder. + Message = New Message(LogConfig) + + GridBuilder = New GridBuilder(GridViewFiles) + GridBuilder. WithDefaults. WithReadOnlyOptions. WithClipboardHandler() - FileEx = New DigitalData.Modules.Filesystem.File(LogConfig) + FileEx = New DigitalData.Modules.Filesystem.File(LogConfig) - ' If ConnectionString does not exist, show SQL Config Form - If ConfigManager.Config.ConnectionString = String.Empty Then - Dim oForm As New frmSQLConfig(LogConfig) With { + ' If ConnectionString does not exist, show SQL Config Form + If ConfigManager.Config.ConnectionString = String.Empty Then + Dim oForm As New frmSQLConfig(LogConfig) With { .FormTitle = "EDI Document Importer" } - Dim oResult = oForm.ShowDialog() + Dim oResult = oForm.ShowDialog() - If oResult = DialogResult.OK Then - ConfigManager.Config.ConnectionString = oForm.ConnectionString - ConfigManager.Save() + If oResult = DialogResult.OK Then + ConfigManager.Config.ConnectionString = oForm.ConnectionString + ConfigManager.Save() + End If End If - End If - ' Initialize Database - Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString) - Database = New MSSQLServer(LogConfig, oConnectionString) - Winline = New Data(LogConfig, Database, ConfigManager.Config) - WebService = New WebService(LogConfig, ConfigManager.Config) - PositionData = New PositionData(LogConfig, Winline) - ' Load WinLine Data - Winline.Mandators.Clear() - Winline.LoadMandators() - Winline.LoadEconomicYears() - Winline.LoadDocumentKinds(Winline.Mandators) - Winline.LoadTemplateConfiguration() - For Each oMandator In Winline.Mandators - Winline.LoadAccounts(oMandator) - Next + ' Initialize Database + Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString) + Database = New MSSQLServer(LogConfig, oConnectionString) + Winline = New Data(LogConfig, Database, ConfigManager.Config) + WebService = New WebService(LogConfig, ConfigManager.Config) + PositionData = New PositionData(LogConfig, Winline) + Catch ex As Exception + Message.Error(ex, "Fehler beim Initialisieren der Anwendung Daten") + End Try - DocumentLoader = New DocumentLoader(LogConfig, Winline) - SchemaLoader = New SchemaLoader(LogConfig) - GridLoader = New GridLoader(LogConfig) + ' Load WinLine Data + Try + Winline.Mandators.Clear() + Winline.LoadMandators() + Winline.LoadEconomicYears() + Winline.LoadDocumentKinds(Winline.Mandators) + Winline.LoadTemplateConfiguration() + For Each oMandator In Winline.Mandators + Winline.LoadAccounts(oMandator) + Next + Catch ex As Exception + Message.Error(ex, "Fehler beim Laden der WinLine Daten") + End Try - SchemaLoader.LoadFiles(ConfigManager.Config.SchemaDirectory) - CurrentSchema = SchemaLoader.SchemaList.First().FullName + Try + DocumentLoader = New DocumentLoader(LogConfig, Winline) + SchemaLoader = New SchemaLoader(LogConfig) + GridLoader = New GridLoader(LogConfig) - Dim oSchema = SchemaLoader.GetSchemaFromFile(CurrentSchema) - Grids = CreateGridsAndColumns(oSchema) + SchemaLoader.LoadFiles(ConfigManager.Config.SchemaDirectory) + CurrentSchemaName = SchemaLoader.SchemaList.First().FullName + CurrentSchema = SchemaLoader.GetSchemaFromFile(CurrentSchemaName) + Grids = CreateGridsAndColumns(CurrentSchema) + Catch ex As Exception + Message.Error(ex, "Fehler beim Laden der Vorlagen Daten") + End Try + txtVersion.Caption = String.Format(txtVersion.Tag.ToString, My.Application.Info.Version.ToString) End Sub @@ -175,8 +192,9 @@ Public Class frmImportMain End Sub Private Sub btnLoadFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLoadFiles.ItemClick - If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory) Then + If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory, CurrentSchema) Then GridControlFiles.DataSource = DocumentLoader.Files + txtFilesLoaded.Caption = String.Format(txtFilesLoaded.Tag.ToString, DocumentLoader.Files.Count) End If End Sub @@ -280,7 +298,7 @@ Public Class frmImportMain If oResult = DialogResult.Yes Then Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle) - Dim oNewDocument = DocumentLoader.LoadFile(oDocument.File) + Dim oNewDocument = DocumentLoader.LoadFile(oDocument.File, CurrentSchema) Dim oIndex = DocumentLoader.Files.IndexOf(oDocument) DocumentLoader.Files.Item(oIndex) = oNewDocument diff --git a/EDIDocumentImport/frmImportMain_old.vb b/EDIDocumentImport/frmImportMain_old.vb index 386bb0d..c44843f 100644 --- a/EDIDocumentImport/frmImportMain_old.vb +++ b/EDIDocumentImport/frmImportMain_old.vb @@ -1,10 +1,7 @@ Imports System.IO Imports DevExpress.XtraGrid.Views.Grid -Imports DevExpress.XtraGrid.Columns Imports DevExpress.XtraRichEdit Imports DevExpress.XtraEditors -Imports DevExpress.XtraReports.UI -Imports DevExpress.DataAccess.ObjectBinding Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Database Imports DigitalData.Modules.Config @@ -12,9 +9,7 @@ Imports DigitalData.Controls.SQLConfig Imports DigitalData.GUIs.Common Imports ImporterShared.Documents Imports ImporterShared.Winline -Imports ImporterShared.Schemas Imports ImporterForm.Positions -Imports DevExpress.XtraLayout Public Class frmImportMain_old Public LogConfig As LogConfig @@ -125,7 +120,7 @@ Public Class frmImportMain_old Private Sub btnLoadDocuments_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLoadDocuments.ItemClick Try - If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory) = True Then + If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory, Nothing) = True Then RibbonGroupDataTransmission.Enabled = True RibbonGroupDocument.Enabled = True diff --git a/EDIDocumentImport/frmRowEditor.vb b/EDIDocumentImport/frmRowEditor.vb index 450ec43..65f3ee6 100644 --- a/EDIDocumentImport/frmRowEditor.vb +++ b/EDIDocumentImport/frmRowEditor.vb @@ -5,16 +5,17 @@ Imports ImporterShared.Documents Imports ImporterShared.DocumentRow Imports DevExpress.XtraEditors.Repository Imports ImporterShared.Winline +Imports DigitalData.Modules.Language Public Class frmRowEditor Private ReadOnly _Columns As List(Of String) Private ReadOnly _DataTable As New DataTable Private ReadOnly _Accounts As List(Of Account) - Private _DocumentRow As ImporterShared.DocumentRow + Private ReadOnly _DocumentRow As ImporterShared.DocumentRow - Private DatePicker As New RepositoryItemDateEdit() - Private MultilineEditor As New RepositoryItemMemoEdit() - Private AccountPicker As New RepositoryItemSearchLookUpEdit + Private ReadOnly DatePicker As New RepositoryItemDateEdit() + Private ReadOnly MultilineEditor As New RepositoryItemMemoEdit() + Private ReadOnly AccountPicker As New RepositoryItemSearchLookUpEdit Private Const COL_KEY = "KEY" Private Const COL_VALUE_ORIGINAL = "VALUE_ORIGINAL" @@ -39,6 +40,11 @@ Public Class frmRowEditor AccountPicker.DataSource = _Accounts AccountPicker.DisplayMember = "Name" AccountPicker.ValueMember = "Id" + + 'DatePicker.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime + 'DatePicker.EditFormat.FormatString = "dd/MM/yyyy" + 'DatePicker.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime + 'DatePicker.DisplayFormat.FormatString = "yyyy-MM-dd" End Sub Private Sub frmRowEditor_Load(sender As Object, e As EventArgs) Handles Me.Load @@ -82,8 +88,8 @@ Public Class frmRowEditor oField = New KeyValuePair(Of String, FieldValue)(oRow.Item(COL_KEY), New FieldValue()) End If - Dim oFieldValue = oField.Value - oFieldValue.Final = oRow.Item(COL_VALUE_FINAL) + Dim oFieldValue As FieldValue = oField.Value + oFieldValue.Final = Utils.Notnull(oRow.Item(COL_VALUE_FINAL), String.Empty) If _DocumentRow.Fields.ContainsKey(oField.Key) Then _DocumentRow.Fields.Item(oField.Key) = oFieldValue diff --git a/ImporterShared/Constants.vb b/ImporterShared/Constants.vb index 6ac6291..3b313f1 100644 --- a/ImporterShared/Constants.vb +++ b/ImporterShared/Constants.vb @@ -3,4 +3,12 @@ GLN = 1 EAN = 2 End Enum + + Public Enum ColumnType As Integer + [String] + [Integer] + [Date] + [Boolean] + [Decimal] + End Enum End Class diff --git a/ImporterShared/Documents/Document.vb b/ImporterShared/Documents/Document.vb index 60cc01a..acd8c33 100644 --- a/ImporterShared/Documents/Document.vb +++ b/ImporterShared/Documents/Document.vb @@ -1,10 +1,12 @@ Imports System.IO +Imports ImporterShared.Schemas Namespace Documents Public Class Document Public File As FileInfo - Public Mandator As String Public Type As DocumentType + Public Schema As Schema + Public Mandator As String Public Selected As Boolean = False ''' @@ -12,7 +14,6 @@ Namespace Documents ''' Public CreatedAt As Date - Public TemplateName As String Public TemplateType As Integer Public [Option] As Integer diff --git a/ImporterShared/Documents/DocumentLoader.vb b/ImporterShared/Documents/DocumentLoader.vb index ff1e03d..12a4de4 100644 --- a/ImporterShared/Documents/DocumentLoader.vb +++ b/ImporterShared/Documents/DocumentLoader.vb @@ -1,20 +1,12 @@ -Imports System.ComponentModel -Imports System.IO -Imports System.Reflection -Imports System.Text.RegularExpressions -Imports System.Xml.Serialization -Imports System.Xml.XPath -Imports DigitalData.Modules.Language +Imports System.IO Imports DigitalData.Modules.Logging -Imports ImporterShared.Documents -Imports ImporterShared.Schemas.Orders +Imports ImporterShared.Schemas Namespace Documents Public Class DocumentLoader Inherits BaseClass Private ReadOnly Winline As Winline.Data - Private ReadOnly Serializer As Serializer Public Files As New List(Of Document) @@ -22,10 +14,10 @@ Namespace Documents Public Sub New(pLogConfig As LogConfig, pWinline As Winline.Data) MyBase.New(pLogConfig, pLogConfig.GetLogger()) Winline = pWinline - Serializer = New Serializer(pLogConfig) End Sub - Public Function LoadFiles(pInputDirectory) As Boolean + + Public Function LoadFiles(pInputDirectory As String, pSchema As Schema) As Boolean If pInputDirectory = String.Empty Then Throw New ArgumentNullException("InputDirectory") End If @@ -40,7 +32,7 @@ Namespace Documents Logger.Debug("Found [{0}] files in directory [{1}]", oFiles.Count, oDirectory) For Each oFile In oFiles - Dim oDocument = LoadFile(oFile) + Dim oDocument = LoadFile(oFile, pSchema) Files.Add(oDocument) Next @@ -53,57 +45,110 @@ Namespace Documents End Try End Function - Public Function LoadFile(pFileInfo As FileInfo) As Document + Public Function LoadFile(pFileInfo As FileInfo, pSchema As Schema) As Document Dim oFileList As New List(Of FileInfo) From {pFileInfo} Logger.Info("Loading file [{0}]", pFileInfo.Name) - Return oFileList. - Select(AddressOf WrapFileInfo). - Select(AddressOf LoadDocumentData2). - Select(Function(d) MatchDataFromWinLine(d, Winline.Mandators)). - SingleOrDefault() + Try + Return oFileList. + Select(AddressOf WrapFileInfo). + Select(Function(d) IncludeSchema(d, pSchema)). + Select(Function(d) LoadDocumentData(d, pSchema)). + Select(Function(d) MatchDataFromWinLine(d, Winline.Mandators)). + SingleOrDefault() + Catch ex As Exception + Logger.Error(ex) + Return Nothing + End Try + End Function + + + Private Function IncludeSchema(pDocument As Document, pSchema As Schema) As Document + pDocument.Schema = pSchema + Return pDocument End Function - Private Function LoadDocumentData2(pDocument As Document) As Document + + ''' + ''' Loads a single document from the FullName Property in the Document Object + ''' + ''' + ''' + ''' A document might look like this: + ''' + ''' + ''' + ''' + ''' + ''' + ''' + Private Function LoadDocumentData(pDocument As Document, pSchema As Schema) As Document Dim oText As String = IO.File.ReadAllText(pDocument.FullName) Dim oDoc = XDocument.Parse(oText) + Dim oRootElement As XElement = XmlData.GetElement(oDoc, "MESOWebService") + If oRootElement Is Nothing Then + Throw New Exceptions.MalformedXmlException("Datei enthält kein MESOWebService-Element") + End If Dim oTemplateName = XmlData.GetElementAttribute(oRootElement, "Template") + If oTemplateName Is Nothing Then + Throw New Exceptions.MalformedXmlException("Datei enthält kein Template-Attribut") + End If + Dim oTemplateType = XmlData.GetElementAttribute(oRootElement, "TemplateType") - Dim oOption = XmlData.GetElementAttribute(oRootElement, "option") - Dim oPrintVoucher = XmlData.GetElementAttribute(oRootElement, "printVoucher") + If oTemplateType Is Nothing Then + Throw New Exceptions.MalformedXmlException("Datei enthält kein TemplateType-Attribut") + End If - Dim oRowElements As List(Of XElement) = oRootElement.Elements.ToList + Dim oOption = XmlData.GetElementAttribute(oRootElement, "option") + If oOption Is Nothing Then + Throw New Exceptions.MalformedXmlException("Datei enthält kein option-Attribut") + End If + Dim oPrintVoucher = XmlData.GetElementAttribute(oRootElement, "printVoucher") + If oPrintVoucher Is Nothing Then + Throw New Exceptions.MalformedXmlException("Datei enthält kein printVoucher-Attribut") + End If - Dim oRows As New List(Of DocumentRow) + ' The first level of Elements are the document Rows + Dim oTopLevelElements As List(Of XElement) = oRootElement.Elements.ToList + Dim oDocumentRows As New List(Of DocumentRow) - For Each oElement As XElement In oRowElements + For Each oTopLevelElement As XElement In oTopLevelElements Dim oFields As New Dictionary(Of String, DocumentRow.FieldValue) - - Dim oSubElements = oElement.Descendants().ToList() + Dim oSubElements = oTopLevelElement.Descendants().ToList() + Dim oTable = pSchema.Tables. + Where(Function(t) t.Name = oTopLevelElement.Name). + FirstOrDefault() For Each oSubElement As XElement In oSubElements + Dim oSchemaField = oTable.Columns. + Where(Function(c) c.Name = oSubElement.Name). + SingleOrDefault() + oFields.Add(oSubElement.Name.ToString, New DocumentRow.FieldValue With { .Original = oSubElement.Value, - .Final = oSubElement.Value + .Final = oSubElement.Value, + .DataType = oSchemaField.DataType }) Next + ' Create a DocumentRow object for each Top Level Element Dim oRow = New DocumentRow With { - .Name = oElement.Name.ToString, + .Name = oTopLevelElement.Name.ToString, .Fields = oFields } - oRows.Add(oRow) + oDocumentRows.Add(oRow) Next + ' Update the document pDocument.TemplateName = oTemplateName pDocument.TemplateType = oTemplateType - pDocument.Rows = oRows pDocument.Option = oOption pDocument.PrintVoucher = oPrintVoucher + pDocument.Rows = oDocumentRows Return pDocument End Function @@ -121,26 +166,13 @@ Namespace Documents Logger.Warn("Mandator not found for File [{0}]", pDocument.File.Name) End If - pDocument = MatchOrderData(pDocument, oMandator) + pDocument = MatchDocumentData(pDocument, oMandator) pDocument.Mandator = oMandator.Id - - 'If TypeOf pDocument.Data Is Schemas.Orders.Input.MESOWebService Then - ' Dim oMandator = Winline.FindMatchingMandatorFromOrder(pDocument.Data) - ' Dim oData As Schemas.Orders.Input.MESOWebService = MatchOrderData(pDocument.Data, oMandator) - - ' If oMandator Is Nothing Then - ' Logger.Warn("Mandator not found for File [{0}]", pDocument.File.Name) - ' End If - - ' pDocument.Mandator = oMandator.Id - ' pDocument.Data = oData - 'End If - Return pDocument End Function - Private Function MatchOrderData(pDocument As Document, pMandator As Winline.Mandator) As Document + Private Function MatchDocumentData(pDocument As Document, pMandator As Winline.Mandator) As Document Dim oYear = Winline.GetWinLineYear() If pMandator Is Nothing Then diff --git a/ImporterShared/Documents/DocumentRow.vb b/ImporterShared/Documents/DocumentRow.vb index 7cbb616..04919d5 100644 --- a/ImporterShared/Documents/DocumentRow.vb +++ b/ImporterShared/Documents/DocumentRow.vb @@ -15,6 +15,7 @@ Public Original As String = "" Public External As String = "" Public Final As String = "" + Public DataType As Constants.ColumnType = Constants.ColumnType.String Public Overrides Function ToString() As String Return Final diff --git a/ImporterShared/Exceptions.vb b/ImporterShared/Exceptions.vb new file mode 100644 index 0000000..ac41eee --- /dev/null +++ b/ImporterShared/Exceptions.vb @@ -0,0 +1,49 @@ +Public Class Exceptions + Public MustInherit Class DocumentShowException + Inherits ApplicationException + + Public Sub New(message As String) + MyBase.New(message) + End Sub + End Class + + Public Class WebServiceException + Inherits ApplicationException + + Public Sub New(message As String) + MyBase.New(message) + End Sub + End Class + + Public Class NoMandatorException + Inherits DocumentShowException + + Public Sub New(message As String) + MyBase.New(message) + End Sub + End Class + + Public Class MultipleAccountsException + Inherits DocumentShowException + + Public Sub New(message As String) + MyBase.New(message) + End Sub + End Class + + Public Class NoAccountException + Inherits DocumentShowException + + Public Sub New(message As String) + MyBase.New(message) + End Sub + End Class + + Public Class MalformedXmlException + Inherits ApplicationException + + Public Sub New(message As String) + MyBase.New(message) + End Sub + End Class +End Class diff --git a/ImporterShared/ImporterShared.vbproj b/ImporterShared/ImporterShared.vbproj index 90c47a3..d4907f3 100644 --- a/ImporterShared/ImporterShared.vbproj +++ b/ImporterShared/ImporterShared.vbproj @@ -100,6 +100,7 @@ + @@ -127,6 +128,7 @@ + diff --git a/ImporterShared/Schemas/Schema.vb b/ImporterShared/Schemas/Schema.vb index e4bae3f..17d32f9 100644 --- a/ImporterShared/Schemas/Schema.vb +++ b/ImporterShared/Schemas/Schema.vb @@ -1,14 +1,5 @@ Namespace Schemas Public Class Schema - - Public Enum ColumnType As Integer - [String] - [Integer] - [Date] - [Boolean] - [Decimal] - End Enum - Public Property Tables As New List(Of Table) Public Property Name As String @@ -20,9 +11,8 @@ Class Column Public Property Name As String Public Property Required As String - Public Property DataType As ColumnType + Public Property DataType As Constants.ColumnType End Class - End Class End Namespace diff --git a/ImporterShared/Schemas/SchemaLoader.vb b/ImporterShared/Schemas/SchemaLoader.vb index 79c7f6e..e5bd601 100644 --- a/ImporterShared/Schemas/SchemaLoader.vb +++ b/ImporterShared/Schemas/SchemaLoader.vb @@ -41,8 +41,11 @@ Namespace Schemas Public Function GetSchemaFromFile(pSchemaFilePath As String) As Schema Dim oSchema As New Schema + Dim oFileInfo As New FileInfo(pSchemaFilePath) Dim oElements = GetSchemaElements(pSchemaFilePath) + oSchema.Name = oFileInfo.Name + For Each oElement In oElements Dim oColumns = GetElementColumns(oElement) Dim oSchemaColumns As New List(Of Schema.Column) @@ -76,7 +79,7 @@ Namespace Schemas Return oSchema End Function - Public Function GetElementType(pElement As XElement) As Schema.ColumnType + Public Function GetElementType(pElement As XElement) As Constants.ColumnType Dim oTypeString = XmlData.GetElementAttribute(pElement, "type") If oTypeString Is Nothing Then @@ -89,15 +92,15 @@ Namespace Schemas Select Case oTypeString Case "xs:date" - Return Schema.ColumnType.Date + Return Constants.ColumnType.Date Case "xs:integer" - Return Schema.ColumnType.Integer + Return Constants.ColumnType.Integer Case "xs:decimal" - Return Schema.ColumnType.Decimal + Return Constants.ColumnType.Decimal Case "xs:boolean" - Return Schema.ColumnType.Boolean + Return Constants.ColumnType.Boolean Case Else - Return Schema.ColumnType.String + Return Constants.ColumnType.String End Select End Function diff --git a/ImporterShared/Winline/Configuration.vb b/ImporterShared/Winline/Configuration.vb new file mode 100644 index 0000000..6f2e6b9 --- /dev/null +++ b/ImporterShared/Winline/Configuration.vb @@ -0,0 +1,7 @@ + +''' +''' Class for loading column/field config from database +''' +Public Class Configuration + +End Class