Zooflow: Implement prefix for Config and Logging, Remove halbgar dev config

This commit is contained in:
Jonathan Jenne 2022-05-06 13:29:06 +02:00
parent 02f61b1e3f
commit 308b26556c
14 changed files with 109 additions and 130 deletions

View File

@ -60,8 +60,6 @@ Partial Class frmAdmin_Start
Me.btnEditRecord = New DevExpress.XtraBars.BarButtonItem()
Me.BarButtonItem26 = New DevExpress.XtraBars.BarButtonItem()
Me.BarButtonItem27 = New DevExpress.XtraBars.BarButtonItem()
Me.btnDatabaseConnection = New DevExpress.XtraBars.BarButtonItem()
Me.btnSecondServiceConnection = New DevExpress.XtraBars.BarButtonItem()
Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.RibbonPageGroup2 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
@ -114,6 +112,7 @@ Partial Class frmAdmin_Start
Me.RibbonGroup_ClipboardWatcher_DocSearch = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonGroup_ClipboardWatcher_Profile = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPage_ClipboardWatcher = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.btnSecondServiceConnection = New DevExpress.XtraBars.BarButtonItem()
CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.TreeListMenu, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.MainTreeImages, System.ComponentModel.ISupportInitialize).BeginInit()
@ -136,7 +135,7 @@ Partial Class frmAdmin_Start
'RibbonControl1
'
Me.RibbonControl1.ExpandCollapseItem.Id = 0
Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.BarButtonItem1, Me.BarButtonItem3, Me.BarButtonItem4, Me.BarButtonItem5, Me.labelStatus, Me.labelError, Me.BarButtonItemAddAttribute, Me.BarButtonItemRefreshAttribute, Me.BarButtonItem6, Me.BarButtonItem7, Me.BarButtonItem8, Me.BarButtonItem9, Me.BarButtonItem10, Me.BarButtonItem12, Me.BarButtonItem13, Me.BarButtonItem14, Me.BarButtonItem15, Me.BarButtonItem16, Me.BarButtonItem17, Me.BarButtonItem18, Me.BarButtonItem19, Me.BarButtonItem20, Me.BarButtonItem21, Me.BarButtonItem22, Me.BarButtonItem23, Me.BarButtonItem24, Me.BarButtonItem25, Me.btnAddRecord, Me.btnEditRecord, Me.BarButtonItem26, Me.BarButtonItem27, Me.btnDatabaseConnection, Me.btnSecondServiceConnection})
Me.RibbonControl1.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl1.ExpandCollapseItem, Me.RibbonControl1.SearchEditItem, Me.BarButtonItem1, Me.BarButtonItem3, Me.BarButtonItem4, Me.BarButtonItem5, Me.labelStatus, Me.labelError, Me.BarButtonItemAddAttribute, Me.BarButtonItemRefreshAttribute, Me.BarButtonItem6, Me.BarButtonItem7, Me.BarButtonItem8, Me.BarButtonItem9, Me.BarButtonItem10, Me.BarButtonItem12, Me.BarButtonItem13, Me.BarButtonItem14, Me.BarButtonItem15, Me.BarButtonItem16, Me.BarButtonItem17, Me.BarButtonItem18, Me.BarButtonItem19, Me.BarButtonItem20, Me.BarButtonItem21, Me.BarButtonItem22, Me.BarButtonItem23, Me.BarButtonItem24, Me.BarButtonItem25, Me.btnAddRecord, Me.btnEditRecord, Me.BarButtonItem26, Me.BarButtonItem27})
Me.RibbonControl1.Location = New System.Drawing.Point(0, 0)
Me.RibbonControl1.MaxItemId = 39
Me.RibbonControl1.Name = "RibbonControl1"
@ -374,20 +373,6 @@ Partial Class frmAdmin_Start
Me.BarButtonItem27.ImageOptions.SvgImage = Global.DigitalData.GUIs.ZooFlow.My.Resources.Resources.text1
Me.BarButtonItem27.Name = "BarButtonItem27"
'
'btnDatabaseConnection
'
Me.btnDatabaseConnection.Caption = "Datenbank konfigurieren"
Me.btnDatabaseConnection.Id = 37
Me.btnDatabaseConnection.ImageOptions.SvgImage = Global.DigitalData.GUIs.ZooFlow.My.Resources.Resources.managedatasource3
Me.btnDatabaseConnection.Name = "btnDatabaseConnection"
'
'btnSecondServiceConnection
'
Me.btnSecondServiceConnection.Caption = "Dienstkonfiguration umschalten"
Me.btnSecondServiceConnection.Id = 38
Me.btnSecondServiceConnection.ImageOptions.SvgImage = Global.DigitalData.GUIs.ZooFlow.My.Resources.Resources.switchrowcolumns
Me.btnSecondServiceConnection.Name = "btnSecondServiceConnection"
'
'RibbonPage1
'
Me.RibbonPage1.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup2, Me.RibbonPageGroup1})
@ -399,8 +384,6 @@ Partial Class frmAdmin_Start
Me.RibbonPageGroup2.Alignment = DevExpress.XtraBars.Ribbon.RibbonPageGroupAlignment.Far
Me.RibbonPageGroup2.ItemLinks.Add(Me.BarButtonItem27)
Me.RibbonPageGroup2.ItemLinks.Add(Me.BarButtonItem9)
Me.RibbonPageGroup2.ItemLinks.Add(Me.btnDatabaseConnection)
Me.RibbonPageGroup2.ItemLinks.Add(Me.btnSecondServiceConnection)
Me.RibbonPageGroup2.Name = "RibbonPageGroup2"
Me.RibbonPageGroup2.Text = "Daten"
'
@ -835,6 +818,13 @@ Partial Class frmAdmin_Start
Me.RibbonPage_ClipboardWatcher.Name = "RibbonPage_ClipboardWatcher"
Me.RibbonPage_ClipboardWatcher.Text = "Clipboard Watcher"
'
'btnSecondServiceConnection
'
Me.btnSecondServiceConnection.Caption = "Dienstkonfiguration umschalten"
Me.btnSecondServiceConnection.Id = 38
Me.btnSecondServiceConnection.ImageOptions.SvgImage = Global.DigitalData.GUIs.ZooFlow.My.Resources.Resources.switchrowcolumns
Me.btnSecondServiceConnection.Name = "btnSecondServiceConnection"
'
'frmAdmin_Start
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@ -959,6 +949,5 @@ Partial Class frmAdmin_Start
Friend WithEvents RibbonPage_ClipboardWatcher As DevExpress.XtraBars.Ribbon.RibbonPage
Friend WithEvents BarButtonItem26 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents BarButtonItem27 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents btnDatabaseConnection As DevExpress.XtraBars.BarButtonItem
Friend WithEvents btnSecondServiceConnection As DevExpress.XtraBars.BarButtonItem
End Class

View File

@ -30,13 +30,6 @@ Public Class frmAdmin_Start
DetailForm = New ClassDetailForm(My.LogConfig)
AddHandler DetailForm.DetailFormClosed, AddressOf DetailForm_Closed
'If My.SystemConfig.ConnectionString = String.Empty Then
' If ShowDatabaseSettings() = False Then
' MsgBox("Die Datenbank verbindung wurde nicht konfiguriert. Die Administration kann nicht verwendet werden.", MsgBoxStyle.Critical, Text)
' Exit Sub
' End If
'End If
DetailForm.LoadData()
TreeListMenu.ExpandAll()
End Sub
@ -290,54 +283,4 @@ Public Class frmAdmin_Start
Dim oForm As New frmAdmin_UserImport()
oForm.ShowDialog()
End Sub
Private Sub btnDatabaseConnection_ItemClick(sender As Object, e As ItemClickEventArgs) Handles btnDatabaseConnection.ItemClick
ShowDatabaseSettings()
End Sub
Private Function ShowDatabaseSettings() As Boolean
Dim oForm As New frmSQLConfig(My.LogConfig) With {
.ConnectionString = My.SystemConfig.ConnectionString,
.FormTitle = "ECM Datenbank"
}
Dim oResult = oForm.ShowDialog()
If oResult = DialogResult.OK Then
My.SystemConfig.ConnectionString = oForm.ConnectionString
My.SystemConfigManager.Save()
Return True
Else
Return False
End If
End Function
Private Sub btnSecondServiceConnection_ItemClick(sender As Object, e As ItemClickEventArgs) Handles btnSecondServiceConnection.ItemClick
If My.SystemConfig.AppServerConfigDevelopment = String.Empty Then
Dim oAnswer = MsgBox("Es ist keine zweite Dienstkonfiguration vorhanden. Wollen Sie nun eine hinterlegen?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text)
If oAnswer = MsgBoxResult.Yes Then
Dim oForm As New frmServiceConfig() With {
.ServiceAddress = "",
.ServiceOnline = False
}
oForm.ShowDialog()
My.SystemConfig.AppServerConfigDevelopment = oForm.ServiceAddress
My.SystemConfigManager.Save()
Else
' Cancel
Exit Sub
End If
End If
Dim oServiceAddress = My.SystemConfig.AppServerConfig
If My.Application.Service.Client.ServerAddress = My.SystemConfig.AppServerConfig Then
oServiceAddress = My.SystemConfig.AppServerConfigDevelopment
Else
oServiceAddress = My.SystemConfig.AppServerConfig
End If
My.Application.Service.Client = New Modules.EDMI.API.Client(My.LogConfig, oServiceAddress)
End Sub
End Class

View File

@ -22,6 +22,9 @@
<setting name="UseAppConfigConString" serializeAs="String">
<value>True</value>
</setting>
<setting name="UserConfig_Prefix" serializeAs="String">
<value>DEV</value>
</setting>
</DigitalData.GUIs.ZooFlow.Settings>
<DevExpress.LookAndFeel.Design.AppSettings>
<setting name="DefaultAppSkin" serializeAs="String">

View File

@ -1,4 +1,5 @@
Imports DigitalData.Modules.Config
Imports System.IO.Path
Imports DigitalData.Modules.Config
Imports DigitalData.Modules.EDMI.API
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Logging.LogConfig
@ -12,25 +13,57 @@ Namespace My
' StartupNextInstance: Wird beim Starten einer Einzelinstanzanwendung ausgelöst, wenn die Anwendung bereits aktiv ist.
' NetworkAvailabilityChanged: Wird beim Herstellen oder Trennen der Netzwerkverbindung ausgelöst.
Partial Friend Class MyApplication
Private _Logger As Logger
Private Logger As Logger
Private UserAppDataPath As String = Windows.Forms.Application.UserAppDataPath
Private BaseLocalUserConfigPath As String = Windows.Forms.Application.LocalUserAppDataPath
Private CommonAppDataPath As String = Windows.Forms.Application.CommonAppDataPath
Private StartupPath As String = Windows.Forms.Application.StartupPath
Private ReadOnly CommonAppDataPath As String = Windows.Forms.Application.CommonAppDataPath
Private ReadOnly StartupPath As String = Windows.Forms.Application.StartupPath
Private ReadOnly Property Prefix
Get
Return My.Settings.UserConfig_Prefix
End Get
End Property
Private ReadOnly Property HasPrefix
Get
Return TypeOf Prefix Is String AndAlso Prefix.Length > 0
End Get
End Property
Public ReadOnly Property UserAppDataPath As String
Get
If HasPrefix Then
Return Combine(Windows.Forms.Application.UserAppDataPath, Prefix)
Else
Return Windows.Forms.Application.UserAppDataPath
End If
End Get
End Property
Public ReadOnly Property LocalUserConfigPath As String
Get
If HasPrefix Then
Return Combine(Windows.Forms.Application.LocalUserAppDataPath, Prefix)
Else
Return Windows.Forms.Application.LocalUserAppDataPath
End If
End Get
End Property
Public Sub App_Startup() Handles Me.Startup
Dim oLogConfig As New LogConfig(LogPath:=PathType.AppData, CompanyName:="Digital Data", ProductName:="ZooFlow", FileKeepRangeInDays:=30) With {.Debug = True}
Dim oLogConfig As New LogConfig(LogPath:=PathType.CustomPath,
CustomLogPath:=Combine(LocalUserConfigPath, "Log"),
CompanyName:="Digital Data",
ProductName:="ZooFlow",
FileKeepRangeInDays:=30) With {.Debug = True}
' System Config files like Service Url will be saved in %LocalAppdata% so they will remain on the machine
Dim oConfigManager As New ConfigManager(Of ClassConfig)(oLogConfig, UserAppDataPath, CommonAppDataPath, StartupPath)
Dim oConfigManager As New ConfigManager(Of SystemConfig)(oLogConfig, UserAppDataPath, CommonAppDataPath, StartupPath)
' Layout files will be saved in %Appdata% (Roaming) so they will be syncronized with the user profile
Dim oUIConfigPath = IO.Path.Combine(UserAppDataPath, ClassConstants.FOLDER_NAME_LAYOUT)
Dim oUIConfigAlternatePath = IO.Path.Combine(UserAppDataPath, ClassConstants.FOLDER_NAME_LAYOUT)
Dim oUIConfigManager As New ConfigManager(Of ClassUIConfig)(oLogConfig, oUIConfigPath, oUIConfigPath, oUIConfigAlternatePath)
Dim oUIConfigManager As New ConfigManager(Of UIConfig)(oLogConfig, oUIConfigPath, oUIConfigPath, oUIConfigAlternatePath)
LogConfig = oLogConfig
LogConfig.Debug = True
@ -38,8 +71,8 @@ Namespace My
SystemConfigManager = oConfigManager
UIConfigManager = oUIConfigManager
_Logger = LogConfig.GetLogger()
_Logger.Debug("Starting ZooFlow...")
Logger = LogConfig.GetLogger()
Logger.Debug("Starting ZooFlow...")
If oConfigManager.Config.AppServerConfig <> String.Empty Then
Try
@ -55,7 +88,7 @@ Namespace My
My.Application.Service.Client.Connect()
End If
Catch ex As Exception
_Logger.Warn($"Could not initialize the AppServer: {ex.Message}")
Logger.Warn($"Could not initialize the AppServer: {ex.Message}")
End Try
End If
@ -68,12 +101,13 @@ Namespace My
End Sub
Public Sub App_Shutdown(sender As Object, e As EventArgs) Handles Me.Shutdown
_Logger.Debug("Shutting down Zooflow..")
Logger.Debug("Shutting down Zooflow..")
End Sub
Private Sub MyApplication_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs) Handles Me.UnhandledException
_Logger.Warn("Unhandled exception occurred: [{0}]", e.Exception.Message)
_Logger.Error(e.Exception)
Logger.Warn("Unhandled exception occurred: [{0}]", e.Exception.Message)
Logger.Error(e.Exception)
End Sub
End Class
End Namespace

View File

@ -118,15 +118,26 @@ Public Class ClassInit
If oResult <> DialogResult.OK Then
Throw New InitException("Could not initialize IDB-Service!")
End If
My.SystemConfig.AppServerConfig = oForm.ServiceAddress
My.SystemConfigManager.Save()
End If
' These Properties need to be set directly on
My.Application.Service.Address = My.SystemConfig.AppServerConfig
My.Application.Service.Client = New Client(LogConfig, My.SystemConfig.AppServerConfig)
MyApplication.Service.Address = My.SystemConfig.AppServerConfig
If Not IsNothing(My.Application.Service.Client) Then
My.Application.Service.Client.Connect()
Dim oClient = New Client(LogConfig, My.SystemConfig.AppServerConfig)
MyApplication.Service.Client = oClient
My.Application.Service.Client = oClient
If oClient Is Nothing Then
Throw New InitException("Could not initialize IDB-Service!")
End If
Dim oConnectionResult = My.Application.Service.Client.Connect()
If oConnectionResult = False Then
Throw New InitException("Could not connect to Service!")
End If
Catch ex As Exception
Logger.Error(ex)
@ -136,7 +147,7 @@ Public Class ClassInit
Private Sub InitializeDatabaseWithFallback(MyApplication As My.MyApplication)
Try
Logger.Debug("Loading client config..")
Dim oClientConfig = MyApplication.Service.Client.ClientConfig
Dim oClientConfig = My.Application.Service.Client.ClientConfig
Logger.Debug("Establishing ECM connection..")
Dim oECMConnectionString = oClientConfig.ConnectionStringECM

View File

@ -18,9 +18,9 @@ Public Class ClassModules
Private Const REGNODE_MANUFACTURER = "Digital Data"
Private Const REGPATH_BASE = "SOFTWARE\\WOW6432Node"
Private Config As ClassConfig
Private Config As SystemConfig
Public Sub New(pLogConfig As LogConfig, pConfig As ClassConfig)
Public Sub New(pLogConfig As LogConfig, pConfig As SystemConfig)
MyBase.New(pLogConfig)
Config = pConfig
End Sub

View File

@ -21,31 +21,11 @@ Imports DigitalData.Modules.Config.ConfigAttributes
'''
''' After changing a config value, My.ConfigManager.Save() must be called to persist the change in the config file
''' </summary>
Public Class ClassConfig
Public Function GetConnectionStringBuilder(ConnectionString As String) As SqlClient.SqlConnectionStringBuilder
Try
If ConnectionString = String.Empty Then
Return Nothing
End If
Dim oBuilder As New SqlClient.SqlConnectionStringBuilder(ConnectionString)
Return oBuilder
Catch ex As Exception
Return Nothing
End Try
End Function
Public Class SystemConfig
' === Service Configuration ===
<ConnectionString>
Public Property ConnectionString As String = String.Empty
<GlobalSetting>
Public Property AppServerConfig As String = String.Empty
<GlobalSetting>
Public Property AppServerConfigDevelopment As String = String.Empty
' === Logging Configuration
Public Property LogDebug As Boolean = False

View File

@ -1,4 +1,4 @@
Public Class ClassUIConfig
Public Class UIConfig
Public Property FlowForm As New FlowFormConfig
Public Property SearchForm As New SearchFormConfig
Public Property Globix As New GlobixConfig

View File

@ -18,7 +18,7 @@ Namespace Globix
Public Property Folderwatchstarted As Boolean = False
Public Property ScanFolderwatchstarted As Boolean = False
Public Property DTEXCLUDE_FILES As DataTable
Public Property PATH_FileExclusions As String = Path.Combine(Application.UserAppDataPath(), "FileExclusions.xml")
Public Property PATH_FileExclusions As String = Path.Combine(My.Application.UserAppDataPath, "FileExclusions.xml")
End Class
End Namespace

View File

@ -95,6 +95,15 @@ Partial Friend NotInheritable Class Settings
Me("IDBOBJID") = value
End Set
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("DEV")> _
Public ReadOnly Property UserConfig_Prefix() As String
Get
Return CType(Me("UserConfig_Prefix"),String)
End Get
End Property
End Class
Namespace My

View File

@ -24,5 +24,8 @@
<Setting Name="IDBOBJID" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="UserConfig_Prefix" Type="System.String" Scope="Application">
<Value Profile="(Default)">DEV</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -11,15 +11,15 @@ Namespace My
''' </summary>
<HideModuleName()>
Module Extension
Property SystemConfigManager As ConfigManager(Of ClassConfig)
ReadOnly Property SystemConfig As ClassConfig
Property SystemConfigManager As ConfigManager(Of SystemConfig)
ReadOnly Property SystemConfig As SystemConfig
Get
Return SystemConfigManager.Config
End Get
End Property
Property UIConfigManager As ConfigManager(Of ClassUIConfig)
ReadOnly Property UIConfig As ClassUIConfig
Property UIConfigManager As ConfigManager(Of UIConfig)
ReadOnly Property UIConfig As UIConfig
Get
Return UIConfigManager.Config
End Get

View File

@ -419,10 +419,10 @@
</Compile>
<Compile Include="Queries\ClassClipboardWatcherQueries.vb" />
<Compile Include="Queries\ClassCommonQueries.vb" />
<Compile Include="Config\ClassConfig.vb" />
<Compile Include="Config\SystemConfig.vb" />
<Compile Include="ClassConstants.vb" />
<Compile Include="ClassInitLoader.vb" />
<Compile Include="Config\ClassUIConfig.vb" />
<Compile Include="Config\UIConfig.vb" />
<Compile Include="frmSettings.Designer.vb">
<DependentUpon>frmSettings.vb</DependentUpon>
</Compile>

View File

@ -1,4 +1,5 @@
Imports DigitalData.Modules.EDMI.API
Imports System.ComponentModel
Imports DigitalData.Modules.EDMI.API
Imports DigitalData.Modules.Logging
Public Class frmServiceConfig
@ -67,5 +68,11 @@ Public Class frmServiceConfig
End Try
End Sub
Private Sub frmServiceConfig_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
If ServiceAddress <> "" And ServiceOnline = True Then
DialogResult = DialogResult.OK
Else
DialogResult = DialogResult.Cancel
End If
End Sub
End Class