WIP
This commit is contained in:
@@ -45,7 +45,7 @@ Namespace Documents
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property Name As String
|
||||
Public ReadOnly Property FileName As String
|
||||
Get
|
||||
Return File?.Name
|
||||
End Get
|
||||
|
||||
@@ -137,7 +137,7 @@ Namespace Documents
|
||||
' The first level of Elements are the document Rows
|
||||
Dim oTopLevelElements As List(Of XElement) = oRootElement.Elements.ToList
|
||||
Dim oDocumentRows As New List(Of DocumentRow)
|
||||
Dim oSortKey As Integer = 0
|
||||
Dim oRowSortKey As Integer = 0
|
||||
|
||||
' TODO: Somehow add all fields in the correct order
|
||||
'
|
||||
@@ -147,12 +147,14 @@ Namespace Documents
|
||||
'
|
||||
' leads to unordered fields.
|
||||
For Each oTopLevelElement As XElement In oTopLevelElements
|
||||
Dim oColumnSortKey = 0
|
||||
Dim oFields As New Dictionary(Of String, DocumentRow.FieldValue)
|
||||
Dim oSubElements = oTopLevelElement.Descendants().ToList()
|
||||
Dim oTable = pSchema.Tables.
|
||||
Where(Function(t) t.Name = oTopLevelElement.Name).
|
||||
FirstOrDefault()
|
||||
|
||||
|
||||
For Each oColumn In oTable.Columns
|
||||
Dim oSubElement = oSubElements.
|
||||
Where(Function(e) e.Name = oColumn.Name).
|
||||
@@ -172,7 +174,8 @@ Namespace Documents
|
||||
.Original = oValue,
|
||||
.Final = oValue,
|
||||
.DataType = oColumn.DataType,
|
||||
.Required = oRequired
|
||||
.Required = oRequired,
|
||||
.SortKey = oColumnSortKey
|
||||
})
|
||||
Else
|
||||
Dim oColumnError = DocumentRow.FieldError.None
|
||||
@@ -181,9 +184,12 @@ Namespace Documents
|
||||
End If
|
||||
|
||||
oFields.Add(oColumn.Name, New DocumentRow.FieldValue With {
|
||||
.[Error] = oColumnError
|
||||
.[Error] = oColumnError,
|
||||
.SortKey = oColumnSortKey
|
||||
})
|
||||
End If
|
||||
|
||||
oColumnSortKey += 1
|
||||
Next
|
||||
|
||||
'For Each oSubElement As XElement In oSubElements
|
||||
@@ -229,12 +235,12 @@ Namespace Documents
|
||||
|
||||
' Create a DocumentRow object for each Top Level Element
|
||||
Dim oRow = New DocumentRow With {
|
||||
.SortKey = oSortKey,
|
||||
.SortKey = oRowSortKey,
|
||||
.Name = oTopLevelElement.Name.ToString,
|
||||
.Fields = oFields
|
||||
}
|
||||
|
||||
oSortKey += 1
|
||||
oRowSortKey += 1
|
||||
oDocumentRows.Add(oRow)
|
||||
Next
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
Public Property External As String = ""
|
||||
Public Property Final As String = ""
|
||||
Public Property Required As Boolean = False
|
||||
Public Property SortKey As Integer = 0
|
||||
|
||||
Public ReadOnly Property HasError As Boolean
|
||||
Get
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Schemas\BaseSchema.vb" />
|
||||
<Compile Include="Schemas\MappingConfig.vb" />
|
||||
<Compile Include="Schemas\Orders\Helpers.vb" />
|
||||
<Compile Include="Schemas\Orders\Input.vb" />
|
||||
<Compile Include="Schemas\Orders\OrderSchema.vb" />
|
||||
@@ -135,7 +136,7 @@
|
||||
<Compile Include="Schemas\Schema.vb" />
|
||||
<Compile Include="Schemas\SchemaLoader.vb" />
|
||||
<Compile Include="Serializer.vb" />
|
||||
<Compile Include="Schemas\Configuration.vb" />
|
||||
<Compile Include="Schemas\SchemaConfig.vb" />
|
||||
<Compile Include="Winline\Entities\Account.vb" />
|
||||
<Compile Include="Winline\WinlineData.vb" />
|
||||
<Compile Include="Winline\Entities\Article.vb" />
|
||||
|
||||
12
MultiTool.Shared/Schemas/MappingConfig.vb
Normal file
12
MultiTool.Shared/Schemas/MappingConfig.vb
Normal file
@@ -0,0 +1,12 @@
|
||||
Namespace Schemas
|
||||
Public Class MappingConfig
|
||||
Public Property OrderKey As Integer
|
||||
Public Property SourceName As String
|
||||
Public Property SourceItem As String
|
||||
Public Property SourceRegex As String
|
||||
Public Property DestinationName As String
|
||||
Public Property DestinationItem As String
|
||||
Public Property DestinationValue As String
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -1,6 +1,7 @@
|
||||
Public Class ReportHead
|
||||
Public Property Title As String
|
||||
Public Property Subtitle As String
|
||||
Public Property Filename As String
|
||||
|
||||
Public Property DateCreated As Date
|
||||
Public Property Id As String
|
||||
|
||||
@@ -5,7 +5,7 @@ Namespace Schemas
|
||||
''' <summary>
|
||||
''' Class for loading column/field config from database
|
||||
''' </summary>
|
||||
Public Class Configuration
|
||||
Public Class SchemaConfig
|
||||
Public Columns As List(Of ColumnConfig)
|
||||
|
||||
Public Function GetColumn(pName As String) As ColumnConfig
|
||||
@@ -10,12 +10,14 @@ Namespace Schemas
|
||||
|
||||
Private ReadOnly ns As XNamespace = "http://www.w3.org/2001/XMLSchema"
|
||||
|
||||
Public SchemaList As List(Of Schema)
|
||||
Public TemplateConfiguration As New Configuration
|
||||
Public Property SchemaList As List(Of Schema)
|
||||
Public Property TemplateConfiguration As New SchemaConfig
|
||||
Public Property MappingConfiguration As New List(Of MappingConfig)
|
||||
|
||||
Private ReadOnly Database As MSSQLServer
|
||||
|
||||
Private Const VWEDI_XML_ITEMS = "VWEDI_XML_ITEMS"
|
||||
Private Const VWEDI_XML_MAPPING = "VWEDI_XML_MAPPING"
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMSSQL As MSSQLServer)
|
||||
MyBase.New(pLogConfig, pLogConfig.GetLogger)
|
||||
@@ -49,6 +51,36 @@ Namespace Schemas
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadMappingConfiguration() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{VWEDI_XML_MAPPING}]"
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
|
||||
Dim oMappingConfigList As New List(Of MappingConfig)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oTemplate As New MappingConfig With {
|
||||
.OrderKey = GetRowItem(oRow, "ORDER_KEY", String.Empty),
|
||||
.SourceName = GetRowItem(oRow, "SOURCE_NAME", String.Empty),
|
||||
.SourceItem = GetRowItem(oRow, "SOURCE_ITEM", String.Empty),
|
||||
.SourceRegex = GetRowItem(oRow, "SOURCE_REGEX", String.Empty),
|
||||
.DestinationName = GetRowItem(oRow, "DESTINATION_NAME", String.Empty),
|
||||
.DestinationItem = GetRowItem(oRow, "DESTINATION_ITEM", String.Empty),
|
||||
.DestinationValue = GetRowItem(oRow, "DESTINATION_VALUE", String.Empty)
|
||||
}
|
||||
|
||||
oMappingConfigList.Add(oTemplate)
|
||||
Next
|
||||
|
||||
MappingConfiguration = oMappingConfigList
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadTemplateConfiguration() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{VWEDI_XML_ITEMS}]"
|
||||
@@ -76,7 +108,7 @@ Namespace Schemas
|
||||
oItems.Add(oColumn)
|
||||
Next
|
||||
|
||||
TemplateConfiguration = New Configuration With {
|
||||
TemplateConfiguration = New SchemaConfig With {
|
||||
.Columns = oItems
|
||||
}
|
||||
|
||||
@@ -131,7 +163,7 @@ Namespace Schemas
|
||||
Return pSchema
|
||||
End Function
|
||||
|
||||
Public Function UpdateSchemaFromDatabase(pSchema As Schema, pTemplateConfig As Configuration) As Schema
|
||||
Public Function UpdateSchemaFromDatabase(pSchema As Schema, pTemplateConfig As SchemaConfig) As Schema
|
||||
If pTemplateConfig Is Nothing Then
|
||||
Return pSchema
|
||||
End If
|
||||
|
||||
@@ -22,7 +22,7 @@ Namespace Winline
|
||||
AppDataPath = pAppDataPath
|
||||
End Sub
|
||||
|
||||
Public Async Function TransferDocumentToWinline(pDocument As Document, pMandator As Mandator) As Task(Of Boolean)
|
||||
Public Async Function TransferDocumentToWinline(pDocument As Document, pMandator As Mandator, Optional pIsTest As Boolean = False) As Task(Of Boolean)
|
||||
Dim oBytes As Byte() = GetBytesFromDocument(pDocument)
|
||||
Dim oWS As Config.WebServiceConfig = Config.Webservice
|
||||
|
||||
@@ -68,9 +68,12 @@ Namespace Winline
|
||||
Dim oTemplateName = pDocument.TemplateName
|
||||
|
||||
' ActionCode: Should this be a test or not?
|
||||
' 0 = Testcall
|
||||
' 0 = Test call
|
||||
' 1 = Real call
|
||||
Dim oActionCode = 1
|
||||
If pIsTest = True Then
|
||||
oActionCode = 0
|
||||
End If
|
||||
|
||||
' Byref: Should data be supplied as file or as string?
|
||||
' 0 = As String
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports MultiTool.Shared.Helpers
|
||||
Imports MultiTool.Shared.Schemas
|
||||
Imports System.Text.RegularExpressions
|
||||
|
||||
Namespace Winline
|
||||
@@ -165,16 +166,17 @@ Namespace Winline
|
||||
.Server = oDbInfo.Item2
|
||||
}
|
||||
|
||||
Dim oMandatorConfig As Config.MandatorConfig = Config.Mandators.
|
||||
Where(Function(m) oMandator.Id = m.Name).
|
||||
SingleOrDefault()
|
||||
'Dim oMandatorConfig As Config.MandatorConfig = Config.Mandators.
|
||||
' Where(Function(m) oMandator.Id = m.Name).
|
||||
' SingleOrDefault()
|
||||
|
||||
If oMandatorConfig IsNot Nothing Then
|
||||
oMandator.IsWhitelisted = True
|
||||
oMandator.Regex = oMandatorConfig.ArticleRegex
|
||||
oMandator.Order = oMandatorConfig.Order
|
||||
End If
|
||||
'Dim oMandatorConfig2 = MappingConfiguration.Where(Function(c) c.)
|
||||
|
||||
'If oMandatorConfig IsNot Nothing Then
|
||||
' oMandator.IsWhitelisted = True
|
||||
' oMandator.Regex = oMandatorConfig.ArticleRegex
|
||||
' oMandator.Order = oMandatorConfig.Order
|
||||
'End If
|
||||
|
||||
Mandators.Add(oMandator)
|
||||
Next
|
||||
|
||||
Reference in New Issue
Block a user