Start implementing FIELD function
This commit is contained in:
parent
b941416de4
commit
efd2aeb775
@ -7,6 +7,7 @@
|
|||||||
Public Const FUNCTION_EAN = "EAN"
|
Public Const FUNCTION_EAN = "EAN"
|
||||||
Public Const FUNCTION_PRICE = "PRICE"
|
Public Const FUNCTION_PRICE = "PRICE"
|
||||||
Public Const FUNCTION_SQL = "SQL"
|
Public Const FUNCTION_SQL = "SQL"
|
||||||
|
Public Const FUNCTION_FIELD = "FIELD"
|
||||||
|
|
||||||
Public Const TEMPLATE_TYPE_DATE = "xs:date"
|
Public Const TEMPLATE_TYPE_DATE = "xs:date"
|
||||||
Public Const TEMPLATE_TYPE_INTEGER = "xs:integer"
|
Public Const TEMPLATE_TYPE_INTEGER = "xs:integer"
|
||||||
|
|||||||
@ -254,6 +254,10 @@ Namespace Documents
|
|||||||
|
|
||||||
' These functions will only be applied if the document does not have errors
|
' These functions will only be applied if the document does not have errors
|
||||||
pDocument = Await MaybeApplyPriceFunctions(pDocument, oMandator, pTemplate)
|
pDocument = Await MaybeApplyPriceFunctions(pDocument, oMandator, pTemplate)
|
||||||
|
|
||||||
|
' This function needs to be the last one because
|
||||||
|
' it can relate to any previously set value
|
||||||
|
ApplyFieldFunctionForImport(pDocument, oMandator, pTemplate)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Return pDocument
|
Return pDocument
|
||||||
@ -329,6 +333,42 @@ Namespace Documents
|
|||||||
Return pDocument
|
Return pDocument
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Private Function ApplyFieldFunctionForImport(pDocument As Document, pMandator As Mandator, pTemplate As Template) As Document
|
||||||
|
For Each oRow As DocumentRow In pDocument.Rows
|
||||||
|
Dim oTable = pTemplate.Tables.Where(Function(table) table.Name = oRow.TableName).SingleOrDefault()
|
||||||
|
|
||||||
|
For Each oField In oRow.Fields
|
||||||
|
If oTable Is Nothing Then
|
||||||
|
Exit For
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim oColumn = oTable.Columns.Where(Function(c) c.Name = oField.Key).SingleOrDefault()
|
||||||
|
If oColumn Is Nothing Then
|
||||||
|
Continue For
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim oFunctionName = oColumn.Config.FunctionName
|
||||||
|
Dim oFunctionParams = oColumn.Config.FunctionParams
|
||||||
|
Dim oParamsDict = ParseFunctionParamsAsDict(oFunctionParams)
|
||||||
|
|
||||||
|
If oFunctionName = Constants.FUNCTION_FIELD Then
|
||||||
|
|
||||||
|
Dim oParam = oParamsDict.FirstOrDefault()
|
||||||
|
|
||||||
|
If IsNothing(oParam) Then
|
||||||
|
Logger.Warn("FIELD function needs exactly one parameter!")
|
||||||
|
Return pDocument
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return pDocument
|
||||||
|
End Function
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Execute Mappings defined in TBMT_MAPPING_CONFIG,
|
''' Execute Mappings defined in TBMT_MAPPING_CONFIG,
|
||||||
''' for example mapping Article Numbers to Winline Mandators
|
''' for example mapping Article Numbers to Winline Mandators
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user