221 lines
10 KiB
VB.net
221 lines
10 KiB
VB.net
Imports System.IO
|
|
|
|
Public Class frmConfig_Basic
|
|
Dim formloaded = False
|
|
Private Sub BtnConnect_Click(sender As Object, e As EventArgs) Handles BtnConnect.Click
|
|
Try
|
|
Dim constring As String
|
|
If chkbxUserAut.Checked Then
|
|
constring = "Data Source=" & Me.txtServer.Text & ";Initial Catalog=" & Me.cmbDatenbank.Text & ";Trusted_Connection=True;"
|
|
Else
|
|
constring = "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(constring) '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
|
|
'Set the construction string
|
|
MyConnectionString = constring 'csb.ConnectionString
|
|
|
|
If chkbxUserAut.Checked = False Then
|
|
'Das Passwort verschlüsseln
|
|
Dim wrapper As New ClassEncryption("!35452didalog=")
|
|
Dim cipherText As String = wrapper.EncryptData(Me.txtPasswort.Text)
|
|
Dim pw As String = cipherText
|
|
constring = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & pw & ";"
|
|
End If
|
|
SaveConfigValue("MyConnectionString", constring)
|
|
|
|
Me.txtActualConnection.Text = constring
|
|
'Me.TBPM_KONFIGURATIONTableAdapter.Connection.ConnectionString = My.Settings.ConfigConnectionString
|
|
'Me.TBPM_KONFIGURATIONTableAdapter.Fill(Me.DD_DMSLiteDataSet.TBPM_KONFIGURATION)
|
|
End If
|
|
Catch ex As Exception
|
|
Cursor = Cursors.Default
|
|
MsgBox("Fehler beim Verbindungsaufbau: " & vbNewLine & ex.Message, MsgBoxStyle.Exclamation)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub cmbDatenbank_MouseClick(sender As Object, e As MouseEventArgs) Handles cmbDatenbank.MouseClick
|
|
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)
|
|
cmd.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
|
|
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler bei Datenbank-Connect:")
|
|
End Try
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Private Sub frmConfig_Basic_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
|
|
SaveConfigValue("UniversalViewer", txtuniversalViewer.Text)
|
|
End Sub
|
|
|
|
Private Sub frmConfig_Basic_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
If Not MyConnectionString = String.Empty Then
|
|
Dim csb As New SqlClient.SqlConnectionStringBuilder
|
|
csb.ConnectionString = MyConnectionString
|
|
|
|
Dim constr = MyConnectionString
|
|
constr = constr.Replace(csb.Password, "XXXXX")
|
|
Me.txtActualConnection.Text = constr
|
|
Me.txtuniversalViewer.Text = UniversalViewer
|
|
|
|
'Me.txtActualConnection.Text = MyConnectionString
|
|
CheckBox1.Checked = LogErrorsOnly
|
|
End If
|
|
If UniversalViewer = String.Empty Then
|
|
Me.TabControl1.SelectedIndex = 1
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.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
|
|
SaveConfigValue("UniversalViewer", txtuniversalViewer.Text)
|
|
UniversalViewer = txtuniversalViewer.Text
|
|
End If
|
|
End With
|
|
End Sub
|
|
|
|
Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
|
|
|
|
End Sub
|
|
|
|
Private Sub TabControl1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles TabControl1.SelectedIndexChanged
|
|
Select Case TabControl1.SelectedIndex
|
|
Case 2
|
|
Dim folderwatch = ClassDatabase.Execute_Scalar("SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE USER_ID = " & CURRENT_USERID, MyConnectionString)
|
|
If Not folderwatch Is Nothing Then
|
|
CURRENT_FOLDERWATCH = folderwatch
|
|
End If
|
|
Me.txtFolderWatch.Text = CURRENT_FOLDERWATCH
|
|
If Not ClassFolderWatcher.FolderWatcher Is Nothing Then
|
|
If ClassFolderWatcher.FolderWatcher.EnableRaisingEvents = True Then
|
|
btnstartstop1.Text = "Überwachung stoppen"
|
|
btnstartstop1.Image = My.Resources.bell_delete
|
|
Else
|
|
btnstartstop1.Text = "Überwachung starten"
|
|
btnstartstop1.Image = My.Resources.bell_go
|
|
End If
|
|
Else
|
|
btnstartstop1.Text = "Überwachung starten"
|
|
btnstartstop1.Image = My.Resources.bell_go
|
|
End If
|
|
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub btnFW_Desktop_Click(sender As Object, e As EventArgs) Handles btnFW_Desktop.Click
|
|
CURRENT_FOLDERWATCH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "SimpleIndexer")
|
|
CheckFolder(CURRENT_FOLDERWATCH)
|
|
End Sub
|
|
Sub CheckFolder(mypath As String)
|
|
Try
|
|
If (Not System.IO.Directory.Exists(mypath)) Then
|
|
System.IO.Directory.CreateDirectory(mypath)
|
|
End If
|
|
Dim folderwatch = ClassDatabase.Execute_Scalar("SELECT GUID FROM TBGI_FOLDERWATCH_USER WHERE USER_ID = " & CURRENT_USERID, MyConnectionString)
|
|
Dim sql As String
|
|
If folderwatch Is Nothing Then
|
|
sql = "INSERT INTO TBGI_FOLDERWATCH_USER (USER_ID, FOLDER_PATH, ADDED_WHO) VALUES (" & CURRENT_USERID & ",'" & mypath & "','" & Environment.UserName & "')"
|
|
Else
|
|
sql = "UPDATE TBGI_FOLDERWATCH_USER SET FOLDER_PATH = '" & mypath & "', CHANGED_WHO = '" & Environment.UserName & "' where GUID = " & folderwatch
|
|
End If
|
|
If ClassDatabase.Execute_non_Query(sql) Then
|
|
folderwatch = ClassDatabase.Execute_Scalar("SELECT FOLDER_PATH FROM TBGI_FOLDERWATCH_USER WHERE USER_ID = " & CURRENT_USERID, MyConnectionString)
|
|
CURRENT_FOLDERWATCH = folderwatch
|
|
Me.txtFolderWatch.Text = CURRENT_FOLDERWATCH
|
|
End If
|
|
If FW_started = True Then
|
|
ClassFolderWatcher.Restart_FolderWatch()
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in CheckFolder:")
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub btnFW_OwnFiles_Click(sender As Object, e As EventArgs) Handles btnFW_OwnFiles.Click
|
|
CURRENT_FOLDERWATCH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "SimpleIndexer")
|
|
CheckFolder(CURRENT_FOLDERWATCH)
|
|
End Sub
|
|
|
|
<STAThread()> _
|
|
Private Sub btnstartstop1_Click(sender As Object, e As EventArgs) Handles btnstartstop1.Click
|
|
If CURRENT_FOLDERWATCH <> "" Then
|
|
CheckFW_State()
|
|
End If
|
|
|
|
End Sub
|
|
Sub CheckFW_State()
|
|
Select Case ClassFolderWatcher.StartStop_FolderWatch()
|
|
Case 1
|
|
btnstartstop1.Text = "Überwachung stoppen"
|
|
btnstartstop1.Image = My.Resources.bell_delete
|
|
Case 0
|
|
btnstartstop1.Text = "Überwachung starten"
|
|
btnstartstop1.Image = My.Resources.bell_go
|
|
End Select
|
|
End Sub
|
|
|
|
Private Sub btnsetFW_Folder_Click(sender As Object, e As EventArgs) Handles btnsetFW_Folder.Click
|
|
Dim fbdialog As New FolderBrowserDialog
|
|
If fbdialog.ShowDialog() = DialogResult.OK Then
|
|
CheckFolder(fbdialog.SelectedPath)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
|
|
If formloaded = True Then
|
|
SaveConfigValue("LogErrorsOnly", CheckBox1.Checked)
|
|
ClassLogger.Add(" >> LogErrorsOnly auf '" & CheckBox1.Checked & "' umgestellt", False)
|
|
LogErrorsOnly = CheckBox1.Checked
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frmConfig_Basic_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
|
formloaded = True
|
|
End Sub
|
|
Private Sub btnopenlog_Click(sender As Object, e As EventArgs) Handles btnopenlog.Click
|
|
Process.Start(ClassLogger.DateiSpeicherort)
|
|
End Sub
|
|
Private Sub btnApplicationFolder_Click(sender As Object, e As EventArgs) Handles btnApplicationFolder.Click
|
|
Process.Start(Application.UserAppDataPath())
|
|
End Sub
|
|
End Class |