improve function + params handling
This commit is contained in:
parent
e3c2e100bb
commit
4c1a3a9220
@ -281,22 +281,11 @@ Namespace Documents
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oFunctionName = oColumn.Config?.Function?.Name
|
||||
Dim oFunctionName = oColumn.Config.FunctionName
|
||||
Dim oFunctionParams = oColumn.Config.FunctionParams
|
||||
Dim oParamsDict = ParseFunctionParamsAsDict(oFunctionParams)
|
||||
|
||||
' TODO: Make more nice
|
||||
Dim oParams = oColumn.Config?.Function?.Params
|
||||
Dim oParamsDict As New Dictionary(Of String, String)
|
||||
|
||||
If oParams IsNot Nothing AndAlso oParams <> String.Empty Then
|
||||
Dim oParamList = oParams.Split("|").ToList()
|
||||
For Each oParam In oParamList
|
||||
Dim oParamSplit = oParam.Split("=")
|
||||
oParamsDict.Add(oParamSplit(0), oParamSplit(1))
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
If oFunctionName = "PRICE" Then
|
||||
If oFunctionName = Constants.FUNCTION_PRICE Then
|
||||
Await SetPrice(oRow, oField.Key, oParamsDict, pDocument, pMandator, pTemplate)
|
||||
End If
|
||||
Next
|
||||
@ -319,10 +308,12 @@ Namespace Documents
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oFunctionName = oColumn.Config?.Function?.Name
|
||||
Dim oFunctionName = oColumn.Config.FunctionName
|
||||
Dim oFunctionParams = oColumn.Config.FunctionParams
|
||||
Dim oParamsDict = ParseFunctionParamsAsDict(oFunctionParams)
|
||||
|
||||
If oFunctionName = "GLN" Then
|
||||
SetAccountByGLN(oRow, pMandator, oField.Key, Nothing)
|
||||
SetAccountByGLN(oRow, pMandator, oField.Key, Nothing, oParamsDict)
|
||||
End If
|
||||
|
||||
If oFunctionName = "EAN" Then
|
||||
@ -419,7 +410,7 @@ Namespace Documents
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub SetAccountByGLN(oRow As DocumentRow, pMandator As Mandator, pNumberField As String, pNameField As String)
|
||||
Private Sub SetAccountByGLN(oRow As DocumentRow, pMandator As Mandator, pNumberField As String, pNameField As String, pParams As Dictionary(Of String, String))
|
||||
' Try to read the Account number (which is a GLN really) and account Name
|
||||
Dim oNumberItem As DocumentRow.FieldValue = oRow.Fields.GetOrDefault(pNumberField)
|
||||
Dim oNameItem As DocumentRow.FieldValue = oRow.Fields.GetOrDefault(pNameField)
|
||||
@ -456,6 +447,20 @@ Namespace Documents
|
||||
Private Function WrapFileInfo(pFileInfo As FileInfo) As Document
|
||||
Return New Document With {.File = pFileInfo}
|
||||
End Function
|
||||
|
||||
Private Function ParseFunctionParamsAsDict(pParams As String) As Dictionary(Of String, String)
|
||||
Dim oParamsDict As New Dictionary(Of String, String)
|
||||
|
||||
If pParams <> String.Empty Then
|
||||
Dim oParamList = pParams.Split("|").ToList()
|
||||
For Each oParam In oParamList
|
||||
Dim oParamSplit = oParam.Split("=")
|
||||
oParamsDict.Add(oParamSplit(0), oParamSplit(1))
|
||||
Next
|
||||
End If
|
||||
|
||||
Return oParamsDict
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@ -1,4 +1,5 @@
|
||||
Imports MultiTool.Shared.Constants
|
||||
Imports DigitalData.Modules.Language
|
||||
|
||||
Namespace Templates
|
||||
Public Class TemplateConfigItem
|
||||
@ -16,6 +17,18 @@ Namespace Templates
|
||||
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user