Migrate configuration from UserConfig to database
This commit is contained in:
@@ -12,13 +12,15 @@ Namespace Templates
|
||||
Public Property TemplateConfiguration As New TemplateConfig
|
||||
Public Property MappingConfiguration As New MappingConfig
|
||||
Public Property MandatorConfiguration As New MandatorConfig
|
||||
Public Property GeneralConfiguration As New GeneralConfig
|
||||
|
||||
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"
|
||||
Private Const SQL_VWEDI_XML_ITEMS = "SELECT * FROM [DD_ECM].[dbo].[VWEDI_XML_ITEMS]"
|
||||
Private Const SQL_VWEDI_XML_MAPPING = "SELECT * FROM [DD_ECM].[dbo].[VWEDI_XML_MAPPING]"
|
||||
Private Const SQL_TBEDI_XML_MANDATORS = "SELECT * FROM [DD_ECM].[dbo].[TBEDI_XML_MANDATORS] ORDER BY ORDER_KEY"
|
||||
Private Const SQL_TBEDI_XML_CONFIG = "SELECT * FROM [DD_ECM].[dbo].[TBEDI_XML_CONFIG]"
|
||||
Private Const SQL_TBEDI_XML_TEMPLATES = "SELECT * FROM [DD_ECM].[dbo].[TBEDI_XML_TEMPLATES]"
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMSSQL As MSSQLServer)
|
||||
MyBase.New(pLogConfig, pLogConfig.GetLogger)
|
||||
@@ -27,8 +29,7 @@ Namespace Templates
|
||||
|
||||
Public Async Function LoadTemplates() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{TBEDI_XML_TEMPLATES}]"
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(SQL_TBEDI_XML_TEMPLATES)
|
||||
Dim oTemplates As New List(Of Template)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
@@ -52,10 +53,58 @@ Namespace Templates
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadGeneralConfiguration() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(SQL_TBEDI_XML_CONFIG)
|
||||
Dim oGeneralConfig As New GeneralConfig
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oValue As String = oRow.ItemEx("VALUE", String.Empty)
|
||||
|
||||
Select Case oRow.Item("KEY")
|
||||
Case "YEAR_OVERRIDE"
|
||||
oGeneralConfig.DefaultYearOverride = oRow.ItemEx("VALUE", 0)
|
||||
|
||||
Case "WEBSERVICE_BASEURL"
|
||||
oGeneralConfig.Webservice.BaseUrl = oValue
|
||||
|
||||
Case "WEBSERVICE_USERNAME"
|
||||
oGeneralConfig.Webservice.Username = oValue
|
||||
|
||||
Case "WEBSERIVCE_PASSWORD"
|
||||
oGeneralConfig.Webservice.Password = oValue
|
||||
|
||||
Case "WEBSERVICE_IMPORT_BASE_PATH"
|
||||
oGeneralConfig.Webservice.ImportBasePath = oValue
|
||||
|
||||
Case "WEBSERVICE_IMPORT_RELATIVE_PATH"
|
||||
oGeneralConfig.Webservice.ImportRelativePath = oValue
|
||||
|
||||
Case "INPUT_DIRECTORY"
|
||||
oGeneralConfig.InputDirectory = oValue
|
||||
|
||||
Case "OUTPUT_DIRECTORY"
|
||||
oGeneralConfig.OutputDirectory = oValue
|
||||
|
||||
Case "TEMPLATE_DIRECTORY"
|
||||
oGeneralConfig.TemplateDirectory = oValue
|
||||
|
||||
End Select
|
||||
Next
|
||||
|
||||
GeneralConfiguration = oGeneralConfig
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
|
||||
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 oTable As DataTable = Await Database.GetDatatableAsync(SQL_VWEDI_XML_MAPPING)
|
||||
Dim oMappingConfig As New MappingConfig
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
@@ -84,8 +133,7 @@ Namespace Templates
|
||||
|
||||
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 oTable As DataTable = Await Database.GetDatatableAsync(SQL_TBEDI_XML_MANDATORS)
|
||||
Dim oMandatorConfig As New MandatorConfig
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
@@ -109,8 +157,7 @@ Namespace Templates
|
||||
|
||||
Public Async Function LoadTemplateConfiguration() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{VWEDI_XML_ITEMS}]"
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(SQL_VWEDI_XML_ITEMS)
|
||||
Dim oItems As New List(Of TemplateConfigItem)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
|
||||
Reference in New Issue
Block a user