First pass of new mandator selection
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports MultiTool.Shared.Winline
|
||||
Imports MultiTool.Shared.Helpers
|
||||
|
||||
Namespace Templates
|
||||
Public Class TemplateLoader
|
||||
@@ -12,12 +10,15 @@ Namespace Templates
|
||||
|
||||
Public Property TemplateList As List(Of Template)
|
||||
Public Property TemplateConfiguration As New TemplateConfig
|
||||
Public Property MappingConfiguration As New List(Of MappingConfig)
|
||||
Public Property MappingConfiguration As New MappingConfig
|
||||
Public Property MandatorConfiguration As New MandatorConfig
|
||||
|
||||
Private ReadOnly Database As MSSQLServer
|
||||
|
||||
Private Const VWEDI_XML_ITEMS = "VWEDI_XML_ITEMS"
|
||||
Private Const VWEDI_XML_MAPPING = "VWEDI_XML_MAPPING"
|
||||
Private Const TBEDI_XML_MANDATORS = "TBEDI_XML_MANDATORS"
|
||||
Private Const TBEDI_XML_TEMPLATES = "TBEDI_XML_TEMPLATES"
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMSSQL As MSSQLServer)
|
||||
MyBase.New(pLogConfig, pLogConfig.GetLogger)
|
||||
@@ -26,7 +27,7 @@ Namespace Templates
|
||||
|
||||
Public Async Function LoadTemplates() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[TBEDI_XML_TEMPLATES]"
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{TBEDI_XML_TEMPLATES}]"
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
|
||||
Dim oTemplates As New List(Of Template)
|
||||
|
||||
@@ -55,10 +56,10 @@ Namespace Templates
|
||||
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)
|
||||
Dim oMappingConfig As New MappingConfig
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oTemplate As New MappingConfig With {
|
||||
Dim oTemplate As New MappingConfigItem With {
|
||||
.OrderKey = oRow.ItemEx("ORDER_KEY", String.Empty),
|
||||
.SourceName = oRow.ItemEx("SOURCE_NAME", String.Empty),
|
||||
.SourceItem = oRow.ItemEx("SOURCE_ITEM", String.Empty),
|
||||
@@ -68,10 +69,35 @@ Namespace Templates
|
||||
.DestinationValue = oRow.ItemEx("DESTINATION_VALUE", String.Empty)
|
||||
}
|
||||
|
||||
oMappingConfigList.Add(oTemplate)
|
||||
oMappingConfig.Items.Add(oTemplate)
|
||||
Next
|
||||
|
||||
MappingConfiguration = oMappingConfigList
|
||||
MappingConfiguration = oMappingConfig
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadMandatorConfiguration() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{TBEDI_XML_MANDATORS}] ORDER BY ORDER_KEY"
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
|
||||
Dim oMandatorConfig As New MandatorConfig
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oMandator As New MandatorConfigItem With {
|
||||
.OrderKey = oRow.ItemEx("ORDER_KEY", String.Empty),
|
||||
.Name = oRow.ItemEx("NAME", String.Empty)
|
||||
}
|
||||
|
||||
oMandatorConfig.Items.Add(oMandator)
|
||||
Next
|
||||
|
||||
MandatorConfiguration = oMandatorConfig
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
@@ -85,20 +111,20 @@ Namespace Templates
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{VWEDI_XML_ITEMS}]"
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
|
||||
Dim oItems As New List(Of ColumnConfig)
|
||||
Dim oItems As New List(Of TemplateConfigItem)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oColumn As New ColumnConfig() With {
|
||||
Dim oColumn As New TemplateConfigItem() With {
|
||||
.Template = oRow.ItemEx("TEMPLATE_NAME", String.Empty),
|
||||
.Table = oRow.ItemEx("XML_TABLE", String.Empty),
|
||||
.Name = oRow.ItemEx("XML_ITEM", String.Empty),
|
||||
.Type = ColumnConfig.ConvertType(ItemEx(oRow, "DATA_TYPE", String.Empty)),
|
||||
.Type = TemplateConfigItem.ConvertType(ItemEx(oRow, "DATA_TYPE", String.Empty)),
|
||||
.OrderKey = oRow.ItemEx("ORDER_KEY", 0),
|
||||
.IsReadOnly = oRow.ItemEx("IS_READ_ONLY", False),
|
||||
.IsVisible = oRow.ItemEx("IS_VISIBLE", True),
|
||||
.IsRequired = oRow.ItemEx("IS_REQUIRED", False),
|
||||
.IsHead = oRow.ItemEx("IS_HEAD", True),
|
||||
.[Function] = New ColumnConfig.ColumnFunction With {
|
||||
.[Function] = New TemplateConfigItem.ColumnFunction With {
|
||||
.Id = oRow.ItemEx("FUNCTION_ID", 0),
|
||||
.Name = oRow.ItemEx("FUNCTION_NAME", String.Empty),
|
||||
.Params = oRow.ItemEx("FUNCTION_PARAMETERS", String.Empty)
|
||||
@@ -109,7 +135,7 @@ Namespace Templates
|
||||
Next
|
||||
|
||||
TemplateConfiguration = New TemplateConfig With {
|
||||
.Columns = oItems
|
||||
.Items = oItems
|
||||
}
|
||||
|
||||
Return True
|
||||
@@ -173,7 +199,7 @@ Namespace Templates
|
||||
Dim oConfig = pTemplateConfig.GetColumn(oColumn.Name)
|
||||
|
||||
If oConfig Is Nothing Then
|
||||
oConfig = New ColumnConfig With {
|
||||
oConfig = New TemplateConfigItem With {
|
||||
.IsRequired = oColumn.IsRequired,
|
||||
.Name = oColumn.Name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user