161 lines
6.8 KiB
VB.net
161 lines
6.8 KiB
VB.net
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.Templates
|
|
|
|
Public Class frmMain
|
|
Private LogConfig As LogConfig
|
|
Private Logger As Logger
|
|
Private ConfigManager As ConfigManager(Of [Shared].Config)
|
|
Private Database As MSSQLServer
|
|
Private TemplateLoader As TemplateLoader
|
|
Private GridBuilder As GridBuilder
|
|
Private FormHelper As FormHelper
|
|
|
|
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
Try
|
|
Text = String.Format(My.Resources.frmShared._0____WebService_Multitool_für_WinLine, My.Resources.frmShared.Auswahl_der_Vorlage)
|
|
|
|
LogConfig = New LogConfig(LogConfig.PathType.AppData, Nothing, Nothing, Application.CompanyName, Application.ProductName)
|
|
LogConfig.Debug = True
|
|
Logger = LogConfig.GetLogger()
|
|
Logger.Info("Starting {0}, Version [{1}]", Application.ProductName, Application.ProductVersion)
|
|
|
|
Catch ex As Exception
|
|
FormHelper.ShowError(ex, My.Resources.frmShared.Laden_des_Formulars)
|
|
|
|
End Try
|
|
End Sub
|
|
|
|
Private Async Sub frmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
|
SplashScreenManager1.ShowWaitForm()
|
|
|
|
Try
|
|
SplashScreenManager1.SetWaitFormDescription("Initialisierung der Grundfunktionen")
|
|
|
|
FormHelper = New FormHelper(LogConfig)
|
|
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
|
|
|
|
SplashScreenManager1.SetWaitFormDescription("Initialisierung der Datenbankverbindung")
|
|
|
|
' Initialize Database
|
|
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
|
|
Database = New MSSQLServer(LogConfig, oConnectionString)
|
|
|
|
SplashScreenManager1.SetWaitFormDescription("Initialisierung der Vorlagen")
|
|
|
|
' Initialize Schemas
|
|
TemplateLoader = New TemplateLoader(LogConfig, Database)
|
|
Await TemplateLoader.LoadGeneralConfiguration()
|
|
Await TemplateLoader.LoadTemplates()
|
|
Await TemplateLoader.LoadTemplateConfiguration()
|
|
Await TemplateLoader.LoadMappingConfiguration()
|
|
Await TemplateLoader.LoadMandatorConfiguration()
|
|
|
|
' Save Schema data in 'My' Namespace
|
|
My.MappingConfiguration = TemplateLoader.MappingConfiguration
|
|
My.TemplateConfiguration = TemplateLoader.TemplateConfiguration
|
|
My.MandatorConfiguration = TemplateLoader.MandatorConfiguration
|
|
My.GeneralConfiguration = TemplateLoader.GeneralConfiguration
|
|
My.Helpers = New [Shared].Helpers(LogConfig)
|
|
|
|
Dim oBindingSource = New BindingList(Of Template)
|
|
For Each oTemplate As Template In TemplateLoader.TemplateList
|
|
oBindingSource.Add(oTemplate)
|
|
Next
|
|
|
|
GridControl1.DataSource = oBindingSource
|
|
Catch ex As Exception
|
|
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Winline_Daten)
|
|
|
|
Finally
|
|
SplashScreenManager1.CloseWaitForm()
|
|
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub btnOpenImportExportForm_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenImportExportForm.ItemClick
|
|
Try
|
|
Dim oTemplate As Template = GridViewTemplates.GetRow(GridViewTemplates.FocusedRowHandle)
|
|
|
|
If oTemplate Is Nothing Then
|
|
MsgBox("Keine Vorlage ausgewählt! Bitte wählen Sie eine Vorlage aus!", MsgBoxStyle.Exclamation, Text)
|
|
Exit Sub
|
|
End If
|
|
|
|
oTemplate = TemplateLoader.UpdateTemplateFromFile(oTemplate, My.GeneralConfiguration.TemplateDirectory)
|
|
oTemplate = TemplateLoader.UpdateTemplateFromDatabase(oTemplate, TemplateLoader.TemplateConfiguration)
|
|
|
|
If oTemplate.IsImport Then
|
|
Dim oForm As New frmImportMain(LogConfig, ConfigManager, oTemplate)
|
|
oForm.ShowDialog()
|
|
Else
|
|
MsgBox("Export-Vorlagen werden noch nicht unterstützt!", MsgBoxStyle.Exclamation, Text)
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
FormHelper.ShowError(ex, My.Resources.frmMainExtra.Laden_der_Vorlage)
|
|
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub TryOpenDirectory(pPath As String, pDisplayName As String)
|
|
If Directory.Exists(pPath) Then
|
|
Process.Start(pPath)
|
|
Else
|
|
Dim oMessage = String.Format(My.Resources.frmImportMainExtra._0__nicht_konfiguriert_oder_nicht_gefunden, pDisplayName)
|
|
MsgBox(oMessage, MsgBoxStyle.Exclamation, Text)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub TryOpenFile(pPath As String, pDisplayName As String)
|
|
If File.Exists(pPath) Then
|
|
Process.Start(pPath)
|
|
Else
|
|
Dim oMessage = String.Format(My.Resources.frmImportMainExtra._0__nicht_konfiguriert_oder_nicht_gefunden, pDisplayName)
|
|
MsgBox(oMessage, MsgBoxStyle.Exclamation, Text)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
|
|
Dim oForm As New frmConfig(LogConfig, ConfigManager)
|
|
oForm.ShowDialog()
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
|
|
Dim oUserConfigDirectory = New FileInfo(ConfigManager.UserConfigPath).Directory
|
|
TryOpenDirectory(oUserConfigDirectory.FullName, My.Resources.frmImportMainExtra.Konfigurationsverzeichnis)
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
|
TryOpenDirectory(LogConfig.LogDirectory, My.Resources.frmImportMainExtra.Logverzeichnis)
|
|
End Sub
|
|
|
|
|
|
|
|
End Class |