Rename Shared to Common
This commit is contained in:
35
MultiTool.Common/Templates/GeneralConfig.vb
Normal file
35
MultiTool.Common/Templates/GeneralConfig.vb
Normal file
@@ -0,0 +1,35 @@
|
||||
Namespace Templates
|
||||
Public Class GeneralConfig
|
||||
Public Property TemplateDirectory As String = ""
|
||||
|
||||
Public Property Webservice As New WebServiceConfig()
|
||||
Public Property DefaultYearOverride As Integer = 0
|
||||
|
||||
Public Class WebServiceConfig
|
||||
Public Property BaseUrl As String = "http://127.0.0.1/EWL"
|
||||
Public Property Username As String = "Username"
|
||||
Public Property Password As String = "Password"
|
||||
Public Property ImportBasePath As String = ""
|
||||
Public Property ImportRelativePath As String = ""
|
||||
End Class
|
||||
|
||||
<DebuggerStepThrough>
|
||||
Public Function GetYear() As Integer
|
||||
If DefaultYearOverride > 0 Then
|
||||
Return DefaultYearOverride
|
||||
End If
|
||||
|
||||
Return Now.Year
|
||||
End Function
|
||||
|
||||
<DebuggerStepThrough>
|
||||
Public Function GetWinLineYear()
|
||||
Return GetWinLineYear(GetYear)
|
||||
End Function
|
||||
|
||||
<DebuggerStepThrough>
|
||||
Public Function GetWinLineYear(pYear As Integer)
|
||||
Return (pYear - 1900) * 12
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
5
MultiTool.Common/Templates/MandatorConfig.vb
Normal file
5
MultiTool.Common/Templates/MandatorConfig.vb
Normal file
@@ -0,0 +1,5 @@
|
||||
Namespace Templates
|
||||
Public Class MandatorConfig
|
||||
Public Property Items As New List(Of MandatorConfigItem)
|
||||
End Class
|
||||
End Namespace
|
||||
7
MultiTool.Common/Templates/MandatorConfigItem.vb
Normal file
7
MultiTool.Common/Templates/MandatorConfigItem.vb
Normal file
@@ -0,0 +1,7 @@
|
||||
Namespace Templates
|
||||
Public Class MandatorConfigItem
|
||||
Public Property Name As String
|
||||
Public Property OrderKey As Integer
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
12
MultiTool.Common/Templates/MappingConfig.vb
Normal file
12
MultiTool.Common/Templates/MappingConfig.vb
Normal file
@@ -0,0 +1,12 @@
|
||||
Namespace Templates
|
||||
Public Class MappingConfig
|
||||
Public Class Entity
|
||||
Public Const MANDATOR = "MANDATOR"
|
||||
Public Const DOCUMENTTYPE = "DOCUMENTTYPE"
|
||||
Public Const ARTICLE = "ARTICLE"
|
||||
End Class
|
||||
|
||||
Public Property Items As New List(Of MappingConfigItem)
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
12
MultiTool.Common/Templates/MappingConfigItem.vb
Normal file
12
MultiTool.Common/Templates/MappingConfigItem.vb
Normal file
@@ -0,0 +1,12 @@
|
||||
Namespace Templates
|
||||
Public Class MappingConfigItem
|
||||
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
|
||||
97
MultiTool.Common/Templates/Template.vb
Normal file
97
MultiTool.Common/Templates/Template.vb
Normal file
@@ -0,0 +1,97 @@
|
||||
Imports DigitalData.Modules.Language
|
||||
|
||||
Namespace Templates
|
||||
|
||||
Public Class Template
|
||||
Public Property Guid As Integer
|
||||
Public Property Name As String
|
||||
Public Property FileName As String
|
||||
Public Property Description As String
|
||||
Public Property IsImport As Boolean
|
||||
Public Property Parameter1 As String
|
||||
Public Property Parameter2 As String
|
||||
Public Property FinalSQL As String
|
||||
|
||||
''' <summary>
|
||||
''' Tabledata from XSD
|
||||
''' </summary>
|
||||
Public Property Tables As New List(Of Table)
|
||||
|
||||
Public Property InputDirectory As String
|
||||
Public Property OutputDirectory As String
|
||||
Public Property ArchiveDirectory As String
|
||||
|
||||
Public ReadOnly Property OutputReportDirectory
|
||||
Get
|
||||
Return IO.Path.Combine(OutputDirectory, "Reports")
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property OutputWebserviceDirectory
|
||||
Get
|
||||
Return IO.Path.Combine(OutputDirectory, "WebService")
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property OutputXmlFileDirectory
|
||||
Get
|
||||
Return IO.Path.Combine(OutputDirectory, "XmlFiles")
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Function GetParameter(pName As String) As String
|
||||
Dim oParam1 As String = Utils.NotNull(Parameter1, String.Empty)
|
||||
Dim oParam2 As String = Utils.NotNull(Parameter2, String.Empty)
|
||||
|
||||
Dim oParamValue1 = TryGetParameter(oParam1)
|
||||
Dim oParamValue2 = TryGetParameter(oParam2)
|
||||
|
||||
If oParamValue1 IsNot Nothing AndAlso oParamValue1.Item1 = pName Then
|
||||
Return oParamValue1.Item2
|
||||
End If
|
||||
|
||||
If oParamValue2 IsNot Nothing AndAlso oParamValue2.Item1 = pName Then
|
||||
Return oParamValue2.Item2
|
||||
End If
|
||||
|
||||
Return Nothing
|
||||
End Function
|
||||
|
||||
Private Function TryGetParameter(pParameterString As String) As Tuple(Of String, String)
|
||||
If pParameterString <> String.Empty Then
|
||||
Dim oSplit = pParameterString.Split("=").ToList()
|
||||
|
||||
If oSplit.Count = 2 Then
|
||||
Return New Tuple(Of String, String)(oSplit.First, oSplit.Last)
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Table from XSD
|
||||
''' </summary>
|
||||
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 DataType As Constants.ColumnType
|
||||
''' <summary>
|
||||
''' Required value from Schema. This value will be written in the ColumnConfig and is not relevant from that point on.
|
||||
''' </summary>
|
||||
Public Property IsRequired As Boolean
|
||||
Public Property Config As TemplateConfigItem
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return Name
|
||||
End Function
|
||||
End Class
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
17
MultiTool.Common/Templates/TemplateConfig.vb
Normal file
17
MultiTool.Common/Templates/TemplateConfig.vb
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
Imports MultiTool.Common.Winline
|
||||
|
||||
Namespace Templates
|
||||
''' <summary>
|
||||
''' Class for loading column/field config from database
|
||||
''' </summary>
|
||||
Public Class TemplateConfig
|
||||
Public Property Items As List(Of TemplateConfigItem)
|
||||
|
||||
Public Function GetColumn(pName As String, pTable As String) As TemplateConfigItem
|
||||
Return Items.
|
||||
Where(Function(c) c.Name = pName And c.Table = pTable).
|
||||
FirstOrDefault()
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
59
MultiTool.Common/Templates/TemplateConfigItem.vb
Normal file
59
MultiTool.Common/Templates/TemplateConfigItem.vb
Normal file
@@ -0,0 +1,59 @@
|
||||
Imports MultiTool.Common.Constants
|
||||
Imports DigitalData.Modules.Language
|
||||
|
||||
Namespace Templates
|
||||
Public Class TemplateConfigItem
|
||||
Public Property Name As String
|
||||
Public Property Table As String
|
||||
Public Property Type As ColumnType
|
||||
Public Property Template As String
|
||||
Public Property OrderKey As Integer
|
||||
|
||||
Public Property IsHead As Boolean
|
||||
Public Property IsReadOnly As Boolean
|
||||
Public Property IsVisible As Boolean
|
||||
Public Property IsRequired As Boolean
|
||||
Public Property IsVirtual As Boolean
|
||||
|
||||
Public Property [Function] As ColumnFunction
|
||||
|
||||
Public ReadOnly Property FunctionName As String
|
||||
Get
|
||||
Return Utils.NotNull([Function]?.Name, String.Empty)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property FunctionParams As String
|
||||
Get
|
||||
Return Utils.NotNull([Function]?.Params, String.Empty)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Class ColumnFunction
|
||||
Public Id As XmlFunction
|
||||
Public Name As String
|
||||
Public Params As String
|
||||
End Class
|
||||
|
||||
Public Shared Function ConvertType(pType As String) As ColumnType
|
||||
Select Case pType
|
||||
Case DB_TYPE_DATE
|
||||
Return ColumnType.Date
|
||||
|
||||
Case DB_TYPE_DECIMAL
|
||||
Return ColumnType.Date
|
||||
|
||||
Case DB_TYPE_BOOLEAN
|
||||
Return ColumnType.Boolean
|
||||
|
||||
Case DB_TYPE_INTEGER
|
||||
Return ColumnType.Integer
|
||||
|
||||
Case Else
|
||||
Return ColumnType.String
|
||||
End Select
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
352
MultiTool.Common/Templates/TemplateLoader.vb
Normal file
352
MultiTool.Common/Templates/TemplateLoader.vb
Normal file
@@ -0,0 +1,352 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Language
|
||||
|
||||
Namespace Templates
|
||||
Public Class TemplateLoader
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly ns As XNamespace = "http://www.w3.org/2001/XMLSchema"
|
||||
|
||||
Public Property TemplateList As List(Of Template)
|
||||
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 Const SQL_VWMT_ITEMS = "SELECT * FROM [DD_ECM].[dbo].[VWMT_ITEMS]"
|
||||
Private Const SQL_VWMT_MAPPING = "SELECT * FROM [DD_ECM].[dbo].[VWMT_MAPPING]"
|
||||
Private Const SQL_TBMT_MANDATORS = "SELECT * FROM [DD_ECM].[dbo].[TBMT_MANDATORS] ORDER BY ORDER_KEY"
|
||||
Private Const SQL_TBMT_CONFIG = "SELECT * FROM [DD_ECM].[dbo].[TBMT_CONFIG]"
|
||||
Private Const SQL_TBMT_TEMPLATES = "SELECT * FROM [DD_ECM].[dbo].[TBMT_TEMPLATES] WHERE ACTIVE = 1"
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMSSQL As MSSQLServer)
|
||||
MyBase.New(pLogConfig, pMSSQL)
|
||||
End Sub
|
||||
|
||||
Public Async Function LoadTemplates() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(SQL_TBMT_TEMPLATES)
|
||||
Dim oTemplates As New List(Of Template)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oTemplate As New Template With {
|
||||
.Guid = oRow.Item("GUID"),
|
||||
.Name = oRow.ItemEx("NAME", String.Empty),
|
||||
.Description = oRow.ItemEx("DESCRIPTION", String.Empty),
|
||||
.FileName = oRow.ItemEx("FILE_NAME", String.Empty),
|
||||
.IsImport = oRow.ItemEx("IS_IMPORT", True),
|
||||
.FinalSQL = oRow.ItemEx("FINAL_SQL", String.Empty),
|
||||
.Parameter1 = oRow.ItemEx("PARAMETER_1", String.Empty),
|
||||
.Parameter2 = oRow.ItemEx("PARAMETER_2", String.Empty)
|
||||
}
|
||||
|
||||
oTemplates.Add(oTemplate)
|
||||
Next
|
||||
|
||||
TemplateList = oTemplates
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadGeneralConfiguration() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(SQL_TBMT_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 "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 oTable As DataTable = Await Database.GetDatatableAsync(SQL_VWMT_MAPPING)
|
||||
Dim oMappingConfig As New MappingConfig
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
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),
|
||||
.SourceRegex = oRow.ItemEx("SOURCE_REGEX", String.Empty),
|
||||
.DestinationName = oRow.ItemEx("DESTINATION_NAME", String.Empty),
|
||||
.DestinationItem = oRow.ItemEx("DESTINATION_ITEM", String.Empty),
|
||||
.DestinationValue = oRow.ItemEx("DESTINATION_VALUE", String.Empty)
|
||||
}
|
||||
|
||||
oMappingConfig.Items.Add(oTemplate)
|
||||
Next
|
||||
|
||||
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 oTable As DataTable = Await Database.GetDatatableAsync(SQL_TBMT_MANDATORS)
|
||||
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
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function LoadTemplateConfiguration() As Task(Of Boolean)
|
||||
Try
|
||||
Dim oTable As DataTable = Await Database.GetDatatableAsync(SQL_VWMT_ITEMS)
|
||||
Dim oItems As New List(Of TemplateConfigItem)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
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 = 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),
|
||||
.IsVirtual = oRow.ItemEx("IS_VIRTUAL", False),
|
||||
.IsHead = oRow.ItemEx("IS_HEAD", True),
|
||||
.[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)
|
||||
}
|
||||
}
|
||||
|
||||
oItems.Add(oColumn)
|
||||
Next
|
||||
|
||||
TemplateConfiguration = New TemplateConfig With {
|
||||
.Items = oItems
|
||||
}
|
||||
|
||||
Return True
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function UpdateTemplateFromFile(pTemplate As Template, pInputDirectory As String) As Template
|
||||
Dim oFullPath = Path.Combine(pInputDirectory, pTemplate.FileName)
|
||||
|
||||
If Not IO.File.Exists(oFullPath) Then
|
||||
Throw New FileNotFoundException(oFullPath)
|
||||
End If
|
||||
|
||||
Dim oElements = GetTemplateElements(oFullPath)
|
||||
|
||||
For Each oElement In oElements
|
||||
Dim oColumns = GetElementColumns(oElement)
|
||||
Dim oTemplateColumns As New List(Of Template.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 oTemplateColumn As New Template.Column With {
|
||||
.Name = oName,
|
||||
.DataType = oType,
|
||||
.IsRequired = oRequired
|
||||
}
|
||||
oTemplateColumns.Add(oTemplateColumn)
|
||||
Next
|
||||
|
||||
pTemplate.Tables.Add(New Template.Table With {
|
||||
.Name = XmlData.GetElementAttribute(oElement, "name"),
|
||||
.Columns = oTemplateColumns
|
||||
})
|
||||
|
||||
Next
|
||||
|
||||
Return pTemplate
|
||||
End Function
|
||||
|
||||
Public Function UpdateTemplateTablesFromDatabase(pTemplate As Template, pTemplateConfig As TemplateConfig) As Template
|
||||
If pTemplateConfig Is Nothing Then
|
||||
Return pTemplate
|
||||
End If
|
||||
|
||||
Dim oTemplate = CreateVirtualColumns(pTemplate, pTemplateConfig)
|
||||
|
||||
For Each oTable In oTemplate.Tables
|
||||
For Each oColumn As Template.Column In oTable.Columns
|
||||
Dim oConfig As TemplateConfigItem = pTemplateConfig.GetColumn(oColumn.Name, oTable.Name)
|
||||
|
||||
If oConfig Is Nothing Then
|
||||
oConfig = New TemplateConfigItem With {
|
||||
.IsRequired = oColumn.IsRequired,
|
||||
.Name = oColumn.Name
|
||||
}
|
||||
End If
|
||||
|
||||
oColumn.Config = oConfig
|
||||
Next
|
||||
Next
|
||||
|
||||
Return oTemplate
|
||||
End Function
|
||||
|
||||
Private Function CreateVirtualColumns(pTemplate As Template, pTemplateConfig As TemplateConfig) As Template
|
||||
For Each oConfigItem In pTemplateConfig.Items
|
||||
' Find the table that relates to this config item
|
||||
Dim oTable = pTemplate.Tables.Where(Function(table) table.Name = oConfigItem.Table).FirstOrDefault()
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("Table [{0}] for item [{1}] does exist in this Template!", oConfigItem.Table, oConfigItem.Name)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oColumnExists = oTable.Columns.Any(Function(column) column.Name = oConfigItem.Name)
|
||||
|
||||
If oColumnExists = False And oConfigItem.IsVirtual = True Then
|
||||
oTable.Columns.Add(New Template.Column() With {
|
||||
.Name = oConfigItem.Name,
|
||||
.Config = oConfigItem,
|
||||
.DataType = Constants.ColumnType.String,
|
||||
.IsRequired = False
|
||||
})
|
||||
End If
|
||||
Next
|
||||
|
||||
Return pTemplate
|
||||
End Function
|
||||
|
||||
Public Function UpdateTemplateFromDatabase(pTemplate As Template) As Template
|
||||
Try
|
||||
Dim oTable As DataTable = Database.GetDatatable($"{SQL_TBMT_CONFIG} WHERE TEMPLATE_ID = {pTemplate.Guid}")
|
||||
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 "INPUT_DIRECTORY"
|
||||
pTemplate.InputDirectory = oValue
|
||||
|
||||
Case "OUTPUT_DIRECTORY"
|
||||
pTemplate.OutputDirectory = oValue
|
||||
|
||||
Case "ARCHIVE_DIRECTORY"
|
||||
pTemplate.ArchiveDirectory = oValue
|
||||
|
||||
End Select
|
||||
Next
|
||||
|
||||
Return pTemplate
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return pTemplate
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function GetElementType(pElement As XElement) As Constants.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 Constants.TEMPLATE_TYPE_DATE
|
||||
Return Constants.ColumnType.Date
|
||||
Case Constants.TEMPLATE_TYPE_INTEGER
|
||||
Return Constants.ColumnType.Integer
|
||||
Case Constants.TEMPLATE_TYPE_DECIMAL
|
||||
Return Constants.ColumnType.Decimal
|
||||
Case Constants.TEMPLATE_TYPE_BOOLEAN
|
||||
Return Constants.ColumnType.Boolean
|
||||
Case Else
|
||||
Return Constants.ColumnType.String
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Public Function GetTemplateElements(pTemplateFilePath As String) As List(Of XElement)
|
||||
Dim oText As String = IO.File.ReadAllText(pTemplateFilePath)
|
||||
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
|
||||
Reference in New Issue
Block a user