Add Template Selection, load templates from Database

This commit is contained in:
Jonathan Jenne 2021-11-18 14:56:29 +01:00
parent 15b553efc3
commit 0356699473
21 changed files with 395 additions and 200 deletions

View File

@ -315,6 +315,7 @@
<ItemGroup> <ItemGroup>
<Content Include="CREATE_DATABASE.sql" /> <Content Include="CREATE_DATABASE.sql" />
<Content Include="MultiTool.ico" /> <Content Include="MultiTool.ico" />
<None Include="Resources\actions_checkcircled1.svg" />
<None Include="Resources\followupall.svg" /> <None Include="Resources\followupall.svg" />
<None Include="Resources\actions_send2.svg" /> <None Include="Resources\actions_send2.svg" />
<None Include="Resources\bo_product.svg" /> <None Include="Resources\bo_product.svg" />

View File

@ -32,7 +32,7 @@ Namespace My
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _ <Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Protected Overrides Sub OnCreateMainForm() Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.MultiTool.Form.frmImportMain Me.MainForm = Global.MultiTool.Form.frmMain
End Sub End Sub
End Class End Class
End Namespace End Namespace

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MySubMain>true</MySubMain> <MySubMain>true</MySubMain>
<MainForm>frmImportMain</MainForm> <MainForm>frmMain</MainForm>
<SingleInstance>false</SingleInstance> <SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode> <ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles> <EnableVisualStyles>true</EnableVisualStyles>

View File

@ -90,6 +90,16 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage.
'''</summary>
Friend ReadOnly Property actions_checkcircled1() As DevExpress.Utils.Svg.SvgImage
Get
Dim obj As Object = ResourceManager.GetObject("actions_checkcircled1", resourceCulture)
Return CType(obj,DevExpress.Utils.Svg.SvgImage)
End Get
End Property
'''<summary> '''<summary>
''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage. ''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage.
'''</summary> '''</summary>

View File

@ -121,6 +121,9 @@
<data name="logical" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="logical" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logical.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\logical.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
<data name="bo_country" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bo_country.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="redo" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="redo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\redo.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\redo.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
@ -163,9 +166,6 @@
<data name="paymentrefund" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="paymentrefund" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\paymentrefund.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\paymentrefund.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
<data name="actions_deletecircled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_deletecircled.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="open1" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="open1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\open1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\open1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
@ -199,8 +199,8 @@
<data name="rotatecounterclockwise" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="rotatecounterclockwise" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\rotatecounterclockwise.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\rotatecounterclockwise.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
<data name="bo_country" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="actions_deletecircled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bo_country.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\actions_deletecircled.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
<data name="actions_arrow4down" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="actions_arrow4down" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_arrow4down.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\actions_arrow4down.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
@ -211,6 +211,9 @@
<data name="actions_send1" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="actions_send1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_send1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\actions_send1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
<data name="followupall" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\followupall.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="actions_send" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="actions_send" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_send.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\actions_send.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
@ -235,7 +238,7 @@
<data name="itemtypechecked" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="itemtypechecked" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\itemtypechecked.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\itemtypechecked.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
<data name="followupall" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="actions_checkcircled1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\followupall.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value> <value>..\Resources\actions_checkcircled1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data> </data>
</root> </root>

View File

@ -0,0 +1,15 @@
<?xml version='1.0' encoding='UTF-8'?>
<svg x="0px" y="0px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" id="Layer_1" style="enable-background:new 0 0 32 32">
<style type="text/css">
.Blue{fill:#1177D7;}
.Yellow{fill:#FFB115;}
.Black{fill:#727272;}
.Green{fill:#039C23;}
.Red{fill:#D11C1C;}
.st0{opacity:0.75;}
.st1{opacity:0.5;}
</style>
<g id="CheckCircled">
<path d="M16,4C9.4,4,4,9.4,4,16c0,6.6,5.4,12,12,12s12-5.4,12-12C28,9.4,22.6,4,16,4z M14,22l-6-6l2-2l4,4l8-8l2,2 L14,22z" class="Green" />
</g>
</svg>

View File

@ -64,6 +64,24 @@ Namespace My.Resources
End Set End Set
End Property End Property
'''<summary>
''' Sucht eine lokalisierte Zeichenfolge, die {0} - WebService Multitool für WinLine ähnelt.
'''</summary>
Friend Shared ReadOnly Property _0____WebService_Multitool_für_WinLine() As String
Get
Return ResourceManager.GetString("{0} - WebService Multitool für WinLine", resourceCulture)
End Get
End Property
'''<summary>
''' Sucht eine lokalisierte Zeichenfolge, die Auswahl der Vorlage ähnelt.
'''</summary>
Friend Shared ReadOnly Property Auswahl_der_Vorlage() As String
Get
Return ResourceManager.GetString("Auswahl der Vorlage", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Sucht eine lokalisierte Zeichenfolge, die In der Funktion &apos;{0}&apos; ist folgender Fehler aufgetreten: {1} ähnelt. ''' Sucht eine lokalisierte Zeichenfolge, die In der Funktion &apos;{0}&apos; ist folgender Fehler aufgetreten: {1} ähnelt.
'''</summary> '''</summary>

View File

@ -117,7 +117,13 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="Auswahl der Vorlage" xml:space="preserve">
<value>Auswahl der Vorlage</value>
</data>
<data name="In der Funktion '{0}' ist folgender Fehler aufgetreten: {1}" xml:space="preserve"> <data name="In der Funktion '{0}' ist folgender Fehler aufgetreten: {1}" xml:space="preserve">
<value>In der Funktion '{0}' ist folgender Fehler aufgetreten: {1}</value> <value>In der Funktion '{0}' ist folgender Fehler aufgetreten: {1}</value>
</data> </data>
<data name="{0} - WebService Multitool für WinLine" xml:space="preserve">
<value>{0} - WebService Multitool für WinLine</value>
</data>
</root> </root>

View File

@ -343,6 +343,7 @@ Partial Class frmImportMain
Me.txtCulture.Id = 26 Me.txtCulture.Id = 26
Me.txtCulture.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.followupall Me.txtCulture.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.followupall
Me.txtCulture.Name = "txtCulture" Me.txtCulture.Name = "txtCulture"
Me.txtCulture.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph
Me.txtCulture.Tag = "Culture: {0}" Me.txtCulture.Tag = "Culture: {0}"
' '
'btnRemoveRow 'btnRemoveRow

View File

@ -303,7 +303,7 @@
</value> </value>
</data> </data>
<data name="$this.Text" xml:space="preserve"> <data name="$this.Text" xml:space="preserve">
<value>WebService Multitool für WinLine</value> <value>{0} - WebService Multitool für WinLine</value>
</data> </data>
<data name="&gt;&gt;GridViewFiles.Name" xml:space="preserve"> <data name="&gt;&gt;GridViewFiles.Name" xml:space="preserve">
<value>GridViewFiles</value> <value>GridViewFiles</value>

View File

@ -1,11 +1,9 @@
Imports System.ComponentModel Imports System.IO
Imports System.IO
Imports System.Net.Http Imports System.Net.Http
Imports System.Xml Imports System.Xml
Imports DevExpress.Utils.Behaviors.Common Imports DevExpress.Utils.Behaviors.Common
Imports DevExpress.XtraGrid Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.Controls.SQLConfig
Imports DigitalData.GUIs.Common Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Config Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
@ -18,31 +16,36 @@ Imports MultiTool.Shared.Constants
Imports MultiTool.Shared.Exceptions Imports MultiTool.Shared.Exceptions
Imports DevExpress.XtraReports.UI Imports DevExpress.XtraReports.UI
Imports MultiTool.Shared.Documents.DocumentRow Imports MultiTool.Shared.Documents.DocumentRow
Imports DevExpress.XtraGrid.Columns
Public Class frmImportMain Public Class frmImportMain
Private LogConfig As LogConfig Public LogConfig As LogConfig
Public ConfigManager As ConfigManager(Of Config)
Private Logger As Logger Private Logger As Logger
Private ConfigManager As ConfigManager(Of Config)
Private Database As MSSQLServer Private Database As MSSQLServer
Private Winline As WinlineData Private Winline As WinlineData
Private FileEx As DigitalData.Modules.Filesystem.File Private FileEx As DigitalData.Modules.Filesystem.File
Private WebService As WebService Private WebService As WebService
Private DocumentLoader As DocumentLoader Private DocumentLoader As DocumentLoader
Private SchemaLoader As SchemaLoader
Private FormHelper As FormHelper Private FormHelper As FormHelper
Private Grids As List(Of GridControl) Private Grids As List(Of GridControl)
Private GridLoader As GridLoader Private GridLoader As GridLoader
Private GridBuilder As GridBuilder Private GridBuilder As GridBuilder
Private CurrentSchemaName As String = Nothing Private ReadOnly CurrentSchema As Schema = Nothing
Private CurrentSchema As Schema = Nothing
' Runtime variables
Private CurrentGrid As GridControl = Nothing Private CurrentGrid As GridControl = Nothing
Private CurrentDocument As Document = Nothing Private CurrentDocument As Document = Nothing
Public Sub New() Public Sub New(pLogConfig As LogConfig, pConfigManager As ConfigManager(Of Config), pSchema As Schema)
InitializeComponent() InitializeComponent()
LogConfig = pLogConfig
ConfigManager = pConfigManager
CurrentSchema = pSchema
BehaviorManager.Attach(Of PersistenceBehavior)(Me, AddressOf LoadPersistenceSettings) BehaviorManager.Attach(Of PersistenceBehavior)(Me, AddressOf LoadPersistenceSettings)
End Sub End Sub
@ -59,42 +62,18 @@ Public Class frmImportMain
Private Sub frmImportMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub frmImportMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try Try
txtVersion.Caption = String.Format(txtVersion.Caption, Application.ProductVersion)
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, Application.CompanyName, Application.ProductName)
Logger = LogConfig.GetLogger() Logger = LogConfig.GetLogger()
Logger.Info("Starting {0}, Version [{1}]", Application.ProductName, Application.ProductVersion)
ConfigManager = New ConfigManager(Of Config)(LogConfig,
Application.UserAppDataPath,
Application.CommonAppDataPath,
Application.StartupPath
)
FormHelper = New FormHelper(LogConfig) FormHelper = New FormHelper(LogConfig)
GridBuilder = New GridBuilder(GridViewFiles)
GridBuilder.WithDefaults.WithClipboardHandler()
GridViewFiles.OptionsView.ShowAutoFilterRow = False
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
' If ConnectionString does not exist, show SQL Config Form
If ConfigManager.Config.ConnectionString = String.Empty Then
Dim oForm As New frmSQLConfig(LogConfig) With {
.FormTitle = Application.ProductName
}
Dim oResult = oForm.ShowDialog()
If oResult = DialogResult.OK Then
ConfigManager.Config.ConnectionString = oForm.ConnectionString
ConfigManager.Save()
End If
End If
' Initialize Database ' Initialize Database
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString) Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
Database = New MSSQLServer(LogConfig, oConnectionString) Database = New MSSQLServer(LogConfig, oConnectionString)
GridBuilder = New GridBuilder(GridViewFiles)
GridBuilder.WithDefaults.WithReadOnlyOptions.WithClipboardHandler()
GridViewFiles.OptionsView.ShowAutoFilterRow = False
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
Winline = New WinlineData(LogConfig, Database, ConfigManager.Config) Winline = New WinlineData(LogConfig, Database, ConfigManager.Config)
WebService = New WebService(LogConfig, ConfigManager.Config, Application.UserAppDataPath) WebService = New WebService(LogConfig, ConfigManager.Config, Application.UserAppDataPath)
AddHandler WebService.WebServiceProgress, AddressOf WebService_Progress AddHandler WebService.WebServiceProgress, AddressOf WebService_Progress
@ -106,6 +85,7 @@ Public Class frmImportMain
txtVersion.Caption = String.Format(My.Resources.frmImportMainExtra.Version__0_, My.Application.Info.Version.ToString) txtVersion.Caption = String.Format(My.Resources.frmImportMainExtra.Version__0_, My.Application.Info.Version.ToString)
txtCulture.Caption = String.Format(My.Resources.frmImportMainExtra.Culture___0_, My.Application.UICulture.ToString) txtCulture.Caption = String.Format(My.Resources.frmImportMainExtra.Culture___0_, My.Application.UICulture.ToString)
Text = String.Format(My.Resources.frmShared._0____WebService_Multitool_für_WinLine, CurrentSchema.Name)
End Sub End Sub
Private Async Sub frmImportMain_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown Private Async Sub frmImportMain_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
@ -119,13 +99,6 @@ Public Class frmImportMain
Winline.LoadEconomicYears() Winline.LoadEconomicYears()
Await Winline.LoadMandators() Await Winline.LoadMandators()
' TODO: Comment in when we finally use the database for additional configuration
SplashScreenManager.SetWaitFormDescription("Lade Schema Informationen")
If Await Winline.LoadTemplateConfiguration() = False Then
Logger.Warn("Template Configuration was not loaded!")
Winline.TemplateConfiguration = Nothing
End If
For Each oMandator As Mandator In Winline.Mandators For Each oMandator As Mandator In Winline.Mandators
SplashScreenManager.SetWaitFormDescription(String.Format(My.Resources.frmImportMainExtra.Lade__0__Konten, oMandator.Id)) SplashScreenManager.SetWaitFormDescription(String.Format(My.Resources.frmImportMainExtra.Lade__0__Konten, oMandator.Id))
Await Winline.LoadAccounts(oMandator) Await Winline.LoadAccounts(oMandator)
@ -142,18 +115,14 @@ Public Class frmImportMain
lookupMandator.Properties.View.BestFitColumns() lookupMandator.Properties.View.BestFitColumns()
DocumentLoader = New DocumentLoader(LogConfig, Winline) DocumentLoader = New DocumentLoader(LogConfig, Winline)
SchemaLoader = New SchemaLoader(LogConfig)
GridLoader = New GridLoader(LogConfig) GridLoader = New GridLoader(LogConfig)
SplashScreenManager.SetWaitFormDescription(My.Resources.frmImportMainExtra.Lade_Vorlagen) SplashScreenManager.SetWaitFormDescription(My.Resources.frmImportMainExtra.Lade_Vorlagen)
SchemaLoader.LoadFiles(ConfigManager.Config.SchemaDirectory) 'SchemaLoader.LoadFiles(ConfigManager.Config.SchemaDirectory)
CurrentSchemaName = SchemaLoader.SchemaList.First().FullName 'CurrentSchemaName = SchemaLoader.SchemaList.First().FullName
'CurrentSchema = SchemaLoader.GetSchemaFromFile(CurrentSchemaName)
CurrentSchema = SchemaLoader.GetSchemaFromFile(CurrentSchemaName) 'CurrentSchema = SchemaLoader.UpdateSchemaWithDatabaseConfiguration(CurrentSchema, SchemaLoader.TemplateConfiguration)
CurrentSchema = SchemaLoader.UpdateSchemaWithDatabaseConfiguration(CurrentSchema, Winline.TemplateConfiguration)
Grids = CreateGridsAndColumns(CurrentSchema) Grids = CreateGridsAndColumns(CurrentSchema)

View File

@ -1,6 +1,6 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain Partial Class frmMain
Inherits DevExpress.XtraEditors.XtraForm Inherits DevExpress.XtraBars.Ribbon.RibbonForm
'Form overrides dispose to clean up the component list. 'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _ <System.Diagnostics.DebuggerNonUserCode()> _
@ -19,75 +19,143 @@ Partial Class frmMain
'Do not modify it using the code editor. 'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _ <System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent() Private Sub InitializeComponent()
Me.LabelControl1 = New DevExpress.XtraEditors.LabelControl() Me.components = New System.ComponentModel.Container()
Me.LabelControl2 = New DevExpress.XtraEditors.LabelControl() Me.RibbonControl1 = New DevExpress.XtraBars.Ribbon.RibbonControl()
Me.ListBoxControl1 = New DevExpress.XtraEditors.ListBoxControl() Me.BarButtonItem1 = New DevExpress.XtraBars.BarButtonItem()
Me.ListBoxControl2 = New DevExpress.XtraEditors.ListBoxControl() Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.SimpleButton1 = New DevExpress.XtraEditors.SimpleButton() Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
CType(Me.ListBoxControl1, System.ComponentModel.ISupportInitialize).BeginInit() Me.RibbonStatusBar1 = New DevExpress.XtraBars.Ribbon.RibbonStatusBar()
CType(Me.ListBoxControl2, System.ComponentModel.ISupportInitialize).BeginInit() Me.RibbonPage2 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.SvgImageCollection1 = New DevExpress.Utils.SvgImageCollection(Me.components)
Me.GridControl1 = New DevExpress.XtraGrid.GridControl()
Me.GridViewTemplates = New DevExpress.XtraGrid.Views.Grid.GridView()
Me.colName = New DevExpress.XtraGrid.Columns.GridColumn()
Me.colDescription = New DevExpress.XtraGrid.Columns.GridColumn()
Me.colFileName = New DevExpress.XtraGrid.Columns.GridColumn()
CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.SvgImageCollection1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.GridViewTemplates, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout() Me.SuspendLayout()
' '
'LabelControl1 'RibbonControl1
' '
Me.LabelControl1.Location = New System.Drawing.Point(41, 43) Me.RibbonControl1.ExpandCollapseItem.Id = 0
Me.LabelControl1.Name = "LabelControl1" Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.BarButtonItem1})
Me.LabelControl1.Size = New System.Drawing.Size(32, 13) Me.RibbonControl1.Location = New System.Drawing.Point(0, 0)
Me.LabelControl1.TabIndex = 0 Me.RibbonControl1.MaxItemId = 2
Me.LabelControl1.Text = "Import" Me.RibbonControl1.Name = "RibbonControl1"
Me.RibbonControl1.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1})
Me.RibbonControl1.Size = New System.Drawing.Size(757, 158)
Me.RibbonControl1.StatusBar = Me.RibbonStatusBar1
' '
'LabelControl2 'BarButtonItem1
' '
Me.LabelControl2.Location = New System.Drawing.Point(41, 239) Me.BarButtonItem1.Caption = "Vorlage verwenden"
Me.LabelControl2.Name = "LabelControl2" Me.BarButtonItem1.Id = 1
Me.LabelControl2.Size = New System.Drawing.Size(32, 13) Me.BarButtonItem1.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.actions_checkcircled1
Me.LabelControl2.TabIndex = 1 Me.BarButtonItem1.Name = "BarButtonItem1"
Me.LabelControl2.Text = "Export"
' '
'ListBoxControl1 'RibbonPage1
' '
Me.ListBoxControl1.Location = New System.Drawing.Point(41, 62) Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup1})
Me.ListBoxControl1.Name = "ListBoxControl1" Me.RibbonPage1.Name = "RibbonPage1"
Me.ListBoxControl1.Size = New System.Drawing.Size(600, 126) Me.RibbonPage1.Text = "RibbonPage1"
Me.ListBoxControl1.TabIndex = 2
' '
'ListBoxControl2 'RibbonPageGroup1
' '
Me.ListBoxControl2.Location = New System.Drawing.Point(41, 258) Me.RibbonPageGroup1.ItemLinks.Add(Me.BarButtonItem1)
Me.ListBoxControl2.Name = "ListBoxControl2" Me.RibbonPageGroup1.Name = "RibbonPageGroup1"
Me.ListBoxControl2.Size = New System.Drawing.Size(600, 126) Me.RibbonPageGroup1.Text = "RibbonPageGroup1"
Me.ListBoxControl2.TabIndex = 2
' '
'SimpleButton1 'RibbonStatusBar1
' '
Me.SimpleButton1.Location = New System.Drawing.Point(608, 481) Me.RibbonStatusBar1.Location = New System.Drawing.Point(0, 513)
Me.SimpleButton1.Name = "SimpleButton1" Me.RibbonStatusBar1.Name = "RibbonStatusBar1"
Me.SimpleButton1.Size = New System.Drawing.Size(137, 44) Me.RibbonStatusBar1.Ribbon = Me.RibbonControl1
Me.SimpleButton1.TabIndex = 3 Me.RibbonStatusBar1.Size = New System.Drawing.Size(757, 24)
Me.SimpleButton1.Text = "SimpleButton1" '
'RibbonPage2
'
Me.RibbonPage2.Name = "RibbonPage2"
Me.RibbonPage2.Text = "RibbonPage2"
'
'SvgImageCollection1
'
Me.SvgImageCollection1.Add("import", "image://svgimages/scheduling/import.svg")
Me.SvgImageCollection1.Add("export", "image://svgimages/export/export.svg")
'
'GridControl1
'
Me.GridControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.GridControl1.Location = New System.Drawing.Point(0, 158)
Me.GridControl1.MainView = Me.GridViewTemplates
Me.GridControl1.MenuManager = Me.RibbonControl1
Me.GridControl1.Name = "GridControl1"
Me.GridControl1.Size = New System.Drawing.Size(757, 355)
Me.GridControl1.TabIndex = 9
Me.GridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridViewTemplates})
'
'GridView1
'
Me.GridViewTemplates.Columns.AddRange(New DevExpress.XtraGrid.Columns.GridColumn() {Me.colName, Me.colDescription, Me.colFileName})
Me.GridViewTemplates.GridControl = Me.GridControl1
Me.GridViewTemplates.Name = "GridView1"
'
'colName
'
Me.colName.Caption = "Name"
Me.colName.FieldName = "Name"
Me.colName.Name = "colName"
Me.colName.Visible = True
Me.colName.VisibleIndex = 0
'
'colDescription
'
Me.colDescription.Caption = "Beschreibung"
Me.colDescription.FieldName = "Description"
Me.colDescription.Name = "colDescription"
Me.colDescription.Visible = True
Me.colDescription.VisibleIndex = 1
'
'colFileName
'
Me.colFileName.Caption = "Dateiname"
Me.colFileName.FieldName = "FileName"
Me.colFileName.Name = "colFileName"
Me.colFileName.Visible = True
Me.colFileName.VisibleIndex = 2
' '
'frmMain 'frmMain
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(757, 537) Me.ClientSize = New System.Drawing.Size(757, 537)
Me.Controls.Add(Me.SimpleButton1) Me.Controls.Add(Me.GridControl1)
Me.Controls.Add(Me.ListBoxControl2) Me.Controls.Add(Me.RibbonStatusBar1)
Me.Controls.Add(Me.ListBoxControl1) Me.Controls.Add(Me.RibbonControl1)
Me.Controls.Add(Me.LabelControl2)
Me.Controls.Add(Me.LabelControl1)
Me.Name = "frmMain" Me.Name = "frmMain"
Me.Ribbon = Me.RibbonControl1
Me.StatusBar = Me.RibbonStatusBar1
Me.Text = "frmMain" Me.Text = "frmMain"
CType(Me.ListBoxControl1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.ListBoxControl2, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.SvgImageCollection1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.GridViewTemplates, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False) Me.ResumeLayout(False)
Me.PerformLayout() Me.PerformLayout()
End Sub End Sub
Friend WithEvents RibbonControl1 As DevExpress.XtraBars.Ribbon.RibbonControl
Friend WithEvents LabelControl1 As DevExpress.XtraEditors.LabelControl Friend WithEvents RibbonPage1 As DevExpress.XtraBars.Ribbon.RibbonPage
Friend WithEvents LabelControl2 As DevExpress.XtraEditors.LabelControl Friend WithEvents RibbonPageGroup1 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents ListBoxControl1 As DevExpress.XtraEditors.ListBoxControl Friend WithEvents RibbonStatusBar1 As DevExpress.XtraBars.Ribbon.RibbonStatusBar
Friend WithEvents ListBoxControl2 As DevExpress.XtraEditors.ListBoxControl Friend WithEvents RibbonPage2 As DevExpress.XtraBars.Ribbon.RibbonPage
Friend WithEvents SimpleButton1 As DevExpress.XtraEditors.SimpleButton Friend WithEvents BarButtonItem1 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents SvgImageCollection1 As DevExpress.Utils.SvgImageCollection
Friend WithEvents GridControl1 As DevExpress.XtraGrid.GridControl
Friend WithEvents GridViewTemplates As DevExpress.XtraGrid.Views.Grid.GridView
Friend WithEvents colName As DevExpress.XtraGrid.Columns.GridColumn
Friend WithEvents colDescription As DevExpress.XtraGrid.Columns.GridColumn
Friend WithEvents colFileName As DevExpress.XtraGrid.Columns.GridColumn
End Class End Class

View File

@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="SvgImageCollection1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>

View File

@ -1,3 +1,83 @@
Public Class frmMain Imports System.ComponentModel
Imports System.IO
Imports DigitalData.Controls.SQLConfig
Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports MultiTool.Shared.Schemas
Public Class frmMain
Private LogConfig As LogConfig
Private Logger As Logger
Private ConfigManager As ConfigManager(Of [Shared].Config)
Private Database As MSSQLServer
Private SchemaLoader As SchemaLoader
Private GridBuilder As GridBuilder
Private Async Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, Application.CompanyName, Application.ProductName)
Logger = LogConfig.GetLogger()
Logger.Info("Starting {0}, Version [{1}]", Application.ProductName, Application.ProductVersion)
Text = String.Format(My.Resources.frmShared._0____WebService_Multitool_für_WinLine, My.Resources.frmShared.Auswahl_der_Vorlage)
ConfigManager = New ConfigManager(Of [Shared].Config)(LogConfig,
Application.UserAppDataPath,
Application.CommonAppDataPath,
Application.StartupPath
)
GridBuilder = New GridBuilder(GridViewTemplates)
GridBuilder.WithDefaults.WithReadOnlyOptions.WithClipboardHandler()
GridViewTemplates.OptionsView.ShowAutoFilterRow = False
' If ConnectionString does not exist, show SQL Config Form
If ConfigManager.Config.ConnectionString = String.Empty Then
Dim oForm As New frmSQLConfig(LogConfig) With {
.FormTitle = Application.ProductName
}
Dim oResult = oForm.ShowDialog()
If oResult = DialogResult.OK Then
ConfigManager.Config.ConnectionString = oForm.ConnectionString
ConfigManager.Save()
End If
End If
' Initialize Database
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
Database = New MSSQLServer(LogConfig, oConnectionString)
' Initialize Schemas
SchemaLoader = New SchemaLoader(LogConfig, Database, ConfigManager.Config.SchemaDirectory)
Await SchemaLoader.LoadTemplates()
Await SchemaLoader.LoadTemplateConfiguration()
Dim oBindingSource = New BindingList(Of Schema)
For Each oSchema As Schema In SchemaLoader.SchemaList
oBindingSource.Add(oSchema)
Next
GridControl1.DataSource = oBindingSource
End Sub
Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick
Dim oSchema = GridViewTemplates.GetRow(GridViewTemplates.FocusedRowHandle)
If oSchema Is Nothing Then
MsgBox("Keine Vorlage ausgewählt! Bitte wählen Sie eine Vorlage aus!", MsgBoxStyle.Exclamation, Text)
Exit Sub
End If
oSchema = SchemaLoader.UpdateSchemaFromFile(oSchema, ConfigManager.Config.SchemaDirectory)
oSchema = SchemaLoader.UpdateSchemaFromDatabase(oSchema, SchemaLoader.TemplateConfiguration)
Dim oForm As New frmImportMain(LogConfig, ConfigManager, oSchema)
oForm.ShowDialog()
End Sub
Private Sub RibbonControl1_Click(sender As Object, e As EventArgs) Handles RibbonControl1.Click
End Sub
End Class End Class

View File

@ -0,0 +1,11 @@
Imports DigitalData.Modules.Language
Public Class Helpers
Public Shared Function GetRowItem(Of T)(pRow As DataRow, pFieldName As String, Optional pDefaultValue As T = Nothing) As T
Try
Return Utils.NotNull(pRow.Item(pFieldName), pDefaultValue)
Catch ex As Exception
Return Nothing
End Try
End Function
End Class

View File

@ -104,6 +104,7 @@
<Compile Include="Documents\DocumentType.vb" /> <Compile Include="Documents\DocumentType.vb" />
<Compile Include="Documents\DocumentLoader.vb" /> <Compile Include="Documents\DocumentLoader.vb" />
<Compile Include="Exceptions.vb" /> <Compile Include="Exceptions.vb" />
<Compile Include="Helpers.vb" />
<Compile Include="IDictionaryEx.vb" /> <Compile Include="IDictionaryEx.vb" />
<Compile Include="IEnumerableEx.vb" /> <Compile Include="IEnumerableEx.vb" />
<Compile Include="Mapper.vb" /> <Compile Include="Mapper.vb" />
@ -134,14 +135,14 @@
<Compile Include="Schemas\Schema.vb" /> <Compile Include="Schemas\Schema.vb" />
<Compile Include="Schemas\SchemaLoader.vb" /> <Compile Include="Schemas\SchemaLoader.vb" />
<Compile Include="Serializer.vb" /> <Compile Include="Serializer.vb" />
<Compile Include="Winline\Configuration.vb" /> <Compile Include="Schemas\Configuration.vb" />
<Compile Include="Winline\Entities\Account.vb" /> <Compile Include="Winline\Entities\Account.vb" />
<Compile Include="Winline\WinlineData.vb" /> <Compile Include="Winline\WinlineData.vb" />
<Compile Include="Winline\Entities\Article.vb" /> <Compile Include="Winline\Entities\Article.vb" />
<Compile Include="Winline\Entities\Contact.vb" /> <Compile Include="Winline\Entities\Contact.vb" />
<Compile Include="Winline\Entities\DocumentKind.vb" /> <Compile Include="Winline\Entities\DocumentKind.vb" />
<Compile Include="Winline\Entities\Mandator.vb" /> <Compile Include="Winline\Entities\Mandator.vb" />
<Compile Include="Winline\Entities\ColumnConfig.vb" /> <Compile Include="Schemas\ColumnConfig.vb" />
<Compile Include="Winline\WebService.vb" /> <Compile Include="Winline\WebService.vb" />
<Compile Include="XmlData.vb" /> <Compile Include="XmlData.vb" />
</ItemGroup> </ItemGroup>

View File

@ -1,6 +1,6 @@
Imports MultiTool.Shared.Constants Imports MultiTool.Shared.Constants
Namespace Winline Namespace Schemas
Public Class ColumnConfig Public Class ColumnConfig
Public Property Name As String Public Property Name As String
Public Property Table As String Public Property Table As String

View File

@ -1,10 +1,12 @@
 
Namespace Winline Imports MultiTool.Shared.Winline
Namespace Schemas
''' <summary> ''' <summary>
''' Class for loading column/field config from database ''' Class for loading column/field config from database
''' </summary> ''' </summary>
Public Class Configuration Public Class Configuration
Public Columns As List(Of Winline.ColumnConfig) Public Columns As List(Of ColumnConfig)
Public Function GetColumn(pName As String) As ColumnConfig Public Function GetColumn(pName As String) As ColumnConfig
Return Columns. Return Columns.

View File

@ -1,9 +1,14 @@
Imports MultiTool.Shared.Winline Imports System.IO
Imports MultiTool.Shared.Winline
Namespace Schemas Namespace Schemas
Public Class Schema Public Class Schema
Public Property Tables As New List(Of Table)
Public Property Name As String Public Property Name As String
Public Property FileName As String
Public Property Description As String
Public Property IsImport As Boolean
Public Property Tables As New List(Of Table)
Class Table Class Table
Public Property Name As String Public Property Name As String

View File

@ -1,7 +1,8 @@
Imports System.IO Imports System.IO
Imports System.Xml Imports DigitalData.Modules.Database
Imports System.Xml.XPath
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports MultiTool.Shared.Winline
Imports MultiTool.Shared.Helpers
Namespace Schemas Namespace Schemas
Public Class SchemaLoader Public Class SchemaLoader
@ -9,42 +10,95 @@ Namespace Schemas
Private ReadOnly ns As XNamespace = "http://www.w3.org/2001/XMLSchema" Private ReadOnly ns As XNamespace = "http://www.w3.org/2001/XMLSchema"
Public SchemaList As List(Of FileInfo) Public SchemaList As List(Of Schema)
Public TemplateConfiguration As New Configuration
Public Sub New(pLogConfig As LogConfig) Private Database As MSSQLServer
Private InputDirectory As String
Private Const VWEDI_XML_ITEMS = "VWEDI_XML_ITEMS"
Public Sub New(pLogConfig As LogConfig, pMSSQL As MSSQLServer, pInputDirectory As String)
MyBase.New(pLogConfig, pLogConfig.GetLogger) MyBase.New(pLogConfig, pLogConfig.GetLogger)
Database = pMSSQL
InputDirectory = pInputDirectory
End Sub End Sub
Public Function LoadFiles(pSchemaDirectory) As Boolean Public Async Function LoadTemplates() As Task(Of Boolean)
If pSchemaDirectory = String.Empty Then
Throw New ArgumentNullException("SchemaDirectory")
End If
Logger.Info("Loading files from directory [{0}]", pSchemaDirectory)
Try Try
Dim oDirectory As New DirectoryInfo(pSchemaDirectory) Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[TBEDI_XML_TEMPLATES]"
Dim oFiles = oDirectory.GetFiles() Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
Dim oTemplates As New List(Of Schema)
Logger.Debug("Found [{0}] files in directory [{1}]", oFiles.Count, oDirectory) For Each oRow As DataRow In oTable.Rows
Dim oTemplate As New Schema With {
.Name = GetRowItem(oRow, "NAME", String.Empty),
.Description = GetRowItem(oRow, "DESCRIPTION", String.Empty),
.FileName = GetRowItem(oRow, "FILE_NAME", String.Empty),
.IsImport = GetRowItem(oRow, "IS_IMPORT", True)
}
SchemaList = oFiles.ToList() oTemplates.Add(oTemplate)
Next
SchemaList = oTemplates
Return True
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
Public Async Function LoadTemplateConfiguration() As Task(Of Boolean)
Try
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{VWEDI_XML_ITEMS}]"
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
Dim oItems As New List(Of ColumnConfig)
For Each oRow As DataRow In oTable.Rows
Dim oColumn As New ColumnConfig() With {
.Template = GetRowItem(oRow, "TEMPLATE_NAME", String.Empty),
.Table = GetRowItem(oRow, "XML_TABLE", String.Empty),
.Name = GetRowItem(oRow, "XML_ITEM", String.Empty),
.Type = ColumnConfig.ConvertType(GetRowItem(oRow, "DATA_TYPE", String.Empty)),
.OrderKey = GetRowItem(oRow, "ORDER_KEY", 0),
.IsReadOnly = GetRowItem(oRow, "IS_READ_ONLY", False),
.IsVisible = GetRowItem(oRow, "IS_VISIBLE", True),
.IsRequired = GetRowItem(oRow, "IS_REQUIRED", False),
.IsHead = GetRowItem(oRow, "IS_HEAD", True),
.[Function] = New ColumnConfig.ColumnFunction With {
.Id = GetRowItem(oRow, "FUNCTION_ID", 0),
.Name = GetRowItem(oRow, "FUNCTION_NAME", String.Empty),
.Params = GetRowItem(oRow, "FUNCTION_PARAMETERS", String.Empty)
}
}
oItems.Add(oColumn)
Next
TemplateConfiguration = New Configuration With {
.Columns = oItems
}
Return True Return True
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
Throw New IO.IOException($"Could not load files from directory {pSchemaDirectory}", ex) Return False
End Try End Try
End Function End Function
Public Function GetSchemaFromFile(pSchemaFilePath As String) As Schema Public Function UpdateSchemaFromFile(pSchema As Schema, pInputDirectory As String) As Schema
Dim oSchema As New Schema Dim oFullPath = Path.Combine(pInputDirectory, pSchema.FileName)
Dim oFileInfo As New FileInfo(pSchemaFilePath)
Dim oElements = GetSchemaElements(pSchemaFilePath)
oSchema.Name = oFileInfo.Name If Not IO.File.Exists(oFullPath) Then
Throw New FileNotFoundException(oFullPath)
End If
Dim oElements = GetSchemaElements(oFullPath)
For Each oElement In oElements For Each oElement In oElements
Dim oColumns = GetElementColumns(oElement) Dim oColumns = GetElementColumns(oElement)
@ -69,17 +123,17 @@ Namespace Schemas
oSchemaColumns.Add(oSchemaColumn) oSchemaColumns.Add(oSchemaColumn)
Next Next
oSchema.Tables.Add(New Schema.Table With { pSchema.Tables.Add(New Schema.Table With {
.Name = XmlData.GetElementAttribute(oElement, "name"), .Name = XmlData.GetElementAttribute(oElement, "name"),
.Columns = oSchemaColumns .Columns = oSchemaColumns
}) })
Next Next
Return oSchema Return pSchema
End Function End Function
Public Function UpdateSchemaWithDatabaseConfiguration(pSchema As Schema, pTemplateConfig As Winline.Configuration) As Schema Public Function UpdateSchemaFromDatabase(pSchema As Schema, pTemplateConfig As Configuration) As Schema
If pTemplateConfig Is Nothing Then If pTemplateConfig Is Nothing Then
Return pSchema Return pSchema
End If End If
@ -89,7 +143,7 @@ Namespace Schemas
Dim oConfig = pTemplateConfig.GetColumn(oColumn.Name) Dim oConfig = pTemplateConfig.GetColumn(oColumn.Name)
If oConfig Is Nothing Then If oConfig Is Nothing Then
oConfig = New Winline.ColumnConfig With { oConfig = New ColumnConfig With {
.IsRequired = oColumn.IsRequired, .IsRequired = oColumn.IsRequired,
.Name = oColumn.Name .Name = oColumn.Name
} }

View File

@ -1,6 +1,7 @@
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports MultiTool.Shared.Helpers
Imports System.Text.RegularExpressions Imports System.Text.RegularExpressions
Namespace Winline Namespace Winline
@ -16,12 +17,9 @@ Namespace Winline
Public DocumentKinds As New List(Of DocumentKind) Public DocumentKinds As New List(Of DocumentKind)
Public Years As List(Of Integer) Public Years As List(Of Integer)
Public TemplateConfiguration As New Configuration
Public Const ALL_MESOCOMP = "mesocomp" Public Const ALL_MESOCOMP = "mesocomp"
Public Const VWEDI_XML_ITEMS = "VWEDI_XML_ITEMS"
Public Const V21_ARTICLENUMBER = "c002" Public Const V21_ARTICLENUMBER = "c002"
Public Const V21_ARTICLEDESCRIPTION = "c003" Public Const V21_ARTICLEDESCRIPTION = "c003"
Public Const V21_MAINARTICLENUMBER = "c011" Public Const V21_MAINARTICLENUMBER = "c011"
@ -487,47 +485,6 @@ Namespace Winline
End If End If
End Function End Function
Public Async Function LoadTemplateConfiguration() As Task(Of Boolean)
Try
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[{VWEDI_XML_ITEMS}]"
Dim oTable As DataTable = Await Database.GetDatatableAsync(oSql)
Dim oItems As New List(Of ColumnConfig)
For Each oRow As DataRow In oTable.Rows
Dim oColumn As New ColumnConfig() With {
.Template = GetRowItem(oRow, "TEMPLATE_NAME", String.Empty),
.Table = GetRowItem(oRow, "XML_TABLE", String.Empty),
.Name = GetRowItem(oRow, "XML_ITEM", String.Empty),
.Type = ColumnConfig.ConvertType(GetRowItem(oRow, "DATA_TYPE", String.Empty)),
.OrderKey = GetRowItem(oRow, "ORDER_KEY", 0),
.IsReadOnly = GetRowItem(oRow, "IS_READ_ONLY", False),
.IsVisible = GetRowItem(oRow, "IS_VISIBLE", True),
.IsRequired = GetRowItem(oRow, "IS_REQUIRED", False),
.IsHead = GetRowItem(oRow, "IS_HEAD", True),
.[Function] = New ColumnConfig.ColumnFunction With {
.Id = GetRowItem(oRow, "FUNCTION_ID", 0),
.Name = GetRowItem(oRow, "FUNCTION_NAME", String.Empty),
.Params = GetRowItem(oRow, "FUNCTION_PARAMETERS", String.Empty)
}
}
oItems.Add(oColumn)
Next
Dim oColumns = oItems
TemplateConfiguration = New Configuration With {
.Columns = oColumns
}
Return True
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
''' <summary> ''' <summary>
''' Turns a database info like "SQLCWLDATEN on SERVER\INSTANCE" into a Tuple of two strings ''' Turns a database info like "SQLCWLDATEN on SERVER\INSTANCE" into a Tuple of two strings
''' </summary> ''' </summary>
@ -552,14 +509,5 @@ Namespace Winline
Split(oDelimiter, StringSplitOptions.None). Split(oDelimiter, StringSplitOptions.None).
ToList() ToList()
End Function End Function
Private Function GetRowItem(Of T)(pRow As DataRow, pFieldName As String, Optional pDefaultValue As T = Nothing) As T
Try
Return Utils.NotNull(pRow.Item(pFieldName), pDefaultValue)
Catch ex As Exception
Return Nothing
End Try
End Function
End Class End Class
End Namespace End Namespace