Improve frmConfig, Fix missing loop in ApplyItemFunctionsForExport, Add support for SQL function
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class BaseClass
|
||||
Public ReadOnly LogConfig As LogConfig
|
||||
Public ReadOnly Logger As Logger
|
||||
Public ReadOnly Helpers As Helpers
|
||||
Inherits DigitalData.Modules.Base.BaseClass
|
||||
|
||||
Friend Database As MSSQLServer
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
LogConfig = pLogConfig
|
||||
Logger = LogConfig.GetLogger()
|
||||
Helpers = New Helpers(pLogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
End Sub
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer)
|
||||
MyBase.New(pLogConfig)
|
||||
Database = pDatabase
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Helpers
|
||||
Private ReadOnly LogConfig As LogConfig
|
||||
Private ReadOnly Logger As Logger
|
||||
|
||||
''' <summary>
|
||||
''' This class needs to initialize the logger by itself!
|
||||
''' </summary>
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger
|
||||
End Sub
|
||||
End Class
|
||||
@@ -50,6 +50,9 @@
|
||||
<Reference Include="DevExpress.Data.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.DataAccess.v21.2, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Printing.v21.2.Core, Version=21.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DigitalData.Modules.Base">
|
||||
<HintPath>..\..\DDMonorepo\Modules.Base\Base\bin\Debug\DigitalData.Modules.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DigitalData.Modules.Config">
|
||||
<HintPath>..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -107,7 +110,6 @@
|
||||
<Compile Include="Documents\DocumentType.vb" />
|
||||
<Compile Include="Documents\DocumentLoader.vb" />
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Helpers.vb" />
|
||||
<Compile Include="IDictionaryEx.vb" />
|
||||
<Compile Include="IEnumerableEx.vb" />
|
||||
<Compile Include="Mapper.vb" />
|
||||
@@ -137,7 +139,7 @@
|
||||
<Compile Include="Report\ReportHead.vb" />
|
||||
<Compile Include="Report\ReportPosition.vb" />
|
||||
<Compile Include="Report\ReportSource.vb" />
|
||||
<Compile Include="Winline\Entities\Document.vb" />
|
||||
<Compile Include="Winline\Entities\ExportDocument.vb" />
|
||||
<Compile Include="Winline\Entities\Response.vb" />
|
||||
<Compile Include="Templates\Template.vb" />
|
||||
<Compile Include="Templates\TemplateLoader.vb" />
|
||||
|
||||
@@ -65,7 +65,7 @@ Public Class Patterns
|
||||
Return oString
|
||||
End Function
|
||||
|
||||
Public Function ReplaceForExport(pTemplate As Template, pDocument As Winline.Entities.Document, pMandator As Mandator, oString As String)
|
||||
Public Function ReplaceForExport(pTemplate As Template, pDocument As ExportDocument, pMandator As Mandator, oString As String)
|
||||
Dim oRegex = New Regex("{#(\w+)#([\w\s_-]+)}+")
|
||||
Dim oMatches As MatchCollection = oRegex.Matches(oString)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Namespace Winline.Entities
|
||||
Public Class Document
|
||||
Public Class ExportDocument
|
||||
Public Property Schema As Templates.Template
|
||||
|
||||
Public Property Account As Account
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -528,7 +528,7 @@ Namespace Winline
|
||||
Return Nothing
|
||||
End Function
|
||||
|
||||
Public Function GetDocuments(pMandator As Mandator, pTemplate As Template, pDocumentType As Integer, pOptions As GetDocumentArgs) As List(Of Document)
|
||||
Public Function GetDocuments(pMandator As Mandator, pTemplate As Template, pDocumentType As Integer, pOptions As GetDocumentArgs) As List(Of ExportDocument)
|
||||
Try
|
||||
Dim oYear As Integer = Config.GetWinLineYear()
|
||||
|
||||
@@ -615,7 +615,7 @@ Namespace Winline
|
||||
{oDateToConstraint}
|
||||
T.[mesocomp] = '{pMandator.Id}' AND T.[mesoyear] = {oYear}"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||
Dim oDocuments As New List(Of Document)
|
||||
Dim oDocuments As New List(Of ExportDocument)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Try
|
||||
@@ -639,7 +639,7 @@ Namespace Winline
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Async Function ExecuteFinalSQL(pDocument As Document, pTemplate As Template, pMandator As Mandator) As Task(Of Boolean)
|
||||
Public Async Function ExecuteFinalSQL(pDocument As ExportDocument, pTemplate As Template, pMandator As Mandator) As Task(Of Boolean)
|
||||
Try
|
||||
Dim oSql As String = Patterns.ReplaceForExport(pTemplate, pDocument, pMandator, pTemplate.FinalSQL)
|
||||
Return Await Database.ExecuteNonQueryAsync(oSql)
|
||||
@@ -650,7 +650,7 @@ Namespace Winline
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetDocumentFromDataRow(pDataRow As DataRow) As Document
|
||||
Private Function GetDocumentFromDataRow(pDataRow As DataRow) As ExportDocument
|
||||
Dim oAccountNumber = pDataRow.Item("ACCOUNT_NUMBER")
|
||||
Dim oRunningNumber As String = pDataRow.Item("RUNNING_NUMBER")
|
||||
Dim oDocumentType As Integer = pDataRow.Item("DOCUMENT_TYPE")
|
||||
@@ -694,7 +694,7 @@ Namespace Winline
|
||||
|
||||
End Select
|
||||
|
||||
Dim oDocument As New Document With {
|
||||
Dim oDocument As New ExportDocument With {
|
||||
.Account = oAccount,
|
||||
.RunningNumber = oRunningNumber,
|
||||
.Number = oDocumentNumber,
|
||||
|
||||
Reference in New Issue
Block a user