Improve frmConfig, Fix missing loop in ApplyItemFunctionsForExport, Add support for SQL function
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Imports System.Net.Http
|
||||
Imports System.Text
|
||||
Imports System.Xml
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports MultiTool.Shared.Documents
|
||||
@@ -17,14 +18,16 @@ Namespace Winline
|
||||
Private ReadOnly GeneralConfig As GeneralConfig
|
||||
Private ReadOnly Winline As WinlineData
|
||||
Private ReadOnly FileEx As File
|
||||
Private ReadOnly Patterns As Patterns
|
||||
|
||||
Public Event WebServiceProgress As EventHandler(Of String)
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pWinline As WinlineData, pWebserviceConfig As WebServiceConfig, pGeneralConfig As GeneralConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pWinline As WinlineData, pWebserviceConfig As WebServiceConfig, pGeneralConfig As GeneralConfig)
|
||||
MyBase.New(pLogConfig, pDatabase)
|
||||
Serializer = New Serializer(pLogConfig)
|
||||
Config = pWebserviceConfig
|
||||
GeneralConfig = pGeneralConfig
|
||||
Patterns = New Patterns(pLogConfig, pGeneralConfig)
|
||||
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
|
||||
Winline = pWinline
|
||||
End Sub
|
||||
@@ -202,7 +205,7 @@ Namespace Winline
|
||||
#End Region
|
||||
|
||||
#Region "Export"
|
||||
Async Function ExportDocumentFromWinline(pDocument As Entities.Document, pTemplate As Template, pMandator As Mandator, Optional pIsTest As Boolean = False) As Task(Of Boolean)
|
||||
Async Function ExportDocumentFromWinline(pDocument As Entities.ExportDocument, pTemplate As Template, pMandator As Mandator, Optional pIsTest As Boolean = False) As Task(Of Boolean)
|
||||
Dim oWS = Config
|
||||
|
||||
' --- Build all teh filenamez and pathz
|
||||
@@ -247,7 +250,7 @@ Namespace Winline
|
||||
' --- Bring the action!
|
||||
Try
|
||||
Dim oResponse As HttpResponseMessage = Await oClient.GetAsync(oURL)
|
||||
Await HandleExportResponse(oResponse, pTemplate, pMandator, oBaseFileName)
|
||||
Await HandleExportResponse(oResponse, pDocument, pTemplate, pMandator, oBaseFileName)
|
||||
|
||||
Return True
|
||||
|
||||
@@ -261,7 +264,7 @@ Namespace Winline
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Async Function HandleExportResponse(pResponse As HttpResponseMessage, pTemplate As Template, pMandator As Mandator, pBaseFileNAme As String) As Task
|
||||
Private Async Function HandleExportResponse(pResponse As HttpResponseMessage, pDocument As Entities.ExportDocument, pTemplate As Template, pMandator As Mandator, pBaseFileNAme As String) As Task
|
||||
pResponse.EnsureSuccessStatusCode()
|
||||
Dim oResponseBody As String = Await pResponse.Content.ReadAsStringAsync()
|
||||
Dim oContentType = pResponse.Content.Headers.ContentType.MediaType
|
||||
@@ -269,7 +272,7 @@ Namespace Winline
|
||||
|
||||
RaiseEvent WebServiceProgress(Me, "Antwort verarbeiten")
|
||||
|
||||
oResponseBody = ApplyItemFunctionsForExport(pTemplate, pMandator, oResponseBody)
|
||||
oResponseBody = ApplyItemFunctionsForExport(pDocument, pTemplate, pMandator, oResponseBody)
|
||||
|
||||
Select Case oContentType
|
||||
Case "text/xml"
|
||||
@@ -287,7 +290,7 @@ Namespace Winline
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Private Function ApplyItemFunctionsForExport(pTemplate As Template, pMandator As Mandator, oResponseBody As String) As String
|
||||
Private Function ApplyItemFunctionsForExport(pDocument As Entities.ExportDocument, pTemplate As Template, pMandator As Mandator, oResponseBody As String) As String
|
||||
Dim oDoc As New XmlDocument()
|
||||
oDoc.LoadXml(oResponseBody)
|
||||
|
||||
@@ -301,23 +304,41 @@ Namespace Winline
|
||||
End If
|
||||
|
||||
Dim oFunction = oItem.Config.Function.Name
|
||||
Dim oNode = oDoc.SelectSingleNode($"//MESOWebService/{oTableName}/{oItemName}")
|
||||
|
||||
If oItem.Config.Function.Name = "GLN" Then
|
||||
Dim oGLN = Winline.TryGetGLN(oNode.InnerText, pMandator)
|
||||
If oGLN Is Nothing Then
|
||||
Throw New Exceptions.MissingAttributeException("GLN")
|
||||
Dim oPath = $"//MESOWebService/{oTableName}/{oItemName}"
|
||||
Dim oNodes As XmlNodeList = oDoc.SelectNodes(oPath)
|
||||
|
||||
For Each oNode As XmlNode In oNodes
|
||||
If oItem.Config.Function.Name = "GLN" Then
|
||||
Dim oGLN = Winline.TryGetGLN(oNode.InnerText, pMandator)
|
||||
|
||||
If oGLN Is Nothing Then
|
||||
Throw New Exceptions.MissingAttributeException("GLN")
|
||||
End If
|
||||
|
||||
oNode.InnerText = oGLN
|
||||
|
||||
ElseIf oItem.Config.Function.Name = "EAN" Then
|
||||
Dim oEAN = Winline.TryGetEAN(oNode.InnerText, pMandator)
|
||||
|
||||
If oEAN Is Nothing Then
|
||||
Throw New Exceptions.MissingAttributeException("EAN")
|
||||
End If
|
||||
|
||||
oNode.InnerText = oEAN
|
||||
|
||||
ElseIf oItem.Config.Function.Name = "SQL" Then
|
||||
Dim oSQL = Patterns.ReplaceForExport(pTemplate, pDocument, pMandator, oItem.Config.Function.Params)
|
||||
Dim oValue = Database.GetScalarValue(oSQL)
|
||||
|
||||
If oValue Is Nothing Then
|
||||
Throw New Exceptions.MissingAttributeException("SQL")
|
||||
End If
|
||||
|
||||
oNode.InnerText = oValue
|
||||
|
||||
End If
|
||||
|
||||
oNode.InnerText = oGLN
|
||||
ElseIf oItem.Config.Function.Name = "EAN" Then
|
||||
Dim oEAN = Winline.TryGetEAN(oNode.InnerText, pMandator)
|
||||
If oEAN Is Nothing Then
|
||||
Throw New Exceptions.MissingAttributeException("EAN")
|
||||
End If
|
||||
|
||||
oNode.InnerText = oEAN
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
Next
|
||||
|
||||
|
||||
Reference in New Issue
Block a user