WIP: Filters

This commit is contained in:
Jonathan Jenne 2022-06-28 16:25:39 +02:00
parent 42b1ca72a6
commit 10565fb1da
7 changed files with 64 additions and 0 deletions

View File

@ -131,6 +131,8 @@
<Compile Include="Parameters.vb" />
<Compile Include="Patterns.vb" />
<Compile Include="Report\ReportGenerator.vb" />
<Compile Include="Templates\FilterConfig.vb" />
<Compile Include="Templates\FilterConfigItem.vb" />
<Compile Include="Templates\GeneralConfig.vb" />
<Compile Include="Templates\MandatorConfig.vb" />
<Compile Include="Templates\MandatorConfigItem.vb" />

View File

@ -0,0 +1,5 @@
Namespace Templates
Public Class FilterConfig
Public Property Items As New List(Of FilterConfigItem)
End Class
End Namespace

View File

@ -0,0 +1,8 @@
Namespace Templates
Public Class FilterConfigItem
Public Property Guid As Integer
Public Property SQLCommand As String
Public Property TableId As Integer
Public Property ColumnName As String
End Class
End Namespace

View File

@ -10,11 +10,14 @@ Namespace Templates
Private ReadOnly ns As XNamespace = "http://www.w3.org/2001/XMLSchema"
Public Property TemplateList As List(Of Template)
Public Property TemplateConfiguration As New TemplateConfig
Public Property MappingConfiguration As New MappingConfig
Public Property MandatorConfiguration As New MandatorConfig
Public Property GeneralConfiguration As New GeneralConfig
Public Property FilterConfiguration As New FilterConfig
Private Const SQL_TBMT_FILTERS = "SELECT * FROM [DD_ECM].[dbo].[TBMT_FILTERS]"
Private Const SQL_VWMT_ITEMS = "SELECT * FROM [DD_ECM].[dbo].[VWMT_ITEMS]"
Private Const SQL_VWMT_MAPPING = "SELECT * FROM [DD_ECM].[dbo].[VWMT_MAPPING]"
Private Const SQL_TBMT_MANDATORS = "SELECT * FROM [DD_ECM].[dbo].[TBMT_MANDATORS] ORDER BY ORDER_KEY"
@ -25,6 +28,32 @@ Namespace Templates
MyBase.New(pLogConfig, pMSSQL)
End Sub
Public Async Function LoadFilterConfiguration() As Task(Of Boolean)
Try
Dim oTable As DataTable = Await Database.GetDatatableAsync(SQL_TBMT_FILTERS)
Dim oFilters As New List(Of FilterConfigItem)
For Each oRow As DataRow In oTable.Rows
Dim oFilter As New FilterConfigItem With {
.Guid = oRow.Item("GUID"),
.SQLCommand = oRow.ItemEx("SQL_COMMAND", String.Empty),
.TableId = oRow.ItemEx("TABLE_ID", 0),
.ColumnName = oRow.ItemEx("COLUMN_NAME", String.Empty)
}
oFilters.Add(oFilter)
Next
FilterConfiguration.Items = oFilters
Return True
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
Public Async Function LoadTemplates() As Task(Of Boolean)
Try
Dim oTable As DataTable = Await Database.GetDatatableAsync(SQL_TBMT_TEMPLATES)

View File

@ -414,6 +414,23 @@ Namespace Winline
oResponseBody = oXml
Return oResponseBody
End Function
Private Function ApplyItemFiltersForExport(pDocument As Entities.ExportDocument, pTemplate As Template, pMandator As Mandator, oResponseBody As String) As String
Dim oDoc As New XmlDocument()
oDoc.LoadXml(oResponseBody)
'TODO: Load filters and apply
Dim oArray As Byte()
Using oStream As New IO.MemoryStream
oDoc.Save(oStream)
oArray = oStream.ToArray()
End Using
Dim oXml = Text.Encoding.UTF8.GetString(oArray)
oResponseBody = oXml
Return oResponseBody
End Function
#End Region

View File

@ -9,6 +9,7 @@ Namespace My
Friend Property MappingConfiguration As MappingConfig
Friend Property MandatorConfiguration As MandatorConfig
Friend Property GeneralConfiguration As GeneralConfig
Friend Property FilterConfiguration As FilterConfig
Friend Property Winline As WinlineData
End Module
End Namespace

View File

@ -114,12 +114,14 @@ Public Class frmMain
Await TemplateLoader.LoadGeneralConfiguration()
Await TemplateLoader.LoadMappingConfiguration()
Await TemplateLoader.LoadMandatorConfiguration()
Await TemplateLoader.LoadFilterConfiguration()
' Save Schema data in 'My' Namespace
My.MappingConfiguration = TemplateLoader.MappingConfiguration
My.TemplateConfiguration = TemplateLoader.TemplateConfiguration
My.MandatorConfiguration = TemplateLoader.MandatorConfiguration
My.GeneralConfiguration = TemplateLoader.GeneralConfiguration
My.FilterConfiguration = TemplateLoader.FilterConfiguration
Dim oBindingSource = New BindingList(Of Template)
For Each oTemplate As Template In TemplateLoader.TemplateList