diff --git a/MultiTool.Common/MultiTool.Common.vbproj b/MultiTool.Common/MultiTool.Common.vbproj index 89f9b23..336b965 100644 --- a/MultiTool.Common/MultiTool.Common.vbproj +++ b/MultiTool.Common/MultiTool.Common.vbproj @@ -131,6 +131,8 @@ + + diff --git a/MultiTool.Common/Templates/FilterConfig.vb b/MultiTool.Common/Templates/FilterConfig.vb new file mode 100644 index 0000000..f9ace79 --- /dev/null +++ b/MultiTool.Common/Templates/FilterConfig.vb @@ -0,0 +1,5 @@ +Namespace Templates + Public Class FilterConfig + Public Property Items As New List(Of FilterConfigItem) + End Class +End Namespace \ No newline at end of file diff --git a/MultiTool.Common/Templates/FilterConfigItem.vb b/MultiTool.Common/Templates/FilterConfigItem.vb new file mode 100644 index 0000000..b16f1f7 --- /dev/null +++ b/MultiTool.Common/Templates/FilterConfigItem.vb @@ -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 \ No newline at end of file diff --git a/MultiTool.Common/Templates/TemplateLoader.vb b/MultiTool.Common/Templates/TemplateLoader.vb index 97d6550..6df3f08 100644 --- a/MultiTool.Common/Templates/TemplateLoader.vb +++ b/MultiTool.Common/Templates/TemplateLoader.vb @@ -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) diff --git a/MultiTool.Common/Winline/WebServiceData.vb b/MultiTool.Common/Winline/WebServiceData.vb index 4170f4d..7aadc2c 100644 --- a/MultiTool.Common/Winline/WebServiceData.vb +++ b/MultiTool.Common/Winline/WebServiceData.vb @@ -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 diff --git a/MultiTool.Form/MyApplication.vb b/MultiTool.Form/MyApplication.vb index c3a4c70..8e76ded 100644 --- a/MultiTool.Form/MyApplication.vb +++ b/MultiTool.Form/MyApplication.vb @@ -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 diff --git a/MultiTool.Form/frmMain.vb b/MultiTool.Form/frmMain.vb index af18aa4..de2922a 100644 --- a/MultiTool.Form/frmMain.vb +++ b/MultiTool.Form/frmMain.vb @@ -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