Add logging for ApplyItemFiltersForExport, fix xpath bug
This commit is contained in:
parent
dc14c80d59
commit
73bc1517f3
@ -336,8 +336,6 @@ Namespace Winline
|
|||||||
Logger.Debug("Applying Item Functions")
|
Logger.Debug("Applying Item Functions")
|
||||||
oDoc = ApplyItemFunctionsForExport(pDocument, pTemplate, pMandator, oDoc)
|
oDoc = ApplyItemFunctionsForExport(pDocument, pTemplate, pMandator, oDoc)
|
||||||
|
|
||||||
'TODO: Load filters and apply
|
|
||||||
|
|
||||||
Dim oXml = ConvertDocumentToString(oDoc)
|
Dim oXml = ConvertDocumentToString(oDoc)
|
||||||
|
|
||||||
' Webservice
|
' Webservice
|
||||||
@ -444,14 +442,20 @@ Namespace Winline
|
|||||||
Where(Function(filter) oTableNames.Contains(filter.TableName)).
|
Where(Function(filter) oTableNames.Contains(filter.TableName)).
|
||||||
ToList()
|
ToList()
|
||||||
|
|
||||||
|
Logger.Info("Applying [{0}] filters before exporting.", oFilters.Count)
|
||||||
|
|
||||||
For Each oFilter As FilterConfigItem In oFilters
|
For Each oFilter As FilterConfigItem In oFilters
|
||||||
Dim oTableName = oFilter.TableName
|
Dim oTableName = oFilter.TableName
|
||||||
|
|
||||||
|
Logger.Debug("Applying filter for Table [{0}]", oTableName)
|
||||||
|
|
||||||
If String.IsNullOrEmpty(oFilter.SQLCommand) Then
|
If String.IsNullOrEmpty(oFilter.SQLCommand) Then
|
||||||
Logger.Warn("SQL Command for filter is empty. Continuing.")
|
Logger.Warn("SQL Command for filter is empty. Continuing.")
|
||||||
Continue For
|
Continue For
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
Logger.Debug("Executing SQL Command: [{0}]", oFilter.SQLCommand)
|
||||||
|
|
||||||
Dim oSQLResult = Database.GetDatatable(oFilter.SQLCommand)
|
Dim oSQLResult = Database.GetDatatable(oFilter.SQLCommand)
|
||||||
|
|
||||||
If oSQLResult Is Nothing Then
|
If oSQLResult Is Nothing Then
|
||||||
@ -460,18 +464,34 @@ Namespace Winline
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oResultList = oSQLResult.AsEnumerable.
|
Dim oResultList = oSQLResult.AsEnumerable.
|
||||||
Select(Of String)(Function(row) row.Item(0)).
|
Select(Function(row) row.ItemEx(0, String.Empty).Trim).
|
||||||
ToList()
|
ToList()
|
||||||
|
|
||||||
Dim oNodes = oXMLDocument.SelectNodes($"//{oTableName}")
|
Logger.Debug("Filterlist contains [{0}] items", oResultList.Count)
|
||||||
|
|
||||||
For Each oNode As XmlNode In oNodes
|
Dim oTableNodes = oXMLDocument.SelectNodes($"//{oTableName}")
|
||||||
Dim oSubNode = oNode.SelectSingleNode($"//{oFilter.ColumnName}")
|
|
||||||
|
|
||||||
If oSubNode IsNot Nothing AndAlso oResultList.Contains(oSubNode.InnerText) Then
|
Logger.Debug("Table contains [{0}] elements", oTableNodes.Count)
|
||||||
oNode.ParentNode.RemoveChild(oNode)
|
|
||||||
'oDoc.RemoveChild(oNode)
|
For Each oElementNode As XmlNode In oTableNodes
|
||||||
|
Dim oPath As String = $"./{oFilter.ColumnName}"
|
||||||
|
Dim oSubNode = oElementNode.SelectSingleNode(oPath)
|
||||||
|
|
||||||
|
If oSubNode Is Nothing Then
|
||||||
|
Logger.Warn("Column [{0}] was not found in element.", oFilter.ColumnName)
|
||||||
|
Continue For
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
Dim oNodeValue = oSubNode.InnerText.Trim
|
||||||
|
Logger.Debug("Element Value is [{0}]", oNodeValue)
|
||||||
|
|
||||||
|
If Not oResultList.Contains(oNodeValue) Then
|
||||||
|
Logger.Warn("Element for Column [{0}] was not found in filterlist.", oFilter.ColumnName)
|
||||||
|
Continue For
|
||||||
|
End If
|
||||||
|
|
||||||
|
Logger.Info("Removing node [{0}] containing value [{1}]", oPath, oNodeValue)
|
||||||
|
oElementNode.ParentNode.RemoveChild(oElementNode)
|
||||||
Next
|
Next
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user