07-12-23
This commit is contained in:
@@ -11,90 +11,38 @@ Imports EnvelopeGenerator.Common.My
|
||||
Imports DevExpress.Charts.Native
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DevExpress.XtraGrid
|
||||
Imports System.Globalization
|
||||
Imports System.Threading
|
||||
|
||||
Public Class frmMain
|
||||
Private LogConfig As LogConfig
|
||||
Private Logger As Logger
|
||||
Private Database As MSSQLServer
|
||||
Private ConfigManager As ConfigManager(Of Config)
|
||||
Private ReadOnly LogConfig As LogConfig
|
||||
Private ReadOnly Logger As Logger
|
||||
Private TempFiles As TempFiles
|
||||
Private FormHelper As FormHelper
|
||||
Private GridBuilder As GridBuilder
|
||||
Private RefreshHelper As RefreshHelper
|
||||
|
||||
Private State As State
|
||||
Private Controller As EnvelopeListController
|
||||
|
||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Dim oLogPath = IO.Path.Combine(Application.LocalUserAppDataPath, "Log")
|
||||
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, oLogPath, CompanyName:="Digital Data", ProductName:="Envelope Generator")
|
||||
Public Sub New(pState As State)
|
||||
' Dieser Aufruf ist für den Designer erforderlich.
|
||||
InitializeComponent()
|
||||
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
State = pState
|
||||
LogConfig = pState.LogConfig
|
||||
Logger = LogConfig.GetLogger()
|
||||
FormHelper = New FormHelper(LogConfig, Me)
|
||||
End Sub
|
||||
|
||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
TempFiles = New TempFiles(LogConfig)
|
||||
TempFiles.Create()
|
||||
|
||||
RefreshHelper = New RefreshHelper(ViewEnvelopes, "Id")
|
||||
|
||||
Try
|
||||
ConfigManager = New ConfigManager(Of Config)(LogConfig, Application.UserAppDataPath, Application.CommonAppDataPath, Application.StartupPath)
|
||||
Controller = New EnvelopeListController(State)
|
||||
|
||||
If ConfigManager.Config.ConnectionString = String.Empty Then
|
||||
Dim oSQLConfig As New frmSQLConfig(LogConfig)
|
||||
If oSQLConfig.ShowDialog() = DialogResult.OK Then
|
||||
ConfigManager.Config.ConnectionString = oSQLConfig.ConnectionString
|
||||
ConfigManager.Save()
|
||||
Application.Restart()
|
||||
Else
|
||||
Throw New ApplicationException("No Database configured. Application will close!")
|
||||
End If
|
||||
End If
|
||||
|
||||
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
|
||||
Database = New MSSQLServer(LogConfig, oConnectionString)
|
||||
|
||||
State = New State With {
|
||||
.UserId = 0,
|
||||
.Config = ConfigManager.Config,
|
||||
.DbConfig = New DbConfig(),
|
||||
.LogConfig = LogConfig,
|
||||
.Database = Database
|
||||
}
|
||||
|
||||
If Database.DBInitialized = False Then
|
||||
Throw New ApplicationException("Could not connect to the database. Application will close!")
|
||||
End If
|
||||
|
||||
Dim ConfigModel = New ConfigModel(State)
|
||||
State.DbConfig = ConfigModel.LoadConfiguration()
|
||||
|
||||
Dim oUserModel = New UserModel(State)
|
||||
State.UserId = oUserModel.SelectUserId()
|
||||
|
||||
Dim oUser = oUserModel.SelectUser()
|
||||
oUser = oUserModel.CheckUserLogin(oUser)
|
||||
|
||||
If oUser.HasAccess = False Then
|
||||
Throw New ApplicationException("User is not activated for this module. Please contact your administrator. Application will close!")
|
||||
End If
|
||||
|
||||
If Not String.IsNullOrEmpty(State.DbConfig.ExternalProgramName) Then
|
||||
Text = State.DbConfig.ExternalProgramName
|
||||
End If
|
||||
|
||||
Controller = New EnvelopeListController(State)
|
||||
|
||||
LoadEnvelopeData()
|
||||
|
||||
Catch ex As ApplicationException
|
||||
Logger.Error(ex)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
|
||||
Application.Exit()
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
MsgBox($"Unexpected error: {ex.Message}", MsgBoxStyle.Critical, Text)
|
||||
Application.Exit()
|
||||
|
||||
End Try
|
||||
LoadEnvelopeData()
|
||||
End Sub
|
||||
|
||||
Private Sub LoadEnvelopeData()
|
||||
|
||||
Reference in New Issue
Block a user