Add Test Mode

This commit is contained in:
Jonathan Jenne 2019-04-16 16:26:31 +02:00
parent 5f14621fab
commit 5177e99ded
6 changed files with 833 additions and 434 deletions

View File

@ -6,6 +6,7 @@ Public Class ClassConfig
Public Property ConnectionString As String = ""
<ConnectionStringTest>
Public Property ConnectionStringTest As String = ""
Public Property TestMode As Boolean = False
' PDF Viewer Settings
Public Property UniversalViewerPath As String = ""

View File

@ -24,7 +24,7 @@ Public Class ClassInit
CONFIG = New ConfigManager(Of ClassConfig)(LOGCONFIG, Application.UserAppDataPath, Application.CommonAppDataPath)
LOGGER.Info("Config loaded")
If CONFIG.Config.ConnectionStringTest <> String.Empty Then
If CONFIG.Config.ConnectionStringTest <> String.Empty And CONFIG.Config.TestMode = True Then
LOGGER.Debug("Test Connection String loaded")
CONNECTION_STRING = DecryptConnectionString(CONFIG.Config.ConnectionStringTest)
Else
@ -46,6 +46,7 @@ Public Class ClassInit
LOG_ERRORS_ONLY = CONFIG.Config.LogErrorsOnly
LOGCONFIG.Debug = Not LOG_ERRORS_ONLY
TEST_MODE = CONFIG.Config.TestMode
'Settings_Load()
End Sub

View File

@ -1,6 +1,7 @@
Module ModuleMySettings
' Connection String
Public CONNECTION_STRING As String = ""
Public TEST_MODE As String = False
' Debug Settings
Public LOG_ERRORS_ONLY As Boolean = True

View File

@ -22,7 +22,6 @@ Partial Class frmKonfig
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmKonfig))
Me.btnuniversalview = New System.Windows.Forms.Button()
Me.Label13 = New System.Windows.Forms.Label()
@ -69,9 +68,11 @@ Partial Class frmKonfig
Me.Button1 = New System.Windows.Forms.Button()
Me.btnLogMail = New System.Windows.Forms.Button()
Me.DD_DMSLiteDataSet = New DD_PM_WINDREAM.DD_DMSLiteDataSet()
Me.TBPM_KONFIGURATIONBindingSource = New System.Windows.Forms.BindingSource(Me.components)
Me.TBPM_KONFIGURATIONBindingSource = New System.Windows.Forms.BindingSource()
Me.TBPM_KONFIGURATIONTableAdapter = New DD_PM_WINDREAM.DD_DMSLiteDataSetTableAdapters.TBPM_KONFIGURATIONTableAdapter()
Me.TableAdapterManager = New DD_PM_WINDREAM.DD_DMSLiteDataSetTableAdapters.TableAdapterManager()
Me.RadioDefaultConnection = New System.Windows.Forms.RadioButton()
Me.RadioAlternativeConnection = New System.Windows.Forms.RadioButton()
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
Me.GroupBox1.SuspendLayout()
@ -221,6 +222,8 @@ Partial Class frmKonfig
'
'TabPage2
'
Me.TabPage2.Controls.Add(Me.RadioAlternativeConnection)
Me.TabPage2.Controls.Add(Me.RadioDefaultConnection)
Me.TabPage2.Controls.Add(Me.chkbxUserAut)
Me.TabPage2.Controls.Add(Me.Label5)
Me.TabPage2.Controls.Add(Me.cmbDatenbank)
@ -413,6 +416,20 @@ Partial Class frmKonfig
Me.TableAdapterManager.TBPM_TYPETableAdapter = Nothing
Me.TableAdapterManager.UpdateOrder = DD_PM_WINDREAM.DD_DMSLiteDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.InsertUpdateDelete
'
'RadioDefaultConnection
'
resources.ApplyResources(Me.RadioDefaultConnection, "RadioDefaultConnection")
Me.RadioDefaultConnection.Checked = True
Me.RadioDefaultConnection.Name = "RadioDefaultConnection"
Me.RadioDefaultConnection.TabStop = True
Me.RadioDefaultConnection.UseVisualStyleBackColor = True
'
'RadioAlternativeConnection
'
resources.ApplyResources(Me.RadioAlternativeConnection, "RadioAlternativeConnection")
Me.RadioAlternativeConnection.Name = "RadioAlternativeConnection"
Me.RadioAlternativeConnection.UseVisualStyleBackColor = True
'
'frmKonfig
'
resources.ApplyResources(Me, "$this")
@ -482,4 +499,6 @@ Partial Class frmKonfig
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents txtIntervall As System.Windows.Forms.TextBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents RadioAlternativeConnection As RadioButton
Friend WithEvents RadioDefaultConnection As RadioButton
End Class

File diff suppressed because it is too large Load Diff

View File

@ -150,12 +150,17 @@ Public Class frmKonfig
oEncryptedConnectionString = oPlainConnectionString
End If
'SaveMySettingsValue("MyConnectionString", con)
'My.Settings.Save()
CONNECTION_STRING = oPlainConnectionString
CONFIG.Config.ConnectionString = oEncryptedConnectionString
CONFIG.Save()
If RadioDefaultConnection.Checked Then
LOGGER.Debug("ConnectionString saved")
CONNECTION_STRING = oPlainConnectionString
CONFIG.Config.ConnectionString = oEncryptedConnectionString
CONFIG.Save(ForceAll:=True)
Else
LOGGER.Debug("ConnectionStringTest saved")
CONNECTION_STRING = oPlainConnectionString
CONFIG.Config.ConnectionStringTest = oEncryptedConnectionString
CONFIG.Save(ForceAll:=True)
End If
Load_ConString(CONNECTION_STRING)
Me.TBPM_KONFIGURATIONTableAdapter.Connection.ConnectionString = CONNECTION_STRING
@ -320,15 +325,20 @@ Public Class frmKonfig
End If
End Sub
Sub Load_ConString(constr As String)
If constr <> "" And constr.Contains("Password") Then
Dim csb As New SqlClient.SqlConnectionStringBuilder
csb.ConnectionString = CONNECTION_STRING
constr = constr.Replace(csb.Password, "XXXXX")
End If
Me.txtActualConnection.Text = constr
txtActualConnection.Text = MaskConnectionStringPassword(constr)
End Sub
Private Function MaskConnectionStringPassword(ConnectionString As String) As String
If ConnectionString.Contains("Password=") Then
Dim oBuilder As New SqlClient.SqlConnectionStringBuilder() With {
.ConnectionString = ConnectionString
}
Return ConnectionString.Replace(oBuilder.Password, "XXXXXX")
End If
Return ConnectionString
End Function
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
' Specify that the link was visited.
Me.LinkLabel1.LinkVisited = True
@ -357,4 +367,14 @@ Public Class frmKonfig
CONFIG.Save()
'SaveMySettingsValue("LogErrorsOnly", chkLogErrorsOnly.Checked)
End Sub
Private Sub RadioDefaultConnection_CheckedChanged(sender As Object, e As EventArgs) Handles RadioDefaultConnection.CheckedChanged
txtActualConnection.Text = MaskConnectionStringPassword(CONFIG.Config.ConnectionString)
End Sub
Private Sub RadioAlternativeConnection_CheckedChanged(sender As Object, e As EventArgs) Handles RadioAlternativeConnection.CheckedChanged
txtActualConnection.Text = MaskConnectionStringPassword(CONFIG.Config.ConnectionStringTest)
End Sub
End Class