Imports System.Globalization Public Class frmKonfig Private email As New ClassEmail Dim formshown As Boolean = False Private Sub btnuniversalview_Click(sender As System.Object, e As System.EventArgs) Handles btnuniversalview.Click With OpenFileDialog1 ' Do .Filter = "Viewer.Exe|*.exe" .FilterIndex = 1 .Title = "Pfad zu Universal Viewer.exe:" If .ShowDialog() = DialogResult.OK Then Me.txtUniversalViewer.Text = .FileName CONFIG.Config.UniversalViewerPath = txtUniversalViewer.Text CONFIG.Save() 'SaveMySettingsValue("UniversalViewer", txtUniversalViewer.Text) End If End With End Sub Private Sub frmKonfig_Load(sender As Object, e As System.EventArgs) Handles Me.Load Try If VIEWER_ALL = "uviewer" Then rbuviewer.Checked = True Else rbwddocview.Checked = True End If If CONNECTION_STRING = String.Empty Then Me.TabControl1.SelectedIndex = 1 Load_ConString("") Else Load_ConString(CONNECTION_STRING) Me.TBPM_KONFIGURATIONTableAdapter.Connection.ConnectionString = CONNECTION_STRING Me.TBPM_KONFIGURATIONTableAdapter.Fill(Me.DD_DMSLiteDataSet.TBPM_KONFIGURATION) End If If VIEWER_UNIVERSAL = String.Empty Then VIEWER_UNIVERSAL = Application.StartupPath & "\programs\Universal Viewer\Viewer.exe" CONFIG.Config.UniversalViewerPath = VIEWER_UNIVERSAL CONFIG.Save() 'SaveMySettingsValue("UniversalViewer", VIEWER_UNIVERSAL) End If txtUniversalViewer.Text = VIEWER_UNIVERSAL txtUniversalViewer.Text = VIEWER_UNIVERSAL txtpdfxchange.Text = VIEWER_XCHANGE txtSumatra.Text = VIEWER_SUMATRA chkLogErrorsOnly.Checked = CBool(LOG_ERRORS_ONLY) Me.txtpdfxchange.Text = VIEWER_XCHANGE Catch ex As Exception LOGGER.Error(ex) MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler bei Formload Grundkonfig:") End Try End Sub Private Sub rbuviewer_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbuviewer.CheckedChanged If rbuviewer.Checked Then VIEWER_ALL = "uviewer" txtUniversalViewer.Text = VIEWER_UNIVERSAL GroupBox1.Visible = False rbSumatra.Checked = False rbPDFX_Change.Checked = False Else VIEWER_ALL = "docview" GroupBox1.Visible = True End If CONFIG.Config.DefaultViewer = VIEWER_ALL CONFIG.Save() 'SaveMySettingsValue("Viewer", VIEWER_ALL) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles btnpdfxchange.Click With OpenFileDialog1 ' Do .Filter = "PDFXCview.Exe|*.exe" .FilterIndex = 1 .Title = "Pfad zu PDF XChange Viewer.exe:" If .ShowDialog() = DialogResult.OK Then Me.txtpdfxchange.Text = .FileName VIEWER_XCHANGE = .FileName CONFIG.Config.XChangeViewerPath = txtpdfxchange.Text CONFIG.Save() 'SaveMySettingsValue("PDFXChangeViewer", txtpdfxchange.Text) End If End With End Sub Private Sub cmbDatenbank_Click(sender As System.Object, e As System.EventArgs) Handles cmbDatenbank.Click Try Me.Cursor = Cursors.WaitCursor Dim csb As New SqlClient.SqlConnectionStringBuilder csb.DataSource = Me.txtServer.Text csb.IntegratedSecurity = False csb.UserID = Me.txtUser.Text csb.Password = Me.txtPasswort.Text Dim con As String If chkbxUserAut.Checked Then con = "Data Source=" & Me.txtServer.Text & ";Trusted_Connection=True;" Else con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";" End If Dim connection As New SqlClient.SqlConnection(con) 'csb.ConnectionString) connection.Open() Dim cmd As New SqlClient.SqlCommand("sp_databases", connection) With { .CommandType = CommandType.StoredProcedure } ' Ausführen und Ergebnis in einer ListBox anzeigen Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader If dr.HasRows Then Do While dr.Read cmbDatenbank.Items.Add(dr("Database_Name")) Loop cmbDatenbank.DroppedDown = True End If connection.Close() Catch ex As Exception LOGGER.Error(ex) MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler bei Datenbank-Connect:") End Try Cursor = Cursors.Default End Sub Private Sub BtnConnect_Click(sender As System.Object, e As System.EventArgs) Handles BtnConnect.Click Try Dim oPlainConnectionString, oEncryptedConnectionString As String If chkbxUserAut.Checked Then oPlainConnectionString = "Data Source=" & Me.txtServer.Text & ";Initial Catalog=" & Me.cmbDatenbank.Text & ";Trusted_Connection=True;" Else oPlainConnectionString = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";" End If Dim connection As New SqlClient.SqlConnection(oPlainConnectionString) 'csb.ConnectionString) 'während Verbindungsaufbau Sanduhr-Mauszeiger Cursor = Cursors.WaitCursor connection.Open() Cursor = Cursors.Default 'DialogResult = Windows.Forms.DialogResult.OK Dim result As MsgBoxResult result = MessageBox.Show("Die Verbindung wurde erfolgreich aufgebaut!" & vbNewLine & "Möchten Sie diese Verbindung nun in der Anwendung speichern?", "Erfolgsmeldung:", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If result = MsgBoxResult.Yes Then 'ConnectionString in Anwendung speichern CONNECTION_STRING = oPlainConnectionString ClassDatabase.Init() 'Das Passwort verschlüsseln If chkbxUserAut.Checked = False Then Dim wrapper As New ClassEncryption("!35452didalog=") Dim cipherText As String = wrapper.EncryptData(Me.txtPasswort.Text) Dim pw As String = cipherText oEncryptedConnectionString = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & pw & ";" Else oEncryptedConnectionString = oPlainConnectionString End If 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 Me.TBPM_KONFIGURATIONTableAdapter.Fill(Me.DD_DMSLiteDataSet.TBPM_KONFIGURATION) End If Catch ex As Exception LOGGER.Error(ex) Cursor = Cursors.Default MsgBox("Fehler beim Verbindungsaufbau: " & vbNewLine & ex.Message, MsgBoxStyle.Exclamation) End Try End Sub Private Sub btnSumatra_Click(sender As System.Object, e As System.EventArgs) Handles btnSumatra.Click With OpenFileDialog1 ' Do .Filter = "SumatraPDF.exe|*.exe" .FilterIndex = 1 .Title = "Pfad zu SumatraPDF.exe:" If .ShowDialog() = DialogResult.OK Then Me.txtSumatra.Text = .FileName CONFIG.Config.SumatraViewerPath = txtSumatra.Text VIEWER_SUMATRA = txtSumatra.Text 'SaveMySettingsValue("SumatraViewer", txtSumatra.Text) End If End With End Sub Private Sub frmKonfig_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown formshown = True Select Case VIEWER_PDF Case "internal" rbPDF_internal.Checked = True Case "none" rbPDFX_Change.Checked = False rbSumatra.Checked = False Case "pdfxchange" rbPDFX_Change.Checked = True rbSumatra.Checked = False Case "sumatra" rbPDFX_Change.Checked = False rbSumatra.Checked = True If VIEWER_SUMATRA = String.Empty Then VIEWER_SUMATRA = Application.StartupPath & "\programs\SumatraPDF\SumatraPDF.exe" txtSumatra.Text = VIEWER_SUMATRA End If Case "system" rbSystem.Checked = True End Select End Sub Private Sub rbPDFX_Change_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles rbPDFX_Change.CheckedChanged If rbPDFX_Change.Checked And formshown = True Then If VIEWER_XCHANGE = String.Empty Then MsgBox("Bitte geben Sie den Installationspfad von PDF XChange-Viewer an!", MsgBoxStyle.Exclamation) End If VIEWER_PDF = "pdfxchange" CONFIG.Config.PDFViewer = VIEWER_PDF CONFIG.Save() 'SaveMySettingsValue("vpdfviewer", VIEWER_PDF) End If End Sub Private Sub rbSumatra_CheckedChanged(sender As Object, e As System.EventArgs) Handles rbSumatra.CheckedChanged If rbSumatra.Checked And formshown = True Then VIEWER_PDF = "sumatra" CONFIG.Config.PDFViewer = VIEWER_PDF CONFIG.Save() 'VIEWER_PDF = "sumatra" 'SaveMySettingsValue("vpdfviewer", VIEWER_PDF) ' lblSumatra.Visible = True ' txtSumatra.Visible = True ' btnSumatra.Visible = True 'Else ' lblSumatra.Visible = False ' txtSumatra.Visible = False ' btnSumatra.Visible = False End If End Sub Private Sub btnno_pdf_viewer_Click(sender As System.Object, e As System.EventArgs) Handles btnno_pdf_viewer.Click VIEWER_PDF = "none" CONFIG.Config.PDFViewer = VIEWER_PDF CONFIG.Save() 'SaveMySettingsValue("vpdfviewer", VIEWER_PDF) rbPDF_internal.Checked = False rbPDFX_Change.Checked = False txtpdfxchange.Text = "" rbSumatra.Checked = False txtSumatra.Text = "" rbSystem.Checked = False End Sub Private Sub chkbxUserAut_CheckedChanged(sender As Object, e As EventArgs) Handles chkbxUserAut.CheckedChanged If chkbxUserAut.Checked Then Me.txtPasswort.Enabled = False Me.txtUser.Enabled = False Else Me.txtPasswort.Enabled = True Me.txtUser.Enabled = True End If End Sub Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnLogMail.Click email.Send_Log_Mail(" Log-/SupportMail von Process-Manager DD.
", _ "Support-Mail Process-Manager", "support@didalog.de", "mail.triplew.de", "support@didalog.de", "ddemail40", "support@didalog.de", False, True) End Sub Private Sub TBPM_KONFIGURATIONBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Me.Validate() Me.TBPM_KONFIGURATIONBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.DD_DMSLiteDataSet) End Sub Private Sub Button1_Click_3(sender As Object, e As EventArgs) Handles Button1.Click MsgBox("Culture-Name: " & CultureInfo.CurrentCulture.Name & vbNewLine & "Culture-ThreeLetterISOLanguageName: " & CultureInfo.CurrentCulture.ThreeLetterISOLanguageName & vbNewLine & _ "CurrentUICulture-Name: " & CultureInfo.CurrentUICulture.Name & vbNewLine & "CurrentUICulture-ThreeLetterISOLanguageName: " & CultureInfo.CurrentUICulture.ThreeLetterISOLanguageName) End Sub Private Sub rbSystem_CheckedChanged(sender As Object, e As EventArgs) Handles rbSystem.CheckedChanged If rbSystem.Checked And formshown = True Then VIEWER_PDF = "system" CONFIG.Config.PDFViewer = VIEWER_PDF CONFIG.Save() 'SaveMySettingsValue("vpdfviewer", VIEWER_PDF) End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim p As Process Dim processes As Process() processes = Process.GetProcesses() Dim msg As String For Each p In processes If p.ProcessName <> "svchost" Then msg = msg & p.ProcessName & vbNewLine End If Next MsgBox("Liste der Processnames: " & vbNewLine & msg, MsgBoxStyle.Information) End Sub Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) My.Settings.Save() End Sub Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles rbPDF_internal.CheckedChanged If rbPDF_internal.Checked And formshown = True Then VIEWER_PDF = "internal" rbPDFX_Change.Checked = False txtpdfxchange.Text = "" rbSumatra.Checked = False txtSumatra.Text = "" rbSystem.Checked = False CONFIG.Config.PDFViewer = VIEWER_PDF CONFIG.Save() 'SaveMySettingsValue("vpdfviewer", VIEWER_PDF) End If End Sub Sub Load_ConString(constr As String) 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 ' Navigate to a URL. System.Diagnostics.Process.Start("http://www.didalog.de/Support") End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Process.Start(Application.UserAppDataPath()) End Sub Private Sub btnopenlog_Click(sender As Object, e As EventArgs) Handles btnopenlog.Click 'Process.Start(ClassLogger.DateiSpeicherort) Process.Start(LOGCONFIG.LogDirectory) End Sub Private Sub txtIntervall_TextChanged(sender As Object, e As EventArgs) Handles txtIntervall.TextChanged ' TODO: This is not used anywhere? My.Settings.Save() End Sub Private Sub chkLogErrorsOnly_CheckedChanged(sender As Object, e As EventArgs) Handles chkLogErrorsOnly.CheckedChanged LOG_ERRORS_ONLY = chkLogErrorsOnly.Checked LOGCONFIG.Debug = Not LOG_ERRORS_ONLY CONFIG.Config.LogErrorsOnly = LOG_ERRORS_ONLY 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 Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click Dim di As New IO.DirectoryInfo(Application.UserAppDataPath()) Dim diar1 As IO.FileInfo() = di.GetFiles() Dim dra As IO.FileInfo 'list the names of all files in the specified directory For Each dra In diar1 If dra.Name <> "UserConfig.xml" Then Try System.IO.File.Delete(dra.FullName) LOGGER.Info($"ConfigFile {dra.FullName} has been deleted!") Catch ex As Exception End Try End If Next MsgBox("The UserConfiguration has been set back to default!", MsgBoxStyle.OkOnly) End Sub End Class