First Working Version with New parser

This commit is contained in:
Jonathan Jenne 2021-10-15 14:56:46 +02:00
parent 3596786137
commit 12aa22ebdf
33 changed files with 3066 additions and 2533 deletions

View File

@ -0,0 +1,59 @@
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.Modules.Logging
Imports ImporterShared
Public Class GridLoader
Inherits BaseClass
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig, pLogConfig.GetLogger())
End Sub
Public Function GetGridFromElement(pTable As Schemas.Schema.Table) As GridControl
Dim oGrid As New GridControl With {
.Dock = DockStyle.Fill,
.Name = pTable.Name
}
oGrid.ForceInitialize()
oGrid.MainView.PopulateColumns()
Dim oView As GridView = oGrid.DefaultView
For Each oCol In pTable.Columns
Dim oColumn = New Columns.GridColumn With {
.Name = oCol.Name,
.Caption = oCol.Name,
.FieldName = oCol.Name,
.UnboundType = GetColumnType(oCol),
.VisibleIndex = 0
}
oView.Columns.Add(oColumn)
Next
Return oGrid
End Function
Private Function GetColumnType(pColumn As Schemas.Schema.Column)
Select Case pColumn.DataType
Case Schemas.Schema.ColumnType.Boolean
Return DevExpress.Data.UnboundColumnType.Boolean
Case Schemas.Schema.ColumnType.Date
Return DevExpress.Data.UnboundColumnType.DateTime
Case Schemas.Schema.ColumnType.Integer
Return DevExpress.Data.UnboundColumnType.Integer
Case Schemas.Schema.ColumnType.Decimal
Return DevExpress.Data.UnboundColumnType.Decimal
Case Else
Return DevExpress.Data.UnboundColumnType.String
End Select
End Function
End Class

View File

@ -149,6 +149,18 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Exceptions.vb" />
<Compile Include="frmImportMain.Designer.vb">
<DependentUpon>frmImportMain.vb</DependentUpon>
</Compile>
<Compile Include="frmImportMain.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmImportMain_old.Designer.vb">
<DependentUpon>frmImportMain_old.vb</DependentUpon>
</Compile>
<Compile Include="frmImportMain_old.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmMain.Designer.vb">
<DependentUpon>frmMain.vb</DependentUpon>
</Compile>
@ -161,6 +173,7 @@
<Compile Include="frmMandatorSelection.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="GridLoader.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen>
@ -195,6 +208,12 @@
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="frmImportMain.resx">
<DependentUpon>frmImportMain.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmImportMain_old.resx">
<DependentUpon>frmImportMain_old.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmMain.resx">
<DependentUpon>frmMain.vb</DependentUpon>
</EmbeddedResource>

View File

@ -32,7 +32,7 @@ Namespace My
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.ImporterForm.frmMain
Me.MainForm = Global.ImporterForm.frmImportMain
End Sub
End Class
End Namespace

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain>
<MainForm>frmMain</MainForm>
<MainForm>frmImportMain</MainForm>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>

View File

@ -13,37 +13,37 @@ Public Class PositionData
Winline = pWinline
End Sub
Public Function Load(pMandator As Mandator, pData As Orders.Input.MESOWebService, pDataOriginal As Orders.Input.MESOWebService) As List(Of Position)
Dim oPositions = Orders.Helpers.GetOrderPositions(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT026)(pData)
Dim oPositionsOriginal = Orders.Helpers.GetOrderPositions(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT026)(pDataOriginal)
Dim oPositionList As New List(Of Position)
'Public Function Load(pMandator As Mandator, pData As Orders.Input.MESOWebService, pDataOriginal As Orders.Input.MESOWebService) As List(Of Position)
' Dim oPositions = Orders.Helpers.GetOrderPositions(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT026)(pData)
' Dim oPositionsOriginal = Orders.Helpers.GetOrderPositions(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT026)(pDataOriginal)
' Dim oPositionList As New List(Of Position)
For Each oPosition In oPositions
Dim oPositionOriginal = oPositionsOriginal.
Where(Function(p) p.Zeilennummer = oPosition.Zeilennummer).
SingleOrDefault()
' For Each oPosition In oPositions
' Dim oPositionOriginal = oPositionsOriginal.
' Where(Function(p) p.Zeilennummer = oPosition.Zeilennummer).
' SingleOrDefault()
Dim oReplacementNumber As String = Winline.GetReplacementArticleNumber(oPosition.Artikelnummer, pMandator)
' Dim oReplacementNumber As String = Winline.GetReplacementArticleNumber(oPosition.Artikelnummer, pMandator)
' If ArticleNumber is the same as the replacement Number, this Article does not have a replacement Number
If oReplacementNumber = oPosition.Artikelnummer Then
oReplacementNumber = Nothing
End If
' ' If ArticleNumber is the same as the replacement Number, this Article does not have a replacement Number
' If oReplacementNumber = oPosition.Artikelnummer Then
' oReplacementNumber = Nothing
' End If
oPositionList.Add(New Position With {
.ArticleNumber = oPosition.Artikelnummer,
.RowNumber = oPosition.Zeilennummer,
.ArticleDescription = oPosition.Bezeichnung,
.ArticleNumberVendor = oPosition.Lieferantenartikelnummer,
.EDIPrice = oPosition.Einzelpreis,
.WinLinePrice = 0,
.Price = 0,
.Amount = oPosition.Menge_bestellt,
.EuropeanArticleNumber = oPositionOriginal.Artikelnummer,
.ReplacementArticleNumber = oReplacementNumber
})
Next
' oPositionList.Add(New Position With {
' .ArticleNumber = oPosition.Artikelnummer,
' .RowNumber = oPosition.Zeilennummer,
' .ArticleDescription = oPosition.Bezeichnung,
' .ArticleNumberVendor = oPosition.Lieferantenartikelnummer,
' .EDIPrice = oPosition.Einzelpreis,
' .WinLinePrice = 0,
' .Price = 0,
' .Amount = oPosition.Menge_bestellt,
' .EuropeanArticleNumber = oPositionOriginal.Artikelnummer,
' .ReplacementArticleNumber = oReplacementNumber
' })
' Next
Return oPositionList
End Function
' Return oPositionList
'End Function
End Class

View File

@ -0,0 +1,259 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class frmImportMain
Inherits DevExpress.XtraBars.Ribbon.RibbonForm
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim UnboundSourceProperty1 As DevExpress.Data.UnboundSourceProperty = New DevExpress.Data.UnboundSourceProperty()
Me.RibbonControl = New DevExpress.XtraBars.Ribbon.RibbonControl()
Me.txtVersion = New DevExpress.XtraBars.BarStaticItem()
Me.txtFilesLoaded = New DevExpress.XtraBars.BarStaticItem()
Me.BarButtonItem1 = New DevExpress.XtraBars.BarButtonItem()
Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonStatusBar = New DevExpress.XtraBars.Ribbon.RibbonStatusBar()
Me.SplitContainerControl1 = New DevExpress.XtraEditors.SplitContainerControl()
Me.GridControlFiles = New DevExpress.XtraGrid.GridControl()
Me.GridViewFiles = New DevExpress.XtraGrid.Views.Grid.GridView()
Me.GridColumn1 = New DevExpress.XtraGrid.Columns.GridColumn()
Me.GridColumn2 = New DevExpress.XtraGrid.Columns.GridColumn()
Me.GridColumn3 = New DevExpress.XtraGrid.Columns.GridColumn()
Me.SplitContainerControl2 = New DevExpress.XtraEditors.SplitContainerControl()
Me.SplitContainerControl3 = New DevExpress.XtraEditors.SplitContainerControl()
Me.SplitContainerControl4 = New DevExpress.XtraEditors.SplitContainerControl()
Me.UnboundSource1 = New DevExpress.Data.UnboundSource(Me.components)
Me.BarButtonItem2 = New DevExpress.XtraBars.BarButtonItem()
CType(Me.RibbonControl, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SplitContainerControl1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerControl1.SuspendLayout()
CType(Me.GridControlFiles, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.GridViewFiles, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SplitContainerControl2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerControl2.SuspendLayout()
CType(Me.SplitContainerControl3, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerControl3.SuspendLayout()
CType(Me.SplitContainerControl4, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerControl4.SuspendLayout()
CType(Me.UnboundSource1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'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.BarButtonItem1, Me.BarButtonItem2})
Me.RibbonControl.Location = New System.Drawing.Point(0, 0)
Me.RibbonControl.MaxItemId = 5
Me.RibbonControl.Name = "RibbonControl"
Me.RibbonControl.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1})
Me.RibbonControl.Size = New System.Drawing.Size(1215, 158)
Me.RibbonControl.StatusBar = Me.RibbonStatusBar
'
'txtVersion
'
Me.txtVersion.Alignment = DevExpress.XtraBars.BarItemLinkAlignment.Right
Me.txtVersion.Caption = "BarStaticItem1"
Me.txtVersion.Id = 1
Me.txtVersion.Name = "txtVersion"
'
'txtFilesLoaded
'
Me.txtFilesLoaded.Caption = "BarStaticItem2"
Me.txtFilesLoaded.Id = 2
Me.txtFilesLoaded.Name = "txtFilesLoaded"
'
'BarButtonItem1
'
Me.BarButtonItem1.Caption = "Import"
Me.BarButtonItem1.Id = 3
Me.BarButtonItem1.Name = "BarButtonItem1"
'
'RibbonPage1
'
Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup1})
Me.RibbonPage1.Name = "RibbonPage1"
Me.RibbonPage1.Text = "RibbonPage1"
'
'RibbonPageGroup1
'
Me.RibbonPageGroup1.ItemLinks.Add(Me.BarButtonItem1)
Me.RibbonPageGroup1.ItemLinks.Add(Me.BarButtonItem2)
Me.RibbonPageGroup1.Name = "RibbonPageGroup1"
Me.RibbonPageGroup1.Text = "RibbonPageGroup1"
'
'RibbonStatusBar
'
Me.RibbonStatusBar.ItemLinks.Add(Me.txtVersion)
Me.RibbonStatusBar.ItemLinks.Add(Me.txtFilesLoaded)
Me.RibbonStatusBar.Location = New System.Drawing.Point(0, 722)
Me.RibbonStatusBar.Name = "RibbonStatusBar"
Me.RibbonStatusBar.Ribbon = Me.RibbonControl
Me.RibbonStatusBar.Size = New System.Drawing.Size(1215, 24)
'
'SplitContainerControl1
'
Me.SplitContainerControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.SplitContainerControl1.Location = New System.Drawing.Point(0, 158)
Me.SplitContainerControl1.Name = "SplitContainerControl1"
Me.SplitContainerControl1.Panel1.Controls.Add(Me.GridControlFiles)
Me.SplitContainerControl1.Panel1.Text = "Panel1"
Me.SplitContainerControl1.Panel2.Controls.Add(Me.SplitContainerControl2)
Me.SplitContainerControl1.Panel2.Text = "Panel2"
Me.SplitContainerControl1.Size = New System.Drawing.Size(1215, 564)
Me.SplitContainerControl1.SplitterPosition = 325
Me.SplitContainerControl1.TabIndex = 2
'
'GridControlFiles
'
Me.GridControlFiles.Dock = System.Windows.Forms.DockStyle.Fill
Me.GridControlFiles.Location = New System.Drawing.Point(0, 0)
Me.GridControlFiles.MainView = Me.GridViewFiles
Me.GridControlFiles.MenuManager = Me.RibbonControl
Me.GridControlFiles.Name = "GridControlFiles"
Me.GridControlFiles.Size = New System.Drawing.Size(325, 564)
Me.GridControlFiles.TabIndex = 0
Me.GridControlFiles.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridViewFiles})
'
'GridViewFiles
'
Me.GridViewFiles.Columns.AddRange(New DevExpress.XtraGrid.Columns.GridColumn() {Me.GridColumn1, Me.GridColumn2, Me.GridColumn3})
Me.GridViewFiles.GridControl = Me.GridControlFiles
Me.GridViewFiles.Name = "GridViewFiles"
'
'GridColumn1
'
Me.GridColumn1.Caption = "GridColumn1"
Me.GridColumn1.FieldName = "Name"
Me.GridColumn1.Name = "GridColumn1"
Me.GridColumn1.Visible = True
Me.GridColumn1.VisibleIndex = 0
'
'GridColumn2
'
Me.GridColumn2.Caption = "GridColumn2"
Me.GridColumn2.FieldName = "FullName"
Me.GridColumn2.Name = "GridColumn2"
Me.GridColumn2.Visible = True
Me.GridColumn2.VisibleIndex = 1
'
'GridColumn3
'
Me.GridColumn3.Caption = "GridColumn3"
Me.GridColumn3.FieldName = "Selected"
Me.GridColumn3.Name = "GridColumn3"
Me.GridColumn3.Visible = True
Me.GridColumn3.VisibleIndex = 2
'
'SplitContainerControl2
'
Me.SplitContainerControl2.Dock = System.Windows.Forms.DockStyle.Fill
Me.SplitContainerControl2.Horizontal = False
Me.SplitContainerControl2.Location = New System.Drawing.Point(0, 0)
Me.SplitContainerControl2.Name = "SplitContainerControl2"
Me.SplitContainerControl2.Panel1.Controls.Add(Me.SplitContainerControl3)
Me.SplitContainerControl2.Panel1.Text = "Panel1"
Me.SplitContainerControl2.Panel2.Controls.Add(Me.SplitContainerControl4)
Me.SplitContainerControl2.Panel2.Text = "Panel2"
Me.SplitContainerControl2.Size = New System.Drawing.Size(880, 564)
Me.SplitContainerControl2.SplitterPosition = 288
Me.SplitContainerControl2.TabIndex = 0
'
'SplitContainerControl3
'
Me.SplitContainerControl3.Dock = System.Windows.Forms.DockStyle.Fill
Me.SplitContainerControl3.Horizontal = False
Me.SplitContainerControl3.Location = New System.Drawing.Point(0, 0)
Me.SplitContainerControl3.Name = "SplitContainerControl3"
Me.SplitContainerControl3.Panel1.Text = "Panel1"
Me.SplitContainerControl3.Panel2.Text = "Panel2"
Me.SplitContainerControl3.Size = New System.Drawing.Size(880, 288)
Me.SplitContainerControl3.SplitterPosition = 118
Me.SplitContainerControl3.TabIndex = 0
'
'SplitContainerControl4
'
Me.SplitContainerControl4.Dock = System.Windows.Forms.DockStyle.Fill
Me.SplitContainerControl4.Horizontal = False
Me.SplitContainerControl4.Location = New System.Drawing.Point(0, 0)
Me.SplitContainerControl4.Name = "SplitContainerControl4"
Me.SplitContainerControl4.Panel1.Text = "Panel1"
Me.SplitContainerControl4.Panel2.Text = "Panel2"
Me.SplitContainerControl4.Size = New System.Drawing.Size(880, 266)
Me.SplitContainerControl4.SplitterPosition = 126
Me.SplitContainerControl4.TabIndex = 0
'
'UnboundSource1
'
UnboundSourceProperty1.DisplayName = Nothing
UnboundSourceProperty1.Name = "Property0"
Me.UnboundSource1.Properties.Add(UnboundSourceProperty1)
'
'BarButtonItem2
'
Me.BarButtonItem2.Caption = "Export"
Me.BarButtonItem2.Id = 4
Me.BarButtonItem2.Name = "BarButtonItem2"
'
'frmImportMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1215, 746)
Me.Controls.Add(Me.SplitContainerControl1)
Me.Controls.Add(Me.RibbonStatusBar)
Me.Controls.Add(Me.RibbonControl)
Me.Name = "frmImportMain"
Me.Ribbon = Me.RibbonControl
Me.StatusBar = Me.RibbonStatusBar
Me.Text = "frmImportMain"
CType(Me.RibbonControl, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.SplitContainerControl1, System.ComponentModel.ISupportInitialize).EndInit()
Me.SplitContainerControl1.ResumeLayout(False)
CType(Me.GridControlFiles, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.GridViewFiles, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.SplitContainerControl2, System.ComponentModel.ISupportInitialize).EndInit()
Me.SplitContainerControl2.ResumeLayout(False)
CType(Me.SplitContainerControl3, System.ComponentModel.ISupportInitialize).EndInit()
Me.SplitContainerControl3.ResumeLayout(False)
CType(Me.SplitContainerControl4, System.ComponentModel.ISupportInitialize).EndInit()
Me.SplitContainerControl4.ResumeLayout(False)
CType(Me.UnboundSource1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents RibbonControl As DevExpress.XtraBars.Ribbon.RibbonControl
Friend WithEvents RibbonPage1 As DevExpress.XtraBars.Ribbon.RibbonPage
Friend WithEvents RibbonPageGroup1 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents RibbonStatusBar As DevExpress.XtraBars.Ribbon.RibbonStatusBar
Friend WithEvents SplitContainerControl1 As DevExpress.XtraEditors.SplitContainerControl
Friend WithEvents GridControlFiles As DevExpress.XtraGrid.GridControl
Friend WithEvents GridViewFiles As DevExpress.XtraGrid.Views.Grid.GridView
Friend WithEvents txtVersion As DevExpress.XtraBars.BarStaticItem
Friend WithEvents txtFilesLoaded As DevExpress.XtraBars.BarStaticItem
Friend WithEvents BarButtonItem1 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents SplitContainerControl2 As DevExpress.XtraEditors.SplitContainerControl
Friend WithEvents SplitContainerControl3 As DevExpress.XtraEditors.SplitContainerControl
Friend WithEvents SplitContainerControl4 As DevExpress.XtraEditors.SplitContainerControl
Friend WithEvents GridColumn1 As DevExpress.XtraGrid.Columns.GridColumn
Friend WithEvents GridColumn2 As DevExpress.XtraGrid.Columns.GridColumn
Friend WithEvents GridColumn3 As DevExpress.XtraGrid.Columns.GridColumn
Friend WithEvents UnboundSource1 As DevExpress.Data.UnboundSource
Friend WithEvents BarButtonItem2 As DevExpress.XtraBars.BarButtonItem
End Class

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="UnboundSource1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,209 @@
Imports System.ComponentModel
Imports System.IO
Imports System.Xml
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.Controls.SQLConfig
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports ImporterShared
Imports ImporterShared.Documents
Imports ImporterShared.Schemas
Imports ImporterShared.Winline
Public Class frmImportMain
Private LogConfig As LogConfig
Private Logger As Logger
Private ConfigManager As ConfigManager(Of ImporterShared.Config)
Private Database As MSSQLServer
Private Winline As Data
Private WebService As WebService
Private PositionData As PositionData
Private DocumentLoader As Documents.DocumentLoader
Private SchemaLoader As Schemas.SchemaLoader
Private GridLoader As GridLoader
Private Grids As List(Of GridControl)
Private CurrentSchema As String
Private Sub frmImportMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
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)
ConfigManager = New ConfigManager(Of ImporterShared.Config)(LogConfig,
Application.UserAppDataPath,
Application.CommonAppDataPath,
Application.StartupPath)
' 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()
If oResult = DialogResult.OK Then
ConfigManager.Config.ConnectionString = oForm.ConnectionString
ConfigManager.Save()
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)
For Each oMandator In Winline.Mandators
Winline.LoadAccounts(oMandator)
Next
DocumentLoader = New DocumentLoader(LogConfig, Winline)
SchemaLoader = New SchemaLoader(LogConfig)
GridLoader = New GridLoader(LogConfig)
SchemaLoader.LoadFiles(ConfigManager.Config.SchemaDirectory)
CurrentSchema = SchemaLoader.SchemaList.First().FullName
Dim oSchema = SchemaLoader.GetSchemaFromFile(CurrentSchema)
Grids = CreateGridsAndColumns(oSchema)
End Sub
Private Function CreateGridsAndColumns(pSchema As Schemas.Schema) As List(Of GridControl)
Dim oGrids As New List(Of GridControl)
Dim oTableCounter = 0
For Each oTable In pSchema.Tables
If oTableCounter = 0 Then
Dim oGrid = GridLoader.GetGridFromElement(oTable)
SplitContainerControl3.Panel1.Controls.Add(oGrid)
oGrids.Add(oGrid)
End If
If oTableCounter = 1 Then
Dim oGrid = GridLoader.GetGridFromElement(oTable)
SplitContainerControl3.Panel2.Controls.Add(oGrid)
oGrids.Add(oGrid)
End If
If oTableCounter = 2 Then
Dim oGrid = GridLoader.GetGridFromElement(oTable)
SplitContainerControl4.Panel1.Controls.Add(oGrid)
oGrids.Add(oGrid)
End If
If oTableCounter = 3 Then
Dim oGrid = GridLoader.GetGridFromElement(oTable)
SplitContainerControl4.Panel2.Controls.Add(oGrid)
oGrids.Add(oGrid)
End If
If oTableCounter > 3 Then
MsgBox("Only 4 Tables are allowed currently!", MsgBoxStyle.Exclamation, Text)
End If
oTableCounter += 1
Next
If oTableCounter < 3 Then
SplitContainerControl2.PanelVisibility = DevExpress.XtraEditors.SplitPanelVisibility.Panel1
End If
Return oGrids
End Function
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory) Then
GridControlFiles.DataSource = DocumentLoader.Files
End If
End Sub
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
Dim oDatasources As New Dictionary(Of String, DataTable)
For Each oRow In oDocument.Rows
Dim oGrid As GridControl = Grids.
Where(Function(g) g.Name = oRow.Name).
SingleOrDefault()
If Not oDatasources.ContainsKey(oRow.Name) Then
Dim oTable As New DataTable()
For Each ofield In oRow.Fields
oTable.Columns.Add(New DataColumn(ofield.Key))
Next
oDatasources.Add(oRow.Name, oTable)
oGrid.DataSource = oTable
End If
Dim oDataTable = oDatasources.Item(oRow.Name)
Dim oDataRow = oDataTable.NewRow()
For Each oField In oRow.Fields
oDataRow.Item(oField.Key) = oField.Value
Next
oDataTable.Rows.Add(oDataRow)
oDataTable.AcceptChanges()
Next
End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Using oStream As New MemoryStream()
Dim w = XmlWriter.Create(oStream)
w.WriteStartDocument()
w.WriteStartElement("MESOWebService")
w.WriteAttributeString("Template", oDocument.TemplateName)
w.WriteAttributeString("TemplateType", oDocument.TemplateType)
w.WriteAttributeString("option", oDocument.Option)
w.WriteAttributeString("printVoucher", oDocument.PrintVoucher)
For Each oRow In oDocument.Rows
w.WriteStartElement(oRow.Name)
For Each oField As KeyValuePair(Of String, String) In oRow.Fields
w.WriteStartElement(oField.Key)
w.WriteValue(oField.Value)
w.WriteEndElement() ' Field
Next
w.WriteEndElement() ' Row
Next
w.WriteEndElement() ' MESOWebService
w.WriteEndDocument() ' Document
w.Close()
File.WriteAllBytes(ConfigManager.Config.OutputDirectory, oStream.ToArray)
End Using
End Sub
End Class

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,142 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ApplicationMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>196, 17</value>
</metadata>
<assembly alias="DevExpress.Data.v19.2" name="DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<data name="colSelected.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjE5LjIsIFZlcnNpb249MTkuMi4z
LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAAHICAAAC77u/
PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgeD0iMHB4IiB5PSIwcHgi
IHZpZXdCb3g9IjAgMCAzMiAzMiIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv
MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3Bh
Y2U9InByZXNlcnZlIiBpZD0iTGF5ZXJfMSIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAg
MzIgMzIiPg0KICA8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLkJsdWV7ZmlsbDojMTE3N0Q3O30KCS5Z
ZWxsb3d7ZmlsbDojRkZCMTE1O30KCS5CbGFja3tmaWxsOiM3MjcyNzI7fQoJLkdyZWVue2ZpbGw6IzAz
OUMyMzt9CgkuUmVke2ZpbGw6I0QxMUMxQzt9Cgkuc3Qwe29wYWNpdHk6MC43NTt9Cgkuc3Qxe29wYWNp
dHk6MC41O30KPC9zdHlsZT4NCiAgPGcgaWQ9IkNoZWNrQ2lyY2xlZCI+DQogICAgPHBhdGggZD0iTTE2
LDRDOS40LDQsNCw5LjQsNCwxNmMwLDYuNiw1LjQsMTIsMTIsMTJzMTItNS40LDEyLTEyQzI4LDkuNCwy
Mi42LDQsMTYsNHogTTE0LDIybC02LTZsMi0ybDQsNGw4LThsMiwyICAgTDE0LDIyeiIgY2xhc3M9Ikdy
ZWVuIiAvPg0KICA8L2c+DQo8L3N2Zz4L
</value>
</data>
</root>

View File

@ -0,0 +1,509 @@
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
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
Public Logger As Logger
Public ConfigManager As ConfigManager(Of ImporterShared.Config)
Public Database As MSSQLServer
Public DocumentLoader As DocumentLoader
Public GridBuilder As GridBuilder
Public PositionData As PositionData
Public Winline As Data
Public WebService As WebService
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
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)
ConfigManager = New ConfigManager(Of ImporterShared.Config)(LogConfig,
Application.UserAppDataPath,
Application.CommonAppDataPath,
Application.StartupPath)
' 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()
If oResult = DialogResult.OK Then
ConfigManager.Config.ConnectionString = oForm.ConnectionString
ConfigManager.Save()
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)
For Each oMandator In Winline.Mandators
Winline.LoadAccounts(oMandator)
Next
' Load data for UI Fields
cmbMandator.Properties.DataSource = Winline.Mandators
cmbYear.Properties.Items.AddRange(Winline.Years)
cmbYear.SelectedItem = ConfigManager.Config.GetYear()
' Initialize Grids
GridBuilder = New GridBuilder(New List(Of GridView) From {GridViewFiles, GridViewPositions})
GridBuilder.WithDefaults()
PositionGrid.LoadPositionViewAndColumns(GridViewPositions, DocumentType.Order)
' Construct classes related to the xml data
DocumentLoader = New DocumentLoader(LogConfig, Winline)
Catch ex As Exception
Logger.Error(ex)
Dim oMessage = GetErrorMessage(ex, "Fehler beim Laden der Anwendung")
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
End Try
End Sub
#Region "Helpers"
Private Function GetValidationMessage(FieldName As String) As String
Return $"Das Feld '{FieldName}' muss ausgefüllt werden!"
End Function
Private Function GetErrorMessage(pException As Exception, pErrorText As String)
Return $"{pErrorText}:{vbNewLine}{vbNewLine}{pException.Message}"
End Function
Private Function GetFocusedDocument() As Document
Dim oRowHandles = GridViewFiles.GetSelectedRows().ToList()
Dim oDocument As Document = GridViewFiles.GetRow(oRowHandles.First())
Return oDocument
End Function
Private Function GetFocusedPosition() As Position
Dim oRowHandles = GridViewPositions.GetSelectedRows().ToList()
Dim oPosition As Position = GridViewPositions.GetRow(oRowHandles.First())
Return oPosition
End Function
Private Sub TryOpenDirectory(pPath As String, pDisplayName As String)
If Directory.Exists(pPath) Then
Process.Start(pPath)
Else
MsgBox($"{pDisplayName} nicht konfiguriert oder nicht gefunden!", MsgBoxStyle.Exclamation, Text)
End If
End Sub
#End Region
Private Sub btnLoadDocuments_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLoadDocuments.ItemClick
Try
If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory) = True Then
RibbonGroupDataTransmission.Enabled = True
RibbonGroupDocument.Enabled = True
RibbonGroupPositions.Enabled = True
LayoutControlHead.Enabled = True
GridControlPositions.Enabled = True
btnReloadDocument.Enabled = True
GridControlFiles.DataSource = DocumentLoader.Files
txtFilesLoaded.Caption = $"{DocumentLoader.Files.Count} Dokumente geladen"
End If
Catch ex As Exception
Dim oMessage = ex.Message
If ex.InnerException IsNot Nothing Then
oMessage &= vbNewLine & vbNewLine & ex.InnerException.Message
End If
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
End Try
End Sub
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
If oDocument Is Nothing Then
Exit Sub
End If
ShowDocument(oDocument)
End Sub
Private Sub ShowDocument(pDocument As Document)
' Load XML File in the sidebar
RichEditXml.LoadDocument(pDocument.FullName, DocumentFormat.PlainText)
If pDocument.Mandator Is Nothing Then
Dim oForm As New frmMandatorSelection() With {
.Mandators = Winline.Mandators,
.SelectedMandator = Nothing
}
Dim oResult = oForm.ShowDialog()
If oResult <> DialogResult.OK Then
Exit Sub
End If
pDocument.Mandator = oForm.SelectedMandator.Id
End If
Try
Select Case pDocument.Type
Case DocumentType.Order
MsgBox("TODO")
'ShowOrderDocument(pDocument)
End Select
Catch ex As Xml.XmlException
Dim oMessage = GetErrorMessage(ex, "Fehler beim Laden des Dokuments")
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Logger.Error(ex)
Catch ex As Exceptions.NoMandatorException
Dim oMessage = GetErrorMessage(ex, "Fehler beim Laden des Dokuments")
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Logger.Error(ex)
Catch ex As Exception
Dim oMessage = GetErrorMessage(ex, "Fehler beim Laden des Dokuments")
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Logger.Error(ex)
End Try
End Sub
'Private Sub ShowOrderDocument(pDocument As Document)
' If pDocument.Mandator Is Nothing Then
' Throw New Exceptions.NoMandatorException("Es konnte kein Mandant gefunden werden")
' End If
' Dim oData As Orders.Input.MESOWebService = DirectCast(pDocument.Data, Orders.Input.MESOWebService)
' Dim oDataOriginal As Orders.Input.MESOWebService = DirectCast(pDocument.DataOriginal, Orders.Input.MESOWebService)
' Dim oHead = Orders.Helpers.GetOrderHead(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oData)
' Dim oHeadOriginal = Orders.Helpers.GetOrderHead(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oDataOriginal)
' ' --- Head Data --------------------------------------------------------------------------------------
' ' Original, Unreplaced Data
' txtCustomerGLN.Text = oHeadOriginal.Fakt_Kontonummer
' txtDeliveryAddressGLN.Text = oHeadOriginal.Lief_Kontonummer
' ' Regular Data from EDI
' txtRunningNumber.Text = oHead.Laufnummer
' cmbOrderIssuer.Text = oHead.Bestellt_Von
' txtOrderNumber.Text = oHead.Auftragsreferenz
' txtInfoText.Text = oHead.Infotext
' Try
' dateOrderDate.EditValue = Date.ParseExact(oHead.Datum_AuftragBestellung, "yyyy-MM-dd", Globalization.CultureInfo.InvariantCulture)
' Catch ex As Exception
' dateOrderDate.EditValue = Nothing
' End Try
' ' --- Find Mandator --------------------------------------------------------------------------------------
' Dim oMandator = Winline.Mandators.
' Where(Function(m) m.Id = pDocument.Mandator).
' SingleOrDefault()
' cmbMandator.EditValue = oMandator
' ' --- Find DocumentKinds ---------------------------------------------------------------------------------
' Dim oMandatorKinds = Winline.DocumentKinds.
' Where(Function(k) k.Mandator = oMandator.Id).
' ToList()
' Dim oSelectedKind = oMandatorKinds.
' Where(Function(k) k.Id.ToString = oHead.Belegart).
' SingleOrDefault()
' cmbDocumentKind.Properties.Items.Clear()
' cmbDocumentKind.Properties.Items.AddRange(oMandatorKinds)
' If oSelectedKind Is Nothing Then
' cmbDocumentKind.ErrorText = "Es wurde keine passende Belegart gefunden."
' cmbDocumentKind.SelectedItem = Nothing
' Else
' cmbDocumentKind.SelectedItem = oSelectedKind
' End If
' ' --- Find Accounts --------------------------------------------------------------------------------------
' Dim oMandatorAccounts = Winline.Accounts.
' Where(Function(a) a.Mandator = oMandator.Id).
' ToList()
' cmbCustomer.Properties.DataSource = oMandatorAccounts
' cmbDeliveryAddress.Properties.DataSource = oMandatorAccounts
' ' FAKTURA
' If oHead.Fakt_Kontonummer = oHeadOriginal.Fakt_Kontonummer Then
' cmbCustomer.ErrorText = GetValidationMessage("Faktura Konto")
' cmbCustomer.EditValue = Nothing
' Else
' Dim oMatchingAccounts = oMandatorAccounts.
' Where(Function(oAccount) oAccount.Id = oHead.Fakt_Kontonummer)
' If oMatchingAccounts.Count() > 1 Then
' cmbCustomer.EditValue = Nothing
' cmbCustomer.ErrorText = "Für die Kontonummer wurden mehrere Konten gefunden."
' ElseIf oMatchingAccounts.Count() = 0 Then
' cmbCustomer.EditValue = Nothing
' cmbCustomer.ErrorText = "Für die Kontonummer wurde kein Konto gefunden."
' Else
' cmbCustomer.EditValue = oMatchingAccounts.SingleOrDefault()
' End If
' End If
' ' CONTACTS
' If cmbCustomer.EditValue IsNot Nothing Then
' Dim oContacts = Winline.GetContacts(oHead.Fakt_Kontonummer, oMandator)
' cmbOrderIssuer.Properties.DataSource = oContacts
' End If
' ' DEVLIERY
' If oHead.Lief_Kontonummer = oHeadOriginal.Lief_Kontonummer Then
' If oHeadOriginal.Lief_Kontonummer = String.Empty Then
' txtPlace.EditValue = oHeadOriginal.Lief_Ort
' txtZIP.EditValue = oHeadOriginal.Lief_PLZ
' txtStreetName.EditValue = oHeadOriginal.Lief_Strasse
' txtName.EditValue = oHeadOriginal.Lief_Name
' Else
' cmbDeliveryAddress.ErrorText = GetValidationMessage("Lieferanten Konto")
' cmbDeliveryAddress.EditValue = Nothing
' End If
' Else
' Dim oMatchingAccounts = oMandatorAccounts.
' Where(Function(oAccount) oAccount.Id = oHead.Lief_Kontonummer)
' If oMatchingAccounts.Count() > 1 Then
' cmbDeliveryAddress.EditValue = Nothing
' cmbDeliveryAddress.ErrorText = "Für die Kontonummer wurden mehrere Konten gefunden."
' ElseIf oMatchingAccounts.Count() = 0 Then
' cmbDeliveryAddress.EditValue = Nothing
' cmbDeliveryAddress.ErrorText = "Für die Kontonummer wurde kein Konto gefunden."
' Else
' cmbDeliveryAddress.EditValue = oMatchingAccounts.SingleOrDefault()
' End If
' End If
' ' --- Find Positions ------------------------------------------------------------------------------------
' Dim oPositionList = PositionData.Load(oMandator, oData, oDataOriginal)
' GridControlPositions.DataSource = oPositionList
' GridViewPositions.BestFitColumns()
'End Sub
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
TryOpenDirectory(ConfigManager.Config.InputDirectory, "Eingangsverzeichnis")
End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
TryOpenDirectory(ConfigManager.Config.OutputDirectory, "Ausgangsverzeichnis")
End Sub
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
Dim oUserConfigDirectory = New FileInfo(ConfigManager.UserConfigPath).Directory
TryOpenDirectory(oUserConfigDirectory.FullName, "Konfigurationsverzeichnis")
End Sub
Private Sub checkShowXml_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles checkShowXml.CheckedChanged
SplitContainerControl3.Collapsed = Not checkShowXml.Checked
End Sub
'Private Async Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
' Dim oMessageText As String = ""
' Dim oMessageStyle As MsgBoxStyle = MsgBoxStyle.Critical
' Dim oDocument As Document = GetFocusedDocument()
' If oDocument Is Nothing Then
' Exit Sub
' End If
' SplashScreenManager1.ShowWaitForm()
' ChangeUIState(False)
' Try
' Dim oFinalDocument As Document = TransferChangesToDocument(oDocument)
' Dim oResult = Await WebService.TransferDocumentToWinLine(oFinalDocument)
' oMessageText = "Beleg wurde erfolgreich übertragen!"
' oMessageStyle = MsgBoxStyle.Information
' Catch ex As Exception
' Logger.Error(ex)
' oMessageText = $"Fehler beim Übertragen des Dokuments:{vbNewLine}{vbNewLine}{ex.Message}"
' oMessageStyle = MsgBoxStyle.Critical
' Finally
' SplashScreenManager1.CloseWaitForm()
' ChangeUIState(True)
' MsgBox(oMessageText, oMessageStyle, Text)
' End Try
'End Sub
Private Sub ChangeUIState(pEnabled As Boolean)
GridControlPositions.Enabled = pEnabled
GridControlFiles.Enabled = pEnabled
LayoutControlHead.Enabled = pEnabled
RibbonGroupDataTransmission.Enabled = pEnabled
RibbonGroupDataLoading.Enabled = pEnabled
RibbonGroupDocument.Enabled = pEnabled
RibbonGroupPositions.Enabled = pEnabled
End Sub
'Private Function TransferChangesToDocument(pDocument As Document)
' Dim oData As Orders.Input.MESOWebService = pDocument.Data
' Try
' Orders.Helpers.SetOrderHead(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oData, AddressOf UpdateOrderHead)
' Catch ex As Exception
' Logger.Error(ex)
' Throw ex
' End Try
' Return pDocument
'End Function
'Private Function UpdateOrderHead(pObject As Orders.Input.MESOWebServiceEXIMVRG_ordersT025) As Orders.Input.MESOWebServiceEXIMVRG_ordersT025
' ' Update DocumentKind
' If cmbDocumentKind.EditValue IsNot Nothing AndAlso TypeOf cmbDocumentKind.EditValue Is DocumentKind Then
' pObject.Belegart = DirectCast(cmbDocumentKind.EditValue, DocumentKind).Id
' End If
' ' Update Talking Person lol
' If cmbOrderIssuer.EditValue IsNot Nothing AndAlso TypeOf cmbOrderIssuer.EditValue Is Contact Then
' pObject.Bestellt_Von = DirectCast(cmbOrderIssuer.EditValue, Contact).Id
' End If
' ' Update Delivery Address
' If cmbDeliveryAddress.EditValue IsNot Nothing AndAlso TypeOf cmbDeliveryAddress.EditValue Is Account Then
' pObject.Lief_Kontonummer = DirectCast(cmbDeliveryAddress.EditValue, Account)?.Id
' End If
' ' Update Order Number
' If txtOrderNumber.EditValue IsNot Nothing AndAlso txtOrderNumber.EditValue <> String.Empty Then
' pObject.Auftragsreferenz = txtOrderNumber.EditValue
' End If
' ' Update Order Date
' If dateOrderDate IsNot Nothing Then
' pObject.Datum_AuftragBestellung = DirectCast(dateOrderDate.EditValue, Date).ToString("yyyy-MM-dd")
' End If
' ' Update Extra Address
' pObject.Lief_Name = txtName.EditValue
' pObject.Lief_Ort = txtPlace.EditValue
' pObject.Lief_PLZ = txtZIP.EditValue
' pObject.Lief_Strasse = txtStreetName.EditValue
' Return pObject
'End Function
Private Sub BarButtonItem8_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem8.ItemClick
TryOpenDirectory(LogConfig.LogDirectory, "Logverzeichnis")
End Sub
Private Sub cmbCustomer_Validating(sender As BaseEdit, e As System.ComponentModel.CancelEventArgs) Handles cmbCustomer.Validating, cmbDocumentKind.Validating, cmbMandator.Validating, cmbYear.Validating
If sender.EditValue Is Nothing Then
sender.ErrorText = "Dieses Feld muss ausgefüllt werden"
Else
sender.ErrorText = ""
End If
End Sub
'Private Sub btnPreviewReport_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnPreviewReport.ItemClick
' Dim oDocument As Document = GetFocusedDocument()
' If oDocument Is Nothing Then
' Exit Sub
' End If
' Dim oReport As New OrderReport()
' Dim oDataSource = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource With {
' .DataSource = New Orders.ReportSource With {
' .Head = Orders.Helpers.GetOrderHead(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oDocument.Data),
' .Positions = Orders.Helpers.GetOrderPositions(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oDocument.Data)
' }
' }
' oDataSource.Fill()
' oReport.DataSource = oDataSource
' Dim oReportPrintTool As New ReportPrintTool(oReport)
' oReportPrintTool.ShowPreview()
'End Sub
Private Sub btnReloadDocument_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReloadDocument.ItemClick
Dim oResult = MsgBox("Wenn sie das Dokument neu laden, werden alle manuell geänderten Wert verworfen. Wollen Sie fortfahren?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question, Text)
If oResult = MsgBoxResult.Yes Then
Dim oDocument As Document = GetFocusedDocument()
If oDocument Is Nothing Then
Exit Sub
End If
ShowDocument(oDocument)
End If
End Sub
Private Sub btnDeletePosition_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeletePosition.ItemClick
Dim oPosition = GetFocusedPosition()
If oPosition Is Nothing Then
MsgBox("Bitte wählen Sie eine Position aus!", MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
Dim oResult = MsgBox($"Wollen Sie die ausgewählte Position Artikel [{oPosition.ArticleNumber}] wirklich löschen?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text)
If oResult = MsgBoxResult.Yes Then
GridViewPositions.DeleteSelectedRows()
MsgBox("Position gelöscht")
End If
End Sub
Private Sub BarButtonItem7_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem7.ItemClick
MsgBox("Mach et!")
End Sub
Private Sub BarButtonItem6_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs)
Dim oUserConfigDirectory = New FileInfo(ConfigManager.UserConfigPath).Directory
TryOpenDirectory(oUserConfigDirectory.FullName, "Konfigurationsverzeichnis")
End Sub
End Class

File diff suppressed because it is too large Load Diff

View File

@ -117,26 +117,4 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ApplicationMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="DevExpress.Data.v19.2" name="DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<data name="colSelected.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjE5LjIsIFZlcnNpb249MTkuMi4z
LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAAHICAAAC77u/
PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgeD0iMHB4IiB5PSIwcHgi
IHZpZXdCb3g9IjAgMCAzMiAzMiIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv
MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3Bh
Y2U9InByZXNlcnZlIiBpZD0iTGF5ZXJfMSIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAg
MzIgMzIiPg0KICA8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLkJsdWV7ZmlsbDojMTE3N0Q3O30KCS5Z
ZWxsb3d7ZmlsbDojRkZCMTE1O30KCS5CbGFja3tmaWxsOiM3MjcyNzI7fQoJLkdyZWVue2ZpbGw6IzAz
OUMyMzt9CgkuUmVke2ZpbGw6I0QxMUMxQzt9Cgkuc3Qwe29wYWNpdHk6MC43NTt9Cgkuc3Qxe29wYWNp
dHk6MC41O30KPC9zdHlsZT4NCiAgPGcgaWQ9IkNoZWNrQ2lyY2xlZCI+DQogICAgPHBhdGggZD0iTTE2
LDRDOS40LDQsNCw5LjQsNCwxNmMwLDYuNiw1LjQsMTIsMTIsMTJzMTItNS40LDEyLTEyQzI4LDkuNCwy
Mi42LDQsMTYsNHogTTE0LDIybC02LTZsMi0ybDQsNGw4LThsMiwyICAgTDE0LDIyeiIgY2xhc3M9Ikdy
ZWVuIiAvPg0KICA8L2c+DQo8L3N2Zz4L
</value>
</data>
</root>

View File

@ -1,510 +1,3 @@
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
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 frmMain
Public Class frmMain
Public LogConfig As LogConfig
Public Logger As Logger
Public ConfigManager As ConfigManager(Of ImporterShared.Config)
Public Database As MSSQLServer
Public DocumentLoader As DocumentLoader
Public GridBuilder As GridBuilder
Public PositionData As PositionData
Public Winline As Data
Public WebService As WebService
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
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)
ConfigManager = New ConfigManager(Of ImporterShared.Config)(LogConfig,
Application.UserAppDataPath,
Application.CommonAppDataPath,
Application.StartupPath)
' 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()
If oResult = DialogResult.OK Then
ConfigManager.Config.ConnectionString = oForm.ConnectionString
ConfigManager.Save()
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)
For Each oMandator In Winline.Mandators
Winline.LoadAccounts(oMandator)
Next
' Load data for UI Fields
cmbMandator.Properties.DataSource = Winline.Mandators
cmbYear.Properties.Items.AddRange(Winline.Years)
cmbYear.SelectedItem = ConfigManager.Config.GetYear()
' Initialize Grids
GridBuilder = New GridBuilder(New List(Of GridView) From {GridViewFiles, GridViewPositions})
GridBuilder.WithDefaults()
PositionGrid.LoadPositionViewAndColumns(GridViewPositions, DocumentType.Order)
' Construct classes related to the xml data
DocumentLoader = New DocumentLoader(LogConfig, Winline)
Catch ex As Exception
Logger.Error(ex)
Dim oMessage = GetErrorMessage(ex, "Fehler beim Laden der Anwendung")
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
End Try
End Sub
#Region "Helpers"
Private Function GetValidationMessage(FieldName As String) As String
Return $"Das Feld '{FieldName}' muss ausgefüllt werden!"
End Function
Private Function GetErrorMessage(pException As Exception, pErrorText As String)
Return $"{pErrorText}:{vbNewLine}{vbNewLine}{pException.Message}"
End Function
Private Function GetFocusedDocument() As Document
Dim oRowHandles = GridViewFiles.GetSelectedRows().ToList()
Dim oDocument As Document = GridViewFiles.GetRow(oRowHandles.First())
Return oDocument
End Function
Private Function GetFocusedPosition() As Position
Dim oRowHandles = GridViewPositions.GetSelectedRows().ToList()
Dim oPosition As Position = GridViewPositions.GetRow(oRowHandles.First())
Return oPosition
End Function
Private Sub TryOpenDirectory(pPath As String, pDisplayName As String)
If Directory.Exists(pPath) Then
Process.Start(pPath)
Else
MsgBox($"{pDisplayName} nicht konfiguriert oder nicht gefunden!", MsgBoxStyle.Exclamation, Text)
End If
End Sub
#End Region
Private Sub btnLoadDocuments_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnLoadDocuments.ItemClick
Try
If DocumentLoader.LoadFiles(ConfigManager.Config.InputDirectory) = True Then
RibbonGroupDataTransmission.Enabled = True
RibbonGroupDocument.Enabled = True
RibbonGroupPositions.Enabled = True
LayoutControlHead.Enabled = True
GridControlPositions.Enabled = True
btnReloadDocument.Enabled = True
GridControlFiles.DataSource = DocumentLoader.Files
txtFilesLoaded.Caption = $"{DocumentLoader.Files.Count} Dokumente geladen"
End If
Catch ex As Exception
Dim oMessage = ex.Message
If ex.InnerException IsNot Nothing Then
oMessage &= vbNewLine & vbNewLine & ex.InnerException.Message
End If
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
End Try
End Sub
Private Sub GridViewFiles_FocusedRowChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs) Handles GridViewFiles.FocusedRowChanged
Dim oDocument As Document = GridViewFiles.GetRow(e.FocusedRowHandle)
If oDocument Is Nothing Then
Exit Sub
End If
ShowDocument(oDocument)
End Sub
Private Sub ShowDocument(pDocument As Document)
' Load XML File in the sidebar
RichEditXml.LoadDocument(pDocument.FullName, DocumentFormat.PlainText)
If pDocument.Mandator Is Nothing Then
Dim oForm As New frmMandatorSelection() With {
.Mandators = Winline.Mandators,
.SelectedMandator = Nothing
}
Dim oResult = oForm.ShowDialog()
If oResult <> DialogResult.OK Then
Exit Sub
End If
pDocument.Mandator = oForm.SelectedMandator.Id
End If
Try
Select Case pDocument.Type
Case DocumentType.Order
ShowOrderDocument(pDocument)
End Select
Catch ex As Xml.XmlException
Dim oMessage = GetErrorMessage(ex, "Fehler beim Laden des Dokuments")
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Logger.Error(ex)
Catch ex As Exceptions.NoMandatorException
Dim oMessage = GetErrorMessage(ex, "Fehler beim Laden des Dokuments")
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Logger.Error(ex)
Catch ex As Exception
Dim oMessage = GetErrorMessage(ex, "Fehler beim Laden des Dokuments")
MsgBox(oMessage, MsgBoxStyle.Critical, Text)
Logger.Error(ex)
End Try
End Sub
Private Sub ShowOrderDocument(pDocument As Document)
If pDocument.Mandator Is Nothing Then
Throw New Exceptions.NoMandatorException("Es konnte kein Mandant gefunden werden")
End If
Dim oData As Orders.Input.MESOWebService = DirectCast(pDocument.Data, Orders.Input.MESOWebService)
Dim oDataOriginal As Orders.Input.MESOWebService = DirectCast(pDocument.DataOriginal, Orders.Input.MESOWebService)
Dim oHead = Orders.Helpers.GetOrderHead(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oData)
Dim oHeadOriginal = Orders.Helpers.GetOrderHead(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oDataOriginal)
' --- Head Data --------------------------------------------------------------------------------------
' Original, Unreplaced Data
txtCustomerGLN.Text = oHeadOriginal.Fakt_Kontonummer
txtDeliveryAddressGLN.Text = oHeadOriginal.Lief_Kontonummer
' Regular Data from EDI
txtRunningNumber.Text = oHead.Laufnummer
cmbOrderIssuer.Text = oHead.Fakt_Ansprechpartner
txtOrderNumber.Text = oHead.Auftragsreferenz
txtInfoText.Text = oHead.Infotext
Try
dateOrderDate.EditValue = Date.ParseExact(oHead.Datum_AuftragBestellung, "yyyy-MM-dd", Globalization.CultureInfo.InvariantCulture)
Catch ex As Exception
dateOrderDate.EditValue = Nothing
End Try
' --- Find Mandator --------------------------------------------------------------------------------------
Dim oMandator = Winline.Mandators.
Where(Function(m) m.Id = pDocument.Mandator).
SingleOrDefault()
cmbMandator.EditValue = oMandator
' --- Find DocumentKinds ---------------------------------------------------------------------------------
Dim oMandatorKinds = Winline.DocumentKinds.
Where(Function(k) k.Mandator = oMandator.Id).
ToList()
Dim oSelectedKind = oMandatorKinds.
Where(Function(k) k.Id.ToString = oHead.Belegart).
SingleOrDefault()
cmbDocumentKind.Properties.Items.Clear()
cmbDocumentKind.Properties.Items.AddRange(oMandatorKinds)
If oSelectedKind Is Nothing Then
cmbDocumentKind.ErrorText = "Es wurde keine passende Belegart gefunden."
cmbDocumentKind.SelectedItem = Nothing
Else
cmbDocumentKind.SelectedItem = oSelectedKind
End If
' --- Find Accounts --------------------------------------------------------------------------------------
Dim oMandatorAccounts = Winline.Accounts.
Where(Function(a) a.Mandator = oMandator.Id).
ToList()
cmbCustomer.Properties.DataSource = oMandatorAccounts
cmbDeliveryAddress.Properties.DataSource = oMandatorAccounts
' FAKTURA
If oHead.Fakt_Kontonummer = oHeadOriginal.Fakt_Kontonummer Then
cmbCustomer.ErrorText = GetValidationMessage("Faktura Konto")
cmbCustomer.EditValue = Nothing
Else
Dim oMatchingAccounts = oMandatorAccounts.
Where(Function(oAccount) oAccount.Id = oHead.Fakt_Kontonummer)
If oMatchingAccounts.Count() > 1 Then
cmbCustomer.EditValue = Nothing
cmbCustomer.ErrorText = "Für die Kontonummer wurden mehrere Konten gefunden."
ElseIf oMatchingAccounts.Count() = 0 Then
cmbCustomer.EditValue = Nothing
cmbCustomer.ErrorText = "Für die Kontonummer wurde kein Konto gefunden."
Else
cmbCustomer.EditValue = oMatchingAccounts.SingleOrDefault()
End If
End If
' CONTACTS
If cmbCustomer.EditValue IsNot Nothing Then
Dim oContacts = Winline.GetContacts(oHead.Fakt_Kontonummer, oMandator)
cmbOrderIssuer.Properties.DataSource = oContacts
End If
' DEVLIERY
If oHead.Lief_Kontonummer = oHeadOriginal.Lief_Kontonummer Then
If oHeadOriginal.Lief_Kontonummer = String.Empty Then
txtPlace.EditValue = oHeadOriginal.Lief_Ort
txtZIP.EditValue = oHeadOriginal.Lief_PLZ
txtStreetName.EditValue = oHeadOriginal.Lief_Strasse
txtName.EditValue = oHeadOriginal.Lief_Name
Else
cmbDeliveryAddress.ErrorText = GetValidationMessage("Lieferanten Konto")
cmbDeliveryAddress.EditValue = Nothing
End If
Else
Dim oMatchingAccounts = oMandatorAccounts.
Where(Function(oAccount) oAccount.Id = oHead.Lief_Kontonummer)
If oMatchingAccounts.Count() > 1 Then
cmbDeliveryAddress.EditValue = Nothing
cmbDeliveryAddress.ErrorText = "Für die Kontonummer wurden mehrere Konten gefunden."
ElseIf oMatchingAccounts.Count() = 0 Then
cmbDeliveryAddress.EditValue = Nothing
cmbDeliveryAddress.ErrorText = "Für die Kontonummer wurde kein Konto gefunden."
Else
cmbDeliveryAddress.EditValue = oMatchingAccounts.SingleOrDefault()
End If
End If
' --- Find Positions ------------------------------------------------------------------------------------
Dim oPositionList = PositionData.Load(oMandator, oData, oDataOriginal)
GridControlPositions.DataSource = oPositionList
GridViewPositions.BestFitColumns()
End Sub
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
TryOpenDirectory(ConfigManager.Config.InputDirectory, "Eingangsverzeichnis")
End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
TryOpenDirectory(ConfigManager.Config.OutputDirectory, "Ausgangsverzeichnis")
End Sub
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
Dim oUserConfigDirectory = New FileInfo(ConfigManager.UserConfigPath).Directory
TryOpenDirectory(oUserConfigDirectory.FullName, "Konfigurationsverzeichnis")
End Sub
Private Sub checkShowXml_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles checkShowXml.CheckedChanged
SplitContainerControl3.Collapsed = Not checkShowXml.Checked
End Sub
Private Async Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
Dim oMessageText As String = ""
Dim oMessageStyle As MsgBoxStyle = MsgBoxStyle.Critical
Dim oDocument As Document = GetFocusedDocument()
If oDocument Is Nothing Then
Exit Sub
End If
SplashScreenManager1.ShowWaitForm()
ChangeUIState(False)
Try
Dim oFinalDocument As Document = TransferChangesToDocument(oDocument)
Dim oResult = Await WebService.TransferDocumentToWinLine(oFinalDocument)
oMessageText = "Beleg wurde erfolgreich übertragen!"
oMessageStyle = MsgBoxStyle.Information
Catch ex As Exception
Logger.Error(ex)
oMessageText = $"Fehler beim Übertragen des Dokuments:{vbNewLine}{vbNewLine}{ex.Message}"
oMessageStyle = MsgBoxStyle.Critical
Finally
SplashScreenManager1.CloseWaitForm()
ChangeUIState(True)
MsgBox(oMessageText, oMessageStyle, Text)
End Try
End Sub
Private Sub ChangeUIState(pEnabled As Boolean)
GridControlPositions.Enabled = pEnabled
GridControlFiles.Enabled = pEnabled
LayoutControlHead.Enabled = pEnabled
RibbonGroupDataTransmission.Enabled = pEnabled
RibbonGroupDataLoading.Enabled = pEnabled
RibbonGroupDocument.Enabled = pEnabled
RibbonGroupPositions.Enabled = pEnabled
End Sub
Private Function TransferChangesToDocument(pDocument As Document)
Dim oData As Orders.Input.MESOWebService = pDocument.Data
Try
Orders.Helpers.SetOrderHead(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oData, AddressOf UpdateOrderHead)
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
Return pDocument
End Function
Private Function UpdateOrderHead(pObject As Orders.Input.MESOWebServiceEXIMVRG_ordersT025) As Orders.Input.MESOWebServiceEXIMVRG_ordersT025
' Update DocumentKind
If cmbDocumentKind.EditValue IsNot Nothing AndAlso TypeOf cmbDocumentKind.EditValue Is DocumentKind Then
pObject.Belegart = DirectCast(cmbDocumentKind.EditValue, DocumentKind).Id
End If
' Update Talking Person lol
If cmbOrderIssuer.EditValue IsNot Nothing AndAlso TypeOf cmbOrderIssuer.EditValue Is Contact Then
pObject.Fakt_Ansprechpartner = DirectCast(cmbOrderIssuer.EditValue, Contact).Id
End If
' Update Delivery Address
If cmbDeliveryAddress.EditValue IsNot Nothing AndAlso TypeOf cmbDeliveryAddress.EditValue Is Account Then
pObject.Lief_Kontonummer = DirectCast(cmbDeliveryAddress.EditValue, Account)?.Id
End If
' Update Order Number
If txtOrderNumber.EditValue IsNot Nothing AndAlso txtOrderNumber.EditValue <> String.Empty Then
pObject.Auftragsreferenz = txtOrderNumber.EditValue
End If
' Update Order Date
If dateOrderDate IsNot Nothing Then
pObject.Datum_AuftragBestellung = DirectCast(dateOrderDate.EditValue, Date).ToString("yyyy-MM-dd")
End If
' Update Extra Address
pObject.Lief_Name = txtName.EditValue
pObject.Lief_Ort = txtPlace.EditValue
pObject.Lief_PLZ = txtZIP.EditValue
pObject.Lief_Strasse = txtStreetName.EditValue
Return pObject
End Function
Private Sub BarButtonItem8_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem8.ItemClick
TryOpenDirectory(LogConfig.LogDirectory, "Logverzeichnis")
End Sub
Private Sub cmbCustomer_Validating(sender As BaseEdit, e As System.ComponentModel.CancelEventArgs) Handles cmbCustomer.Validating, cmbDocumentKind.Validating, cmbMandator.Validating, cmbYear.Validating
If sender.EditValue Is Nothing Then
sender.ErrorText = "Dieses Feld muss ausgefüllt werden"
Else
sender.ErrorText = ""
End If
End Sub
Private Sub btnPreviewReport_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnPreviewReport.ItemClick
Dim oDocument As Document = GetFocusedDocument()
If oDocument Is Nothing Then
Exit Sub
End If
Dim oReport As New OrderReport()
Dim oDataSource = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource With {
.DataSource = New Orders.ReportSource With {
.Head = Orders.Helpers.GetOrderHead(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oDocument.Data),
.Positions = Orders.Helpers.GetOrderPositions(Of Orders.Input.MESOWebServiceEXIMVRG_ordersT025)(oDocument.Data)
}
}
oDataSource.Fill()
oReport.DataSource = oDataSource
Dim oReportPrintTool As New ReportPrintTool(oReport)
oReportPrintTool.ShowPreview()
End Sub
Private Sub btnReloadDocument_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnReloadDocument.ItemClick
Dim oResult = MsgBox("Wenn sie das Dokument neu laden, werden alle manuell geänderten Wert verworfen. Wollen Sie fortfahren?", MsgBoxStyle.YesNo Or MsgBoxStyle.Question, Text)
If oResult = MsgBoxResult.Yes Then
Dim oDocument As Document = GetFocusedDocument()
If oDocument Is Nothing Then
Exit Sub
End If
ShowDocument(oDocument)
End If
End Sub
Private Sub btnDeletePosition_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeletePosition.ItemClick
Dim oPosition = GetFocusedPosition()
If oPosition Is Nothing Then
MsgBox("Bitte wählen Sie eine Position aus!", MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
Dim oResult = MsgBox($"Wollen Sie die ausgewählte Position Artikel [{oPosition.ArticleNumber}] wirklich löschen?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text)
If oResult = MsgBoxResult.Yes Then
GridViewPositions.DeleteSelectedRows()
MsgBox("Position gelöscht")
End If
End Sub
Private Sub BarButtonItem7_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem7.ItemClick
MsgBox("Mach et!")
End Sub
Private Sub BarButtonItem6_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs)
Dim oUserConfigDirectory = New FileInfo(ConfigManager.UserConfigPath).Directory
TryOpenDirectory(oUserConfigDirectory.FullName, "Konfigurationsverzeichnis")
End Sub
End Class

View File

@ -1,8 +1,12 @@
Public Class Config
Public Property ConnectionString As String = ""
Public Property Mandators As New List(Of MandatorConfig)
Public Property InputDirectory As String = ""
Public Property OutputDirectory As String = ""
Public Property SchemaDirectory As String = ""
Public Property Webservice As New WebServiceConfig()
Public Property DefaultYearOverride As Integer = 0

View File

@ -1,19 +1,17 @@
Imports System.IO
Imports EDIDocumentImport.Data
Namespace Documents
Public Class Document
Public File As FileInfo
Public Type As DocumentType
Public Mandator As String
Public Data As Object
Public DataOriginal As Object
Public DataOutput As Object
Public DataString As String
Public Type As DocumentType
Public Selected As Boolean = False
Public TemplateName As String
Public TemplateType As Integer
Public [Option] As Integer
Public PrintVoucher As Integer
Public ReadOnly Property FullName As String
Get
Return File?.FullName
@ -26,19 +24,30 @@ Namespace Documents
End Get
End Property
Public Shared Function GetDocumentTypeFromTemplateName(pTemplateName As String) As DocumentType
Return DocumentMatch.TypeMatchingTable.
Where(Function(kv) pTemplateName.Contains(kv.Key)).
Select(Function(kv) kv.Value).
FirstOrDefault()
End Function
Public Rows As New List(Of DocumentRow)
Public Shared Function GetDocumentSchemaFromDocumentType(pDocumentType As DocumentType) As Type
Return DocumentMatch.SchemaMatchingTable.
Where(Function(kv) pDocumentType = kv.Key).
Select(Function(kv) kv.Value).
FirstOrDefault()
End Function
' Public Type As DocumentType
' Public Data As Object
' Public DataOriginal As Object
' Public DataOutput As Object
' Public DataString As String
' Public Selected As Boolean = False
' Public Shared Function GetDocumentTypeFromTemplateName(pTemplateName As String) As DocumentType
' Return DocumentMatch.TypeMatchingTable.
' Where(Function(kv) pTemplateName.Contains(kv.Key)).
' Select(Function(kv) kv.Value).
' FirstOrDefault()
' End Function
' Public Shared Function GetDocumentSchemaFromDocumentType(pDocumentType As DocumentType) As Type
' Return DocumentMatch.SchemaMatchingTable.
' Where(Function(kv) pDocumentType = kv.Key).
' Select(Function(kv) kv.Value).
' FirstOrDefault()
' End Function
End Class
End Namespace

View File

@ -1,4 +1,6 @@
Imports System.IO
Imports System.ComponentModel
Imports System.IO
Imports System.Reflection
Imports System.Text.RegularExpressions
Imports System.Xml.Serialization
Imports System.Xml.XPath
@ -36,12 +38,9 @@ Namespace Documents
Logger.Debug("Found [{0}] files in directory [{1}]", oFiles.Count, oDirectory)
Files = oFiles.
Select(AddressOf WrapFileInfo).
Select(AddressOf LoadDocumentData).
Select(Function(oDocument)
Return MatchDataFromWinLine(oDocument, Winline.Mandators)
End Function).
ToList()
Select(AddressOf WrapFileInfo).
Select(AddressOf LoadDocumentData2).
ToList()
Return True
@ -52,26 +51,66 @@ Namespace Documents
End Try
End Function
Private Function MatchDataFromWinLine(pDocument As Document, pMandators As List(Of Winline.Mandator)) As Document
Dim oMandators As List(Of Winline.Mandator) = pMandators.
Where(Function(m) m.IsWhitelisted = True).
OrderBy(Function(m) m.Order).
ToList()
Private Function LoadDocumentData2(pDocument As Document) 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 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)
Dim oTemplateName = XmlData.GetElementAttribute(oRootElement, "Template")
Dim oTemplateType = XmlData.GetElementAttribute(oRootElement, "TemplateType")
Dim oOption = XmlData.GetElementAttribute(oRootElement, "option")
Dim oPrintVoucher = XmlData.GetElementAttribute(oRootElement, "printVoucher")
If oMandator Is Nothing Then
Logger.Warn("Mandator not found for File [{0}]", pDocument.File.Name)
End If
Dim oRowElements As List(Of XElement) = oRootElement.Elements.ToList
pDocument.Mandator = oMandator.Id
pDocument.Data = oData
End If
Dim oRows As New List(Of DocumentRow)
For Each oElement As XElement In oRowElements
Dim oFields As New Dictionary(Of String, String)
Dim oSubElements = oElement.Descendants().ToList()
For Each oSubElement As XElement In oSubElements
oFields.Add(oSubElement.Name.ToString, oSubElement.Value)
Next
Dim oRow = New DocumentRow With {
.Name = oElement.Name.ToString,
.Fields = oFields
}
oRows.Add(oRow)
Next
pDocument.TemplateName = oTemplateName
pDocument.TemplateType = oTemplateType
pDocument.Rows = oRows
pDocument.Option = oOption
pDocument.PrintVoucher = oPrintVoucher
Return pDocument
End Function
'Private Function MatchDataFromWinLine(pDocument As Document, pMandators As List(Of Winline.Mandator)) As Document
' Dim oMandators As List(Of Winline.Mandator) = pMandators.
' Where(Function(m) m.IsWhitelisted = True).
' OrderBy(Function(m) m.Order).
' ToList()
' 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(pData As Input.MESOWebService, pMandator As Winline.Mandator) As Input.MESOWebService
Dim oYear = Winline.GetWinLineYear()
@ -115,51 +154,77 @@ Namespace Documents
Return pData
End Function
Private Function WrapFileInfo(pFileInfo As FileInfo) As Document
Return New Document With {.File = pFileInfo}
End Function
Private Function LoadDocumentData(pDocument As Document) As Document
Using oFileStream As New FileStream(pDocument.FullName, FileMode.Open, FileAccess.Read, FileShare.Read)
Try
Dim oXmlDocument = New XPathDocument(oFileStream)
Dim oNavigator = oXmlDocument.CreateNavigator()
Dim oTemplateName = GetTemplateName(oNavigator)
Dim oDocumentType = DocumentMatch.GetDocumentTypeFromTemplateName(oTemplateName)
Dim oSchemaType = DocumentMatch.GetDocumentSchemaFromDocumentType(oDocumentType)
' Read data the first time, working copy
Using oReader = oNavigator.ReadSubtree()
Dim oSerializer = Serializer.GetSerializer(oSchemaType)
pDocument.Data = oSerializer.Deserialize(oReader)
'Private Function LoadDocumentData(pDocument As Document) As Document
' Using oFileStream As New FileStream(pDocument.FullName, FileMode.Open, FileAccess.Read, FileShare.Read)
' Try
' Dim oXmlDocument = New XPathDocument(oFileStream)
' Dim oDocument = oXmlDocument.CreateNavigator()
' Dim oTemplateName = GetTemplateName(oDocument)
' Dim oDocumentType = DocumentMatch.GetDocumentTypeFromTemplateName(oTemplateName)
' Dim oSchemaType As Type = DocumentMatch.GetDocumentSchemaFromDocumentType(oDocumentType)
End Using
' ' Read data the first time, working copy
' 'Using oReader = oNavigator.ReadSubtree()
' ' Dim oSerializer = Serializer.GetSerializer(oSchemaType)
' ' pDocument.Data = oSerializer.Deserialize(oReader)
' Read data the second time, archive copy
Using oReader = oNavigator.ReadSubtree()
Dim oSerializer = Serializer.GetSerializer(oSchemaType)
pDocument.DataOriginal = oSerializer.Deserialize(oReader)
' 'End Using
End Using
' ' Read data the second time, archive copy
' 'Using oReader = oNavigator.ReadSubtree()
' ' Dim oSerializer = Serializer.GetSerializer(oSchemaType)
' ' pDocument.DataOriginal = oSerializer.Deserialize(oReader)
pDocument.Type = oDocumentType
Return pDocument
Catch ex As Exception
Logger.Error(ex)
' 'End Using
Dim oException As Exception = ex
If ex.InnerException IsNot Nothing Then
oException = ex.InnerException
End If
' 'Dim oInstance As Object = Activator.CreateInstance(oSchemaType)
' 'Dim oProps = oSchemaType.GetProperties()
Throw oException
End Try
End Using
End Function
' 'Dim oHead = oProps.
' ' Where(Function(p) p.Name = "Head").
' ' SingleOrDefault()
' 'Dim oDescriptionHead As CustomAttributeData = oHead.CustomAttributes.
' ' Where(Function(d) d.AttributeType.Equals(GetType(DescriptionAttribute))).
' ' SingleOrDefault()
' 'Dim oDescriptionHeadValue = oDescriptionHead.ConstructorArguments.First().Value
' 'Dim oHeadXml = oDocument.Select($"//MESOWebService/{oDescriptionHeadValue}")
' 'Dim oPositions As PropertyInfo = oProps.
' ' Where(Function(p) p.Name = "Positions").
' ' SingleOrDefault()
' 'Dim oDescriptionPos As CustomAttributeData = oPositions.CustomAttributes.
' ' Where(Function(d) d.AttributeType.Equals(GetType(DescriptionAttribute))).
' ' SingleOrDefault()
' 'Dim oDescriptionPosValue = oDescriptionPos.ConstructorArguments.First().Value
' 'Dim oPosXml = oDocument.Select($"//MESOWebService/{oDescriptionPosValue}")
' pDocument.Type = oDocumentType
' Return pDocument
' Catch ex As Exception
' Logger.Error(ex)
' Dim oException As Exception = ex
' If ex.InnerException IsNot Nothing Then
' oException = ex.InnerException
' End If
' Throw oException
' End Try
' End Using
'End Function
Private Function GetTemplateName(pDocument As XPathNavigator) As String
Dim oTemplateName = pDocument.
SelectSingleNode("//MESOWebService").
GetAttribute("Template", "")
SelectSingleNode("//MESOWebService").
GetAttribute("Template", "")
Return oTemplateName
End Function

View File

@ -8,7 +8,7 @@
}
Public Shared Property SchemaMatchingTable As New Dictionary(Of DocumentType, Type) From {
{DocumentType.Order, GetType(Schemas.Orders.Input.MESOWebService)}
{DocumentType.Order, GetType(Schemas.OrderSchema)}
}
Public Shared Function GetDocumentTypeFromTemplateName(pTemplateName As String) As DocumentType

View File

@ -0,0 +1,4 @@
Public Class DocumentRow
Public Name As String
Public Fields As Dictionary(Of String, String)
End Class

View File

@ -54,6 +54,9 @@
<Reference Include="DigitalData.Modules.Filesystem">
<HintPath>..\..\DDMonorepo\Modules.Filesystem\bin\Debug\DigitalData.Modules.Filesystem.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Interfaces">
<HintPath>..\..\DDMonorepo\Modules.Interfaces\bin\Debug\DigitalData.Modules.Interfaces.dll</HintPath>
</Reference>
<Reference Include="DigitalData.Modules.Language">
<HintPath>..\..\DDMonorepo\Modules.Language\bin\Release\DigitalData.Modules.Language.dll</HintPath>
</Reference>
@ -93,6 +96,7 @@
<Compile Include="Config.vb" />
<Compile Include="Documents\Document.vb" />
<Compile Include="Documents\DocumentMatch.vb" />
<Compile Include="Documents\DocumentRow.vb" />
<Compile Include="Documents\DocumentType.vb" />
<Compile Include="Documents\DocumentLoader.vb" />
<Compile Include="IEnumerableEx.vb" />
@ -112,19 +116,23 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Mapper.vb" />
<Compile Include="Schemas\IMesoWebService.vb" />
<Compile Include="Schemas\BaseSchema.vb" />
<Compile Include="Schemas\Orders\Helpers.vb" />
<Compile Include="Schemas\Orders\Input.vb" />
<Compile Include="Schemas\Orders\Output.vb" />
<Compile Include="Schemas\Orders\OrderSchema.vb" />
<Compile Include="Schemas\Orders\ReportSource.vb" />
<Compile Include="Schemas\Response.vb" />
<Compile Include="Schemas\Schema.vb" />
<Compile Include="Schemas\SchemaLoader.vb" />
<Compile Include="Serializer.vb" />
<Compile Include="Winline\Entities\Account.vb" />
<Compile Include="Winline\Data.vb" />
<Compile Include="Winline\Entities\Contact.vb" />
<Compile Include="Winline\Entities\DocumentKind.vb" />
<Compile Include="Winline\Entities\Mandator.vb" />
<Compile Include="Winline\Entities\XmlItem.vb" />
<Compile Include="Winline\WebService.vb" />
<Compile Include="XmlData.vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="My Project\Resources.resx">

View File

@ -5,24 +5,24 @@ Imports AutoMapper.Configuration
Public Class MapperFactory
Private Shared MapperConfig As Object
Public Shared Function GetMapper() As Mapper
MapperConfig = New MapperConfiguration(CreateMapperConfig())
MapperConfig.AssertConfigurationIsValid()
Return MapperConfig.CreateMapper()
End Function
'Public Shared Function GetMapper() As Mapper
' MapperConfig = New MapperConfiguration(CreateMapperConfig())
' MapperConfig.AssertConfigurationIsValid()
' Return MapperConfig.CreateMapper()
'End Function
Private Shared Function CreateMapperConfig() As MapperConfigurationExpression
Dim oConfig As New MapperConfigurationExpression()
'Private Shared Function CreateMapperConfig() As MapperConfigurationExpression
' Dim oConfig As New MapperConfigurationExpression()
oConfig.CreateMap(Of String, Integer)().ConvertUsing(New IntegerTypeConverter())
oConfig.CreateMap(Of String, Decimal)().ConvertUsing(New DecimalTypeConverter())
oConfig.CreateMap(Of String, DateTime)().ConvertUsing(New DateTimeTypeConverter())
oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebService, Schemas.Orders.Output.MESOWebService)()
oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT025, Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT025)()
oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT026, Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT026)()
' oConfig.CreateMap(Of String, Integer)().ConvertUsing(New IntegerTypeConverter())
' oConfig.CreateMap(Of String, Decimal)().ConvertUsing(New DecimalTypeConverter())
' oConfig.CreateMap(Of String, DateTime)().ConvertUsing(New DateTimeTypeConverter())
' oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebService, Schemas.Orders.Output.MESOWebService)()
' oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT025, Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT025)()
' oConfig.CreateMap(Of Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT026, Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT026)()
Return oConfig
End Function
' Return oConfig
'End Function
Private Class DateTimeTypeConverter
Implements ITypeConverter(Of String, DateTime)

View File

@ -0,0 +1,8 @@
Namespace Schemas
Public Class BaseSchema
Public Property Template As String
Public Property TemplateType As Integer
Public Property [Option] As Integer
Public Property PrintVoucher As Integer
End Class
End Namespace

View File

@ -1,6 +0,0 @@
Namespace Schemas
Public Interface IMesoWebservice
Property Items As Object()
End Interface
End Namespace

View File

@ -1,28 +1,28 @@
Namespace Schemas.Orders
Public Class Helpers
Public Shared Function GetOrderHead(Of T)(pData As IMesoWebservice) As T
Dim oHead As T = pData.Items.
Where(Function(i) TypeOf i Is T).
FirstOrDefault()
Return oHead
End Function
'Public Class Helpers
' Public Shared Function GetOrderHead(Of T)(pData As IMesoWebservice) As T
' Dim oHead As T = pData.Items.
' Where(Function(i) TypeOf i Is T).
' FirstOrDefault()
' Return oHead
' End Function
Public Shared Sub SetOrderHead(Of T)(pData As IMesoWebservice, pUpdateFunction As Action(Of T))
Dim oHead As T = pData.Items.
Where(Function(i) TypeOf i Is T).
SetValue(Sub(pObject As T)
pUpdateFunction(pObject)
End Sub).
FirstOrDefault()
' Public Shared Sub SetOrderHead(Of T)(pData As IMesoWebservice, pUpdateFunction As Action(Of T))
' Dim oHead As T = pData.Items.
' Where(Function(i) TypeOf i Is T).
' SetValue(Sub(pObject As T)
' pUpdateFunction(pObject)
' End Sub).
' FirstOrDefault()
End Sub
' End Sub
Public Shared Function GetOrderPositions(Of T)(pData As IMesoWebservice) As List(Of T)
Dim oPositions As List(Of T) = pData.Items.
Where(Function(i) TypeOf i Is T).
Select(Of T)(Function(i) i).
ToList()
Return oPositions
End Function
End Class
' Public Shared Function GetOrderPositions(Of T)(pData As IMesoWebservice) As List(Of T)
' Dim oPositions As List(Of T) = pData.Items.
' Where(Function(i) TypeOf i Is T).
' Select(Of T)(Function(i) i).
' ToList()
' Return oPositions
' End Function
'End Class
End Namespace

View File

@ -27,8 +27,6 @@ Namespace Schemas.Orders.Input
System.Xml.Serialization.XmlRootAttribute([Namespace]:="", IsNullable:=False)>
Partial Public Class MESOWebService
Implements Schemas.IMesoWebservice
Private itemsField() As Object
Private templateTypeField As String
@ -50,7 +48,7 @@ Namespace Schemas.Orders.Input
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("EXIM-VRG_ordersT025", GetType(MESOWebServiceEXIMVRG_ordersT025), Form:=System.Xml.Schema.XmlSchemaForm.Unqualified),
System.Xml.Serialization.XmlElementAttribute("EXIM-VRG_ordersT026", GetType(MESOWebServiceEXIMVRG_ordersT026), Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)>
Public Property Items() As Object() Implements Schemas.IMesoWebservice.Items
Public Property Items() As Object()
Get
Return Me.itemsField
End Get

View File

@ -0,0 +1,55 @@
Imports System.ComponentModel
Namespace Schemas
''' <summary>
''' XML Schema to import the Data-Files
''' </summary>
Public Class OrderSchema
Inherits BaseSchema
<Description("EXIM-VRG_ordersT025")>
Public Property Head As New OrderHead
<Description("EXIM-VRG_ordersT026")>
Public Property Positions As New List(Of OrderPosition)
Public Class OrderHead
<Description("BELEGKEY")>
Public Property DocumentKey As String
<Description("Fakt_Kontonummer")>
Public Property AccountNumber As String
<Description("Laufnummer")>
Public Property RunningNumber As String
<Description("Bestellt_von")>
Public Property OrderedBy As String
<Description("Lief_Kontonummer")>
Public Property AccountNumber2 As String
<Description("Belegart")>
Public Property DocumentType As Integer
<Description("Datum_Auftrag-Bestellung")>
Public Property OrderDate As Date
<Description("Auftrags-Bestellnummer")>
Public Property OrderNumber As String
<Description("Infotext")>
Public Property InfoText As String
End Class
Public Class OrderPosition
<Description("BELEGKEY")>
Public Property DocumentKey As String
<Description("Zeilennummer")>
Public Property LineNumber As String
<Description("Artikelnummer")>
Public Property ArticleNumber As String
<Description("Bezeichnung")>
Public Property ArticleDescription As String
<Description("Lieferantenartikelnummer")>
Public Property VendorNumber As String
End Class
End Class
End Namespace

View File

@ -1,712 +0,0 @@
'------------------------------------------------------------------------------
' <auto-generated>
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.42000
'
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports System.Xml.Serialization
'
'This source code was auto-generated by xsd, Version=4.8.3928.0.
'
Namespace Schemas.Orders.Output
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.8.3928.0"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true), _
System.Xml.Serialization.XmlRootAttribute([Namespace]:="", IsNullable:=false)> _
Partial Public Class MESOWebService
Private itemsField() As Object
Private templateTypeField As String
Private templateField As String
Private optionField As String
Private amountField As String
Private extEntryField As String
Private printVoucherField As String
Private extInsertField As String
Private changeLotSizeField As String
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("EXIM-VRG_ordersT025", GetType(MESOWebServiceEXIMVRG_ordersT025), Form:=System.Xml.Schema.XmlSchemaForm.Unqualified), _
System.Xml.Serialization.XmlElementAttribute("EXIM-VRG_ordersT026", GetType(MESOWebServiceEXIMVRG_ordersT026), Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Items() As Object()
Get
Return Me.itemsField
End Get
Set
Me.itemsField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer")> _
Public Property TemplateType() As String
Get
Return Me.templateTypeField
End Get
Set
Me.templateTypeField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute()> _
Public Property Template() As String
Get
Return Me.templateField
End Get
Set
Me.templateField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer")> _
Public Property [option]() As String
Get
Return Me.optionField
End Get
Set
Me.optionField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer")> _
Public Property amount() As String
Get
Return Me.amountField
End Get
Set
Me.amountField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer")> _
Public Property extEntry() As String
Get
Return Me.extEntryField
End Get
Set
Me.extEntryField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer")> _
Public Property printVoucher() As String
Get
Return Me.printVoucherField
End Get
Set
Me.printVoucherField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer")> _
Public Property extInsert() As String
Get
Return Me.extInsertField
End Get
Set
Me.extInsertField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer")> _
Public Property ChangeLotSize() As String
Get
Return Me.changeLotSizeField
End Get
Set
Me.changeLotSizeField = value
End Set
End Property
End Class
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.8.3928.0"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true)> _
Partial Public Class MESOWebServiceEXIMVRG_ordersT025
Private bELEGKEYField As String
Private fakt_KontonummerField As String
Private laufnummerField As String
Private fakt_NameField As String
Private fakt_StrasseField As String
Private fakt_PLZField As String
Private fakt_OrtField As String
Private fakt_AnsprechpartnerField As String
Private lief_KontonummerField As String
Private lief_NameField As String
Private lief_StrasseField As String
Private lief_PLZField As String
Private lief_OrtField As String
Private belegartField As String
Private datum_AuftragBestellungField As Date
Private datum_AuftragBestellungFieldSpecified As Boolean
Private auftragsBestellnummerField As String
Private leistungsdatumField As Date
Private leistungsdatumFieldSpecified As Boolean
Private auftragsreferenzField As String
Private infotextField As String
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType:="integer")> _
Public Property BELEGKEY() As String
Get
Return Me.bELEGKEYField
End Get
Set
Me.bELEGKEYField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Fakt_Kontonummer() As String
Get
Return Me.fakt_KontonummerField
End Get
Set
Me.fakt_KontonummerField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Laufnummer() As String
Get
Return Me.laufnummerField
End Get
Set
Me.laufnummerField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Fakt_Name() As String
Get
Return Me.fakt_NameField
End Get
Set
Me.fakt_NameField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Fakt_Strasse() As String
Get
Return Me.fakt_StrasseField
End Get
Set
Me.fakt_StrasseField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Fakt_PLZ() As String
Get
Return Me.fakt_PLZField
End Get
Set
Me.fakt_PLZField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Fakt_Ort() As String
Get
Return Me.fakt_OrtField
End Get
Set
Me.fakt_OrtField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Fakt_Ansprechpartner() As String
Get
Return Me.fakt_AnsprechpartnerField
End Get
Set
Me.fakt_AnsprechpartnerField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Lief_Kontonummer() As String
Get
Return Me.lief_KontonummerField
End Get
Set
Me.lief_KontonummerField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Lief_Name() As String
Get
Return Me.lief_NameField
End Get
Set
Me.lief_NameField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Lief_Strasse() As String
Get
Return Me.lief_StrasseField
End Get
Set
Me.lief_StrasseField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Lief_PLZ() As String
Get
Return Me.lief_PLZField
End Get
Set
Me.lief_PLZField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Lief_Ort() As String
Get
Return Me.lief_OrtField
End Get
Set
Me.lief_OrtField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Belegart() As String
Get
Return Me.belegartField
End Get
Set
Me.belegartField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Datum_Auftrag-Bestellung", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType:="date")> _
Public Property Datum_AuftragBestellung() As Date
Get
Return Me.datum_AuftragBestellungField
End Get
Set
Me.datum_AuftragBestellungField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlIgnoreAttribute()> _
Public Property Datum_AuftragBestellungSpecified() As Boolean
Get
Return Me.datum_AuftragBestellungFieldSpecified
End Get
Set
Me.datum_AuftragBestellungFieldSpecified = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Auftrags-Bestellnummer", Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property AuftragsBestellnummer() As String
Get
Return Me.auftragsBestellnummerField
End Get
Set
Me.auftragsBestellnummerField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType:="date")> _
Public Property Leistungsdatum() As Date
Get
Return Me.leistungsdatumField
End Get
Set
Me.leistungsdatumField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlIgnoreAttribute()> _
Public Property LeistungsdatumSpecified() As Boolean
Get
Return Me.leistungsdatumFieldSpecified
End Get
Set
Me.leistungsdatumFieldSpecified = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Auftragsreferenz() As String
Get
Return Me.auftragsreferenzField
End Get
Set
Me.auftragsreferenzField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Infotext() As String
Get
Return Me.infotextField
End Get
Set
Me.infotextField = value
End Set
End Property
End Class
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.8.3928.0"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true)> _
Partial Public Class MESOWebServiceEXIMVRG_ordersT026
Private bELEGKEYField As String
Private zeilennummerField As String
Private datentypField As String
Private artikelnummerField As String
Private bezeichnungField As String
Private notizblockField As String
Private lieferantenartikelnummerField As String
Private menge_bestelltField As Decimal
Private menge_bestelltFieldSpecified As Boolean
Private menge_geliefertField As Decimal
Private colliField As String
Private einzelpreisField As Decimal
Private einzelpreisFieldSpecified As Boolean
Private zeilenrabatt1Field As Decimal
Private zeilenrabatt1FieldSpecified As Boolean
Private zeilenrabatt2Field As Decimal
Private zeilenrabatt2FieldSpecified As Boolean
Private zeilenrabatt3Field As Decimal
Private zeilenrabatt3FieldSpecified As Boolean
Private zeilenrabatt4Field As Decimal
Private zeilenrabatt4FieldSpecified As Boolean
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType:="integer")> _
Public Property BELEGKEY() As String
Get
Return Me.bELEGKEYField
End Get
Set
Me.bELEGKEYField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified, DataType:="integer")> _
Public Property Zeilennummer() As String
Get
Return Me.zeilennummerField
End Get
Set
Me.zeilennummerField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Datentyp() As String
Get
Return Me.datentypField
End Get
Set
Me.datentypField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Artikelnummer() As String
Get
Return Me.artikelnummerField
End Get
Set
Me.artikelnummerField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Bezeichnung() As String
Get
Return Me.bezeichnungField
End Get
Set
Me.bezeichnungField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Notizblock() As String
Get
Return Me.notizblockField
End Get
Set
Me.notizblockField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Lieferantenartikelnummer() As String
Get
Return Me.lieferantenartikelnummerField
End Get
Set
Me.lieferantenartikelnummerField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Menge_bestellt() As Decimal
Get
Return Me.menge_bestelltField
End Get
Set
Me.menge_bestelltField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlIgnoreAttribute()> _
Public Property Menge_bestelltSpecified() As Boolean
Get
Return Me.menge_bestelltFieldSpecified
End Get
Set
Me.menge_bestelltFieldSpecified = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Menge_geliefert() As Decimal
Get
Return Me.menge_geliefertField
End Get
Set
Me.menge_geliefertField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Colli() As String
Get
Return Me.colliField
End Get
Set
Me.colliField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Einzelpreis() As Decimal
Get
Return Me.einzelpreisField
End Get
Set
Me.einzelpreisField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlIgnoreAttribute()> _
Public Property EinzelpreisSpecified() As Boolean
Get
Return Me.einzelpreisFieldSpecified
End Get
Set
Me.einzelpreisFieldSpecified = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Zeilenrabatt1() As Decimal
Get
Return Me.zeilenrabatt1Field
End Get
Set
Me.zeilenrabatt1Field = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlIgnoreAttribute()> _
Public Property Zeilenrabatt1Specified() As Boolean
Get
Return Me.zeilenrabatt1FieldSpecified
End Get
Set
Me.zeilenrabatt1FieldSpecified = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Zeilenrabatt2() As Decimal
Get
Return Me.zeilenrabatt2Field
End Get
Set
Me.zeilenrabatt2Field = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlIgnoreAttribute()> _
Public Property Zeilenrabatt2Specified() As Boolean
Get
Return Me.zeilenrabatt2FieldSpecified
End Get
Set
Me.zeilenrabatt2FieldSpecified = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Zeilenrabatt3() As Decimal
Get
Return Me.zeilenrabatt3Field
End Get
Set
Me.zeilenrabatt3Field = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlIgnoreAttribute()> _
Public Property Zeilenrabatt3Specified() As Boolean
Get
Return Me.zeilenrabatt3FieldSpecified
End Get
Set
Me.zeilenrabatt3FieldSpecified = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Form:=System.Xml.Schema.XmlSchemaForm.Unqualified)> _
Public Property Zeilenrabatt4() As Decimal
Get
Return Me.zeilenrabatt4Field
End Get
Set
Me.zeilenrabatt4Field = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlIgnoreAttribute()> _
Public Property Zeilenrabatt4Specified() As Boolean
Get
Return Me.zeilenrabatt4FieldSpecified
End Get
Set
Me.zeilenrabatt4FieldSpecified = value
End Set
End Property
End Class
End Namespace

View File

@ -0,0 +1,28 @@
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
Class Table
Public Property Name As String
Public Property Columns As New List(Of Column)
End Class
Class Column
Public Property Name As String
Public Property Required As String
Public Property DataType As ColumnType
End Class
End Class
End Namespace

View File

@ -0,0 +1,116 @@
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports DigitalData.Modules.Logging
Namespace Schemas
Public Class SchemaLoader
Inherits BaseClass
Private ns As XNamespace = "http://www.w3.org/2001/XMLSchema"
Public SchemaList As List(Of FileInfo)
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig, pLogConfig.GetLogger)
End Sub
Public Function LoadFiles(pSchemaDirectory) As Boolean
If pSchemaDirectory = String.Empty Then
Throw New ArgumentNullException("SchemaDirectory")
End If
Logger.Info("Loading files from directory [{0}]", pSchemaDirectory)
Try
Dim oDirectory As New DirectoryInfo(pSchemaDirectory)
Dim oFiles = oDirectory.GetFiles()
Logger.Debug("Found [{0}] files in directory [{1}]", oFiles.Count, oDirectory)
SchemaList = oFiles.ToList()
Return True
Catch ex As Exception
Logger.Error(ex)
Throw New IO.IOException($"Could not load files from directory {pSchemaDirectory}", ex)
End Try
End Function
Public Function GetSchemaFromFile(pSchemaFilePath As String) As Schema
Dim oSchema As New Schema
Dim oElements = GetSchemaElements(pSchemaFilePath)
For Each oElement In oElements
Dim oColumns = GetElementColumns(oElement)
Dim oSchemaColumns As New List(Of Schema.Column)
For Each oColumn As XElement In oColumns
Dim oName = XmlData.GetElementAttribute(oColumn, "name")
Dim oMinOccurs = XmlData.GetElementAttribute(oColumn, "minOccurs")
Dim oMaxOccurs = XmlData.GetElementAttribute(oColumn, "maxOccurs")
Dim oType = GetElementType(oColumn)
Dim oRequired = False
If oMinOccurs = 1 And oMaxOccurs = 1 Then
oRequired = True
End If
Dim oSchemaColumn As New Schema.Column With {
.Name = oName,
.Required = oRequired,
.DataType = oType
}
oSchemaColumns.Add(oSchemaColumn)
Next
oSchema.Tables.Add(New Schema.Table With {
.Name = XmlData.GetElementAttribute(oElement, "name"),
.Columns = oSchemaColumns
})
Next
Return oSchema
End Function
Public Function GetElementType(pElement As XElement) As Schema.ColumnType
Dim oTypeString = XmlData.GetElementAttribute(pElement, "type")
If oTypeString Is Nothing Then
Dim oRestrictionElement As XElement = pElement.
Descendants(ns + "restriction").
FirstOrDefault()
oTypeString = XmlData.GetElementAttribute(oRestrictionElement, "base")
End If
Select Case oTypeString
Case "xs:date"
Return Schema.ColumnType.Date
Case "xs:integer"
Return Schema.ColumnType.Integer
Case "xs:decimal"
Return Schema.ColumnType.Decimal
Case "xs:boolean"
Return Schema.ColumnType.Boolean
Case Else
Return Schema.ColumnType.String
End Select
End Function
Public Function GetSchemaElements(pSchemaFilePath As String) As List(Of XElement)
Dim oText As String = IO.File.ReadAllText(pSchemaFilePath)
Dim oDoc = XDocument.Parse(oText)
Return XmlData.GetElementsFromElement(oDoc, "choice", ns)
End Function
Public Function GetElementColumns(pElement As XElement) As List(Of XElement)
Return XmlData.GetElementsFromElement(pElement, "sequence", ns)
End Function
End Class
End Namespace

View File

@ -16,6 +16,8 @@ Namespace Winline
Public Mandators As New List(Of Mandator)
Public DocumentKinds As New List(Of DocumentKind)
Public Years As List(Of Integer)
Public XmlConfigHead As List(Of XmlItem)
Public XmlConfigPositions As List(Of XmlItem)
Public Const ALL_MESOCOMP = "mesocomp"
@ -134,8 +136,6 @@ Namespace Winline
Dim oDocumentKinds As New List(Of DocumentKind)
Dim oMandatorString = String.Join(",", pMandators.Select(Function(m) $"'{m.Id}'").ToArray)
Dim oYear As Integer = GetWinLineYear()
DocumentKinds.Clear()
For Each oMandator As Mandator In pMandators
@ -348,8 +348,8 @@ Namespace Winline
Dim oYear = GetWinLineYear()
Dim oMandatorId As String = String.Empty
Dim oWhitelistedMandators = Mandators.
Where(Function(m) m.IsWhitelisted = True).
ToList()
Where(Function(m) m.IsWhitelisted = True).
ToList()
For Each oPos In oPositions
For Each oMandator In oWhitelistedMandators
@ -413,6 +413,24 @@ Namespace Winline
End If
End Function
Public Sub GetXmlConfiguration()
Try
Dim oSql = $"SELECT XML_NAME, XML_ROOT, DATA_TYPE, IS_HEAD FROM [DD_ECM].[dbo].[VWEDI_XML_ITEMS]"
Dim oTable As DataTable = Database.GetDatatable(oSql)
For Each oRow As DataRow In oTable.Rows
Dim oXmlItem As New XmlItem With {
.Name = oRow.Item("XML_NAME"),
.Root = oRow.Item("XML_ROOT"),
.Type = oRow.Item("XML_TYPE")
}
Next
Catch ex As Exception
End Try
End Sub
''' <summary>
''' Turns a database info like "SQLCWLDATEN on SERVER\INSTANCE" into a Tuple of two strings
''' </summary>
@ -437,5 +455,7 @@ Namespace Winline
Split(oDelimiter, StringSplitOptions.None).
ToList()
End Function
End Class
End Namespace

View File

@ -0,0 +1,9 @@
Namespace Winline
Public Class XmlItem
Public Name As String
Public Root As String
Public Type As String
Public IsHead As Boolean
End Class
End Namespace

View File

@ -22,85 +22,85 @@ Namespace Winline
FileEx = New File(pLogConfig)
Serializer = New Serializer(pLogConfig)
Config = pConfig
Mapper = MapperFactory.GetMapper()
'Mapper = MapperFactory.GetMapper()
End Sub
Public Async Function TransferDocumentToWinLine(pDocument As Document) As Task(Of Boolean)
If TypeOf pDocument.Data Is Schemas.Orders.Input.MESOWebService Then
Return Await TransferOrderToWinline(pDocument)
Else
Return False
End If
End Function
'Public Async Function TransferDocumentToWinLine(pDocument As Document) As Task(Of Boolean)
' If TypeOf pDocument.Data Is Schemas.Orders.Input.MESOWebService Then
' Return Await TransferOrderToWinline(pDocument)
' Else
' Return False
' End If
'End Function
Private Async Function TransferOrderToWinline(pDocument As Document) As Task(Of Boolean)
Dim oOrderOutput = TransformOrderToOutput(pDocument.Data)
Dim oWS As Config.WebServiceConfig = Config.Webservice
'Private Async Function TransferOrderToWinline(pDocument As Document) As Task(Of Boolean)
' Dim oOrderOutput = TransformOrderToOutput(pDocument.Data)
' Dim oWS As Config.WebServiceConfig = Config.Webservice
' --- Get and create path for request/response files
' ' --- Get and create path for request/response files
Dim oPath As String = GetBaseWebServicePath()
If IO.Directory.Exists(oPath) = False Then
IO.Directory.CreateDirectory(oPath)
End If
' Dim oPath As String = GetBaseWebServicePath()
' If IO.Directory.Exists(oPath) = False Then
' IO.Directory.CreateDirectory(oPath)
' End If
' --- Build all teh filenamez and pathz
' ' --- Build all teh filenamez and pathz
Dim oBaseFileName As String = GetBaseFilenameForRequest()
Dim oFileName = GetXmlFilenameWithSuffix(oBaseFileName, "Request", "xml")
' Dim oBaseFileName As String = GetBaseFilenameForRequest()
' Dim oFileName = GetXmlFilenameWithSuffix(oBaseFileName, "Request", "xml")
' Relative Path for Webservice Call
Dim oImportRelativeFilePath = IO.Path.Combine(GetDateSubDirectoryPath(Config.Webservice.ImportRelativePath), oFileName)
' ' Relative Path for Webservice Call
' Dim oImportRelativeFilePath = IO.Path.Combine(GetDateSubDirectoryPath(Config.Webservice.ImportRelativePath), oFileName)
' Absolute Path to copy Request file
Dim oImportAbsolutePath = IO.Path.Combine(Config.Webservice.ImportBasePath, Config.Webservice.ImportRelativePath)
Dim oImportAbsoluteFilePath = IO.Path.Combine(GetDateSubDirectoryPath(oImportAbsolutePath), oFileName)
' ' Absolute Path to copy Request file
' Dim oImportAbsolutePath = IO.Path.Combine(Config.Webservice.ImportBasePath, Config.Webservice.ImportRelativePath)
' Dim oImportAbsoluteFilePath = IO.Path.Combine(GetDateSubDirectoryPath(oImportAbsolutePath), oFileName)
' --- Serialize Data into XML string
' ' --- Serialize Data into XML string
Dim oOutputFilePath = SerializeOrder(oOrderOutput, oFileName)
' Dim oOutputFilePath = SerializeOrder(oOrderOutput, oFileName)
' --- Copy file to Winline Import Directory
' ' --- Copy file to Winline Import Directory
Try
IO.File.Copy(oOutputFilePath, oImportAbsoluteFilePath, True)
Catch ex As Exception
Logger.Error(ex)
Throw ex
End Try
' Try
' IO.File.Copy(oOutputFilePath, oImportAbsoluteFilePath, True)
' Catch ex As Exception
' Logger.Error(ex)
' Throw ex
' End Try
' --- Prepare URL and HTTP Client
Dim oTemplateType = 30
Dim oTemplateName = "EXIM-VRG_orders"
' ' --- Prepare URL and HTTP Client
' Dim oTemplateType = 30
' Dim oTemplateName = "EXIM-VRG_orders"
' ActionCode: Should this be a test or not?
' 0 = Testcall
' 1 = Real call
Dim oActionCode = 1
' ' ActionCode: Should this be a test or not?
' ' 0 = Testcall
' ' 1 = Real call
' Dim oActionCode = 1
' Byref: Should data be supplied as file or as string?
' 0 = As String
' 1 = As File (relative to Winline Server directory)
Dim oByref = 1
' ' Byref: Should data be supplied as file or as string?
' ' 0 = As String
' ' 1 = As File (relative to Winline Server directory)
' Dim oByref = 1
Dim oURL As String = $"{oWS.BaseUrl}/ewlservice/import?User={oWS.Username}&Password={oWS.Password}&Company={pDocument.Mandator}&Type={oTemplateType}&Vorlage={oTemplateName}&ActionCode={oActionCode}&Byref={oByref}&Data={oImportRelativeFilePath}"
Dim oClient As New HttpClient()
' Dim oURL As String = $"{oWS.BaseUrl}/ewlservice/import?User={oWS.Username}&Password={oWS.Password}&Company={pDocument.Mandator}&Type={oTemplateType}&Vorlage={oTemplateName}&ActionCode={oActionCode}&Byref={oByref}&Data={oImportRelativeFilePath}"
' Dim oClient As New HttpClient()
Logger.Info("Creating HTTP Request to [{0}]", oWS.BaseUrl)
' Logger.Info("Creating HTTP Request to [{0}]", oWS.BaseUrl)
' --- Bring the action!
Try
Dim oResponse As HttpResponseMessage = Await oClient.GetAsync(oURL)
Await HandleResponse(oResponse, oPath, oBaseFileName)
' ' --- Bring the action!
' Try
' Dim oResponse As HttpResponseMessage = Await oClient.GetAsync(oURL)
' Await HandleResponse(oResponse, oPath, oBaseFileName)
Return True
Catch ex As Exception
Logger.Error(ex)
Throw ex
Finally
oClient.Dispose()
End Try
End Function
' Return True
' Catch ex As Exception
' Logger.Error(ex)
' Throw ex
' Finally
' oClient.Dispose()
' End Try
'End Function
Private Async Function HandleResponse(pResponse As HttpResponseMessage, pPath As String, pBaseFileNAme As String) As Task
pResponse.EnsureSuccessStatusCode()
@ -155,35 +155,35 @@ Namespace Winline
End Try
End Function
Private Function TransformOrderToOutput(pData As Schemas.Orders.Input.MESOWebService) As Schemas.Orders.Output.MESOWebService
Dim oData As Schemas.Orders.Input.MESOWebService = pData
Dim oResult As Schemas.Orders.Output.MESOWebService = Mapper.Map(Of Schemas.Orders.Output.MESOWebService)(oData)
'Private Function TransformOrderToOutput(pData As Schemas.Orders.Input.MESOWebService) As Schemas.Orders.Output.MESOWebService
' Dim oData As Schemas.Orders.Input.MESOWebService = pData
' Dim oResult As Schemas.Orders.Output.MESOWebService = Mapper.Map(Of Schemas.Orders.Output.MESOWebService)(oData)
Dim oItems = oData.Items.
Select(Function(i)
If TypeOf i Is Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT025 Then
Return Mapper.Map(Of Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT025)(i)
Else
Return Mapper.Map(Of Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT026)(i)
End If
End Function).
ToList()
' Dim oItems = oData.Items.
' Select(Function(i)
' If TypeOf i Is Schemas.Orders.Input.MESOWebServiceEXIMVRG_ordersT025 Then
' Return Mapper.Map(Of Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT025)(i)
' Else
' Return Mapper.Map(Of Schemas.Orders.Output.MESOWebServiceEXIMVRG_ordersT026)(i)
' End If
' End Function).
' ToList()
oResult.Items = oItems.ToArray()
Return oResult
End Function
' oResult.Items = oItems.ToArray()
' Return oResult
'End Function
Private Function SerializeOrder(pData As Schemas.Orders.Output.MESOWebService, pFileName As String) As String
Dim oSerializer = Serializer.GetSerializer(GetType(Schemas.Orders.Output.MESOWebService))
Dim oPath As String = GetBaseWebServicePath()
Dim oFilePath As String = IO.Path.Combine(oPath, pFileName)
'Private Function SerializeOrder(pData As Schemas.Orders.Output.MESOWebService, pFileName As String) As String
' Dim oSerializer = Serializer.GetSerializer(GetType(Schemas.Orders.Output.MESOWebService))
' Dim oPath As String = GetBaseWebServicePath()
' Dim oFilePath As String = IO.Path.Combine(oPath, pFileName)
Using oWriter = XmlWriter.Create(oFilePath, New XmlWriterSettings With {.Indent = True})
oSerializer.Serialize(oWriter, pData)
End Using
' Using oWriter = XmlWriter.Create(oFilePath, New XmlWriterSettings With {.Indent = True})
' oSerializer.Serialize(oWriter, pData)
' End Using
Return oFilePath
End Function
' Return oFilePath
'End Function
Private Function GetBaseWebServicePath() As String
Return IO.Path.Combine(FileEx.GetAppDataPath("Digital Data", "EDI Document Importer"), "WebService")

43
ImporterShared/XmlData.vb Normal file
View File

@ -0,0 +1,43 @@
Imports DigitalData.Modules.Logging
Public Class XmlData
'<DebuggerStepThrough>
Public Shared Function GetElementAttribute(pElement As XElement, pName As String) As String
Try
Dim oAttribute As XAttribute = pElement.Attribute(pName)
Return oAttribute?.Value
Catch ex As Exception
Return Nothing
End Try
End Function
Public Shared Function GetElementsFromElement(pElement As XContainer, pElementName As String) As List(Of XElement)
Return pElement.Descendants(pElementName).
Elements().
ToList()
End Function
Public Shared Function GetElementsFromElement(pElement As XContainer, pElementName As String, pNamespace As XNamespace) As List(Of XElement)
Return pElement.Descendants(pNamespace + pElementName).
Elements().
ToList()
End Function
Public Shared Function GetElement(pContainer As XContainer, pElementName As String, pNamespace As XNamespace) As XElement
Return pContainer.Descendants(pNamespace + pElementName).
FirstOrDefault()
End Function
Public Shared Function GetElement(pContainer As XContainer, pElementName As String) As XElement
Return pContainer.Descendants(pElementName).
FirstOrDefault()
End Function
Public Shared Function GetElementValue(pElement As XElement) As String
Return pElement.Value
End Function
End Class