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>
<Content Include="CREATE_DATABASE.sql" />
<Content Include="MultiTool.ico" />
<None Include="Resources\actions_checkcircled1.svg" />
<None Include="Resources\followupall.svg" />
<None Include="Resources\actions_send2.svg" />
<None Include="Resources\bo_product.svg" />

View File

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

View File

@ -1,7 +1,7 @@
<?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">
<MySubMain>true</MySubMain>
<MainForm>frmImportMain</MainForm>
<MainForm>frmMain</MainForm>
<SingleInstance>false</SingleInstance>
<ShutdownMode>0</ShutdownMode>
<EnableVisualStyles>true</EnableVisualStyles>

View File

@ -90,6 +90,16 @@ Namespace My.Resources
End Get
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>
''' Sucht eine lokalisierte Ressource vom Typ DevExpress.Utils.Svg.SvgImage.
'''</summary>

View File

@ -121,6 +121,9 @@
<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>
</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">
<value>..\Resources\redo.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
@ -163,9 +166,6 @@
<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>
</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">
<value>..\Resources\open1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
@ -199,8 +199,8 @@
<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>
</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 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="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>
@ -211,6 +211,9 @@
<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>
</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">
<value>..\Resources\actions_send.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
@ -235,7 +238,7 @@
<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>
</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 name="actions_checkcircled1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\actions_checkcircled1.svg;DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
</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 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>
''' Sucht eine lokalisierte Zeichenfolge, die In der Funktion &apos;{0}&apos; ist folgender Fehler aufgetreten: {1} ähnelt.
'''</summary>

View File

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

View File

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

View File

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

View File

@ -1,11 +1,9 @@
Imports System.ComponentModel
Imports System.IO
Imports System.IO
Imports System.Net.Http
Imports System.Xml
Imports DevExpress.Utils.Behaviors.Common
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.Controls.SQLConfig
Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.Database
@ -18,31 +16,36 @@ Imports MultiTool.Shared.Constants
Imports MultiTool.Shared.Exceptions
Imports DevExpress.XtraReports.UI
Imports MultiTool.Shared.Documents.DocumentRow
Imports DevExpress.XtraGrid.Columns
Public Class frmImportMain
Private LogConfig As LogConfig
Public LogConfig As LogConfig
Public ConfigManager As ConfigManager(Of Config)
Private Logger As Logger
Private ConfigManager As ConfigManager(Of Config)
Private Database As MSSQLServer
Private Winline As WinlineData
Private FileEx As DigitalData.Modules.Filesystem.File
Private WebService As WebService
Private DocumentLoader As DocumentLoader
Private SchemaLoader As SchemaLoader
Private FormHelper As FormHelper
Private Grids As List(Of GridControl)
Private GridLoader As GridLoader
Private GridBuilder As GridBuilder
Private CurrentSchemaName As String = Nothing
Private CurrentSchema As Schema = Nothing
Private ReadOnly CurrentSchema As Schema = Nothing
' Runtime variables
Private CurrentGrid As GridControl = Nothing
Private CurrentDocument As Document = Nothing
Public Sub New()
Public Sub New(pLogConfig As LogConfig, pConfigManager As ConfigManager(Of Config), pSchema As Schema)
InitializeComponent()
LogConfig = pLogConfig
ConfigManager = pConfigManager
CurrentSchema = pSchema
BehaviorManager.Attach(Of PersistenceBehavior)(Me, AddressOf LoadPersistenceSettings)
End Sub
@ -59,42 +62,18 @@ Public Class frmImportMain
Private Sub frmImportMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
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.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)
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
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
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)
WebService = New WebService(LogConfig, ConfigManager.Config, Application.UserAppDataPath)
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)
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
Private Async Sub frmImportMain_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown
@ -119,13 +99,6 @@ Public Class frmImportMain
Winline.LoadEconomicYears()
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
SplashScreenManager.SetWaitFormDescription(String.Format(My.Resources.frmImportMainExtra.Lade__0__Konten, oMandator.Id))
Await Winline.LoadAccounts(oMandator)
@ -142,18 +115,14 @@ Public Class frmImportMain
lookupMandator.Properties.View.BestFitColumns()
DocumentLoader = New DocumentLoader(LogConfig, Winline)
SchemaLoader = New SchemaLoader(LogConfig)
GridLoader = New GridLoader(LogConfig)
SplashScreenManager.SetWaitFormDescription(My.Resources.frmImportMainExtra.Lade_Vorlagen)
SchemaLoader.LoadFiles(ConfigManager.Config.SchemaDirectory)
CurrentSchemaName = SchemaLoader.SchemaList.First().FullName
CurrentSchema = SchemaLoader.GetSchemaFromFile(CurrentSchemaName)
CurrentSchema = SchemaLoader.UpdateSchemaWithDatabaseConfiguration(CurrentSchema, Winline.TemplateConfiguration)
'SchemaLoader.LoadFiles(ConfigManager.Config.SchemaDirectory)
'CurrentSchemaName = SchemaLoader.SchemaList.First().FullName
'CurrentSchema = SchemaLoader.GetSchemaFromFile(CurrentSchemaName)
'CurrentSchema = SchemaLoader.UpdateSchemaWithDatabaseConfiguration(CurrentSchema, SchemaLoader.TemplateConfiguration)
Grids = CreateGridsAndColumns(CurrentSchema)

View File

@ -1,6 +1,6 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain
Inherits DevExpress.XtraEditors.XtraForm
Inherits DevExpress.XtraBars.Ribbon.RibbonForm
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
@ -19,75 +19,143 @@ Partial Class frmMain
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.LabelControl1 = New DevExpress.XtraEditors.LabelControl()
Me.LabelControl2 = New DevExpress.XtraEditors.LabelControl()
Me.ListBoxControl1 = New DevExpress.XtraEditors.ListBoxControl()
Me.ListBoxControl2 = New DevExpress.XtraEditors.ListBoxControl()
Me.SimpleButton1 = New DevExpress.XtraEditors.SimpleButton()
CType(Me.ListBoxControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.ListBoxControl2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.components = New System.ComponentModel.Container()
Me.RibbonControl1 = New DevExpress.XtraBars.Ribbon.RibbonControl()
Me.BarButtonItem1 = New DevExpress.XtraBars.BarButtonItem()
Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonStatusBar1 = New DevExpress.XtraBars.Ribbon.RibbonStatusBar()
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()
'
'LabelControl1
'RibbonControl1
'
Me.LabelControl1.Location = New System.Drawing.Point(41, 43)
Me.LabelControl1.Name = "LabelControl1"
Me.LabelControl1.Size = New System.Drawing.Size(32, 13)
Me.LabelControl1.TabIndex = 0
Me.LabelControl1.Text = "Import"
Me.RibbonControl1.ExpandCollapseItem.Id = 0
Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.BarButtonItem1})
Me.RibbonControl1.Location = New System.Drawing.Point(0, 0)
Me.RibbonControl1.MaxItemId = 2
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.LabelControl2.Name = "LabelControl2"
Me.LabelControl2.Size = New System.Drawing.Size(32, 13)
Me.LabelControl2.TabIndex = 1
Me.LabelControl2.Text = "Export"
Me.BarButtonItem1.Caption = "Vorlage verwenden"
Me.BarButtonItem1.Id = 1
Me.BarButtonItem1.ImageOptions.SvgImage = Global.MultiTool.Form.My.Resources.Resources.actions_checkcircled1
Me.BarButtonItem1.Name = "BarButtonItem1"
'
'ListBoxControl1
'RibbonPage1
'
Me.ListBoxControl1.Location = New System.Drawing.Point(41, 62)
Me.ListBoxControl1.Name = "ListBoxControl1"
Me.ListBoxControl1.Size = New System.Drawing.Size(600, 126)
Me.ListBoxControl1.TabIndex = 2
Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup1})
Me.RibbonPage1.Name = "RibbonPage1"
Me.RibbonPage1.Text = "RibbonPage1"
'
'ListBoxControl2
'RibbonPageGroup1
'
Me.ListBoxControl2.Location = New System.Drawing.Point(41, 258)
Me.ListBoxControl2.Name = "ListBoxControl2"
Me.ListBoxControl2.Size = New System.Drawing.Size(600, 126)
Me.ListBoxControl2.TabIndex = 2
Me.RibbonPageGroup1.ItemLinks.Add(Me.BarButtonItem1)
Me.RibbonPageGroup1.Name = "RibbonPageGroup1"
Me.RibbonPageGroup1.Text = "RibbonPageGroup1"
'
'SimpleButton1
'RibbonStatusBar1
'
Me.SimpleButton1.Location = New System.Drawing.Point(608, 481)
Me.SimpleButton1.Name = "SimpleButton1"
Me.SimpleButton1.Size = New System.Drawing.Size(137, 44)
Me.SimpleButton1.TabIndex = 3
Me.SimpleButton1.Text = "SimpleButton1"
Me.RibbonStatusBar1.Location = New System.Drawing.Point(0, 513)
Me.RibbonStatusBar1.Name = "RibbonStatusBar1"
Me.RibbonStatusBar1.Ribbon = Me.RibbonControl1
Me.RibbonStatusBar1.Size = New System.Drawing.Size(757, 24)
'
'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
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(757, 537)
Me.Controls.Add(Me.SimpleButton1)
Me.Controls.Add(Me.ListBoxControl2)
Me.Controls.Add(Me.ListBoxControl1)
Me.Controls.Add(Me.LabelControl2)
Me.Controls.Add(Me.LabelControl1)
Me.Controls.Add(Me.GridControl1)
Me.Controls.Add(Me.RibbonStatusBar1)
Me.Controls.Add(Me.RibbonControl1)
Me.Name = "frmMain"
Me.Ribbon = Me.RibbonControl1
Me.StatusBar = Me.RibbonStatusBar1
Me.Text = "frmMain"
CType(Me.ListBoxControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.ListBoxControl2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.RibbonControl1, 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.PerformLayout()
End Sub
Friend WithEvents LabelControl1 As DevExpress.XtraEditors.LabelControl
Friend WithEvents LabelControl2 As DevExpress.XtraEditors.LabelControl
Friend WithEvents ListBoxControl1 As DevExpress.XtraEditors.ListBoxControl
Friend WithEvents ListBoxControl2 As DevExpress.XtraEditors.ListBoxControl
Friend WithEvents SimpleButton1 As DevExpress.XtraEditors.SimpleButton
Friend WithEvents RibbonControl1 As DevExpress.XtraBars.Ribbon.RibbonControl
Friend WithEvents RibbonPage1 As DevExpress.XtraBars.Ribbon.RibbonPage
Friend WithEvents RibbonPageGroup1 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
Friend WithEvents RibbonStatusBar1 As DevExpress.XtraBars.Ribbon.RibbonStatusBar
Friend WithEvents RibbonPage2 As DevExpress.XtraBars.Ribbon.RibbonPage
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

View File

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</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>

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

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\DocumentLoader.vb" />
<Compile Include="Exceptions.vb" />
<Compile Include="Helpers.vb" />
<Compile Include="IDictionaryEx.vb" />
<Compile Include="IEnumerableEx.vb" />
<Compile Include="Mapper.vb" />
@ -134,14 +135,14 @@
<Compile Include="Schemas\Schema.vb" />
<Compile Include="Schemas\SchemaLoader.vb" />
<Compile Include="Serializer.vb" />
<Compile Include="Winline\Configuration.vb" />
<Compile Include="Schemas\Configuration.vb" />
<Compile Include="Winline\Entities\Account.vb" />
<Compile Include="Winline\WinlineData.vb" />
<Compile Include="Winline\Entities\Article.vb" />
<Compile Include="Winline\Entities\Contact.vb" />
<Compile Include="Winline\Entities\DocumentKind.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="XmlData.vb" />
</ItemGroup>

View File

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

View File

@ -1,10 +1,12 @@

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

View File

@ -1,9 +1,14 @@
Imports MultiTool.Shared.Winline
Imports System.IO
Imports MultiTool.Shared.Winline
Namespace Schemas
Public Class Schema
Public Property Tables As New List(Of Table)
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
Public Property Name As String

View File

@ -1,7 +1,8 @@
Imports System.IO
Imports System.Xml
Imports System.Xml.XPath
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports MultiTool.Shared.Winline
Imports MultiTool.Shared.Helpers
Namespace Schemas
Public Class SchemaLoader
@ -9,42 +10,95 @@ Namespace Schemas
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)
Database = pMSSQL
InputDirectory = pInputDirectory
End Sub
Public Function LoadFiles(pSchemaDirectory) As Boolean
If pSchemaDirectory = String.Empty Then
Throw New ArgumentNullException("SchemaDirectory")
End If
Logger.Info("Loading files from directory [{0}]", pSchemaDirectory)
Public Async Function LoadTemplates() As Task(Of Boolean)
Try
Dim oDirectory As New DirectoryInfo(pSchemaDirectory)
Dim oFiles = oDirectory.GetFiles()
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[TBEDI_XML_TEMPLATES]"
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
Catch ex As Exception
Logger.Error(ex)
Throw New IO.IOException($"Could not load files from directory {pSchemaDirectory}", ex)
Return False
End Try
End Function
Public Function GetSchemaFromFile(pSchemaFilePath As String) As Schema
Dim oSchema As New Schema
Dim oFileInfo As New FileInfo(pSchemaFilePath)
Dim oElements = GetSchemaElements(pSchemaFilePath)
Public Function UpdateSchemaFromFile(pSchema As Schema, pInputDirectory As String) As Schema
Dim oFullPath = Path.Combine(pInputDirectory, pSchema.FileName)
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
Dim oColumns = GetElementColumns(oElement)
@ -69,17 +123,17 @@ Namespace Schemas
oSchemaColumns.Add(oSchemaColumn)
Next
oSchema.Tables.Add(New Schema.Table With {
pSchema.Tables.Add(New Schema.Table With {
.Name = XmlData.GetElementAttribute(oElement, "name"),
.Columns = oSchemaColumns
})
Next
Return oSchema
Return pSchema
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
Return pSchema
End If
@ -89,7 +143,7 @@ Namespace Schemas
Dim oConfig = pTemplateConfig.GetColumn(oColumn.Name)
If oConfig Is Nothing Then
oConfig = New Winline.ColumnConfig With {
oConfig = New ColumnConfig With {
.IsRequired = oColumn.IsRequired,
.Name = oColumn.Name
}

View File

@ -1,6 +1,7 @@
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Database
Imports MultiTool.Shared.Helpers
Imports System.Text.RegularExpressions
Namespace Winline
@ -16,12 +17,9 @@ Namespace Winline
Public DocumentKinds As New List(Of DocumentKind)
Public Years As List(Of Integer)
Public TemplateConfiguration As New Configuration
Public Const ALL_MESOCOMP = "mesocomp"
Public Const VWEDI_XML_ITEMS = "VWEDI_XML_ITEMS"
Public Const V21_ARTICLENUMBER = "c002"
Public Const V21_ARTICLEDESCRIPTION = "c003"
Public Const V21_MAINARTICLENUMBER = "c011"
@ -487,47 +485,6 @@ Namespace Winline
End If
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>
''' Turns a database info like "SQLCWLDATEN on SERVER\INSTANCE" into a Tuple of two strings
''' </summary>
@ -552,14 +509,5 @@ Namespace Winline
Split(oDelimiter, StringSplitOptions.None).
ToList()
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 Namespace