Replaced all license management classes (ClassLicense, ClassLicenses, ClassLicenseManager) with a new ClassPasswordCrypto for password encryption/decryption using Rijndael (AES). Updated all usages to call EncodePassword/DecodePassword instead of license key methods. Removed obsolete license-related code and files from the project. Incremented assembly version to 2.10.4.0. Cleaned up imports and updated the project file to reflect these changes. No license logic remains; only password crypto is handled.
461 lines
17 KiB
VB.net
461 lines
17 KiB
VB.net
Imports System.IO
|
|
Imports System.Text.RegularExpressions
|
|
Imports DigitalData.Modules.Database
|
|
Imports DigitalData.Modules.Logging
|
|
|
|
Public Class frmStart
|
|
Private _MyLogger As LogConfig
|
|
Private Shared _Logger As DigitalData.Modules.Logging.Logger
|
|
|
|
' CREATE INSTANCE
|
|
Private Shared _Instance As frmStart = Nothing
|
|
|
|
Public Shared Function Instance() As frmStart
|
|
If _Instance Is Nothing OrElse _Instance.IsDisposed Then
|
|
_Instance = New frmStart()
|
|
End If
|
|
Return _Instance
|
|
End Function
|
|
|
|
' DELETE LOGS
|
|
Private Sub Delete_LogFiles()
|
|
Try
|
|
Dim directory As New DirectoryInfo(My.Application.Info.DirectoryPath & "\Log")
|
|
_Logger.Debug($"Dateipfad geholt: {directory}")
|
|
Dim oIntervall As Integer = 30
|
|
Integer.TryParse(frmGrundeinstellungen.TextBox4.Text, oIntervall)
|
|
_Logger.Debug($"Löschalter aus der Config geholt: {oIntervall}")
|
|
|
|
For Each file As FileInfo In directory.GetFiles
|
|
_Logger.Debug($"Durchlaufe alle Dateien: {file.FullName}")
|
|
Try
|
|
Dim oAgeOfFile As Integer = (Now - file.CreationTime).Days
|
|
_Logger.Debug($"Alter der aktuellen Datei: {oAgeOfFile}")
|
|
If oAgeOfFile >= oIntervall Then
|
|
file.Delete()
|
|
_Logger.Debug($"Lösche Datei, die älter ist als Löschalter: {file.FullName}")
|
|
End If
|
|
Catch ex As Exception
|
|
_Logger.Warn($"Could not delete file {file.Name}: {ex.Message}")
|
|
End Try
|
|
Next
|
|
|
|
Catch ex As Exception
|
|
_Logger.Error(ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Public Sub SetupTimerDeleteLogfiles()
|
|
Try
|
|
Dim now As DateTime = DateTime.Now
|
|
Dim startTime As DateTime
|
|
|
|
' Zeit aus den gespeicherten Settings lesen
|
|
Dim timeString As String = My.Settings.vDeleteLogsTime
|
|
|
|
If String.IsNullOrWhiteSpace(timeString) Then
|
|
timeString = "02:00"
|
|
End If
|
|
|
|
Dim dt As DateTime
|
|
If DateTime.TryParse(timeString, dt) Then
|
|
'If timeString Then
|
|
My.Settings.vDeleteLogsTime = timeString
|
|
My.Settings.Save()
|
|
startTime = New DateTime(now.Year, now.Month, now.Day, dt.Hour, dt.Minute, 0)
|
|
If now > startTime Then startTime = startTime.AddDays(1)
|
|
Else
|
|
_Logger.Warn($"Ungültiges Zeitformat '{timeString}', Standard 02:00 wird verwendet.")
|
|
startTime = New DateTime(now.Year, now.Month, now.Day, 2, 0, 0)
|
|
If now > startTime Then startTime = startTime.AddDays(1)
|
|
End If
|
|
|
|
Dim interval As TimeSpan = startTime - now
|
|
Dim intervalMs As Double = interval.TotalMilliseconds
|
|
|
|
' Sicherheitscheck
|
|
If intervalMs < 1000 Then
|
|
intervalMs = 1000
|
|
End If
|
|
If intervalMs > Integer.MaxValue Then
|
|
intervalMs = Integer.MaxValue
|
|
End If
|
|
|
|
TimerDeleteLogfiles.Interval = CInt(intervalMs)
|
|
|
|
If My.Settings.vAutoDeleteLogs Then
|
|
TimerDeleteLogfiles.Start()
|
|
_Logger.Info($"TimerDeleteLogfiles startet in {interval.TotalMinutes:F1} Minuten (Zielzeit: {startTime:HH:mm}).")
|
|
Else
|
|
TimerDeleteLogfiles.Stop()
|
|
_Logger.Info("Automatische Log-Löschung deaktiviert, Timer gestoppt.")
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
_Logger.Error("Fehler in SetupTimerDeleteLogfiles: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub TimerDeleteLogfiles_Tick(sender As Object, e As EventArgs) Handles TimerDeleteLogfiles.Tick
|
|
Try
|
|
Delete_LogFiles()
|
|
' Nächstes Intervall wieder 24h
|
|
TimerDeleteLogfiles.Interval = 24 * 60 * 60 * 1000
|
|
Catch ex As Exception
|
|
_Logger.Error("Fehler beim automatischen Löschen: " & ex.Message)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub FMStart_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
|
|
Dim result As MsgBoxResult = MsgBox("Sind Sie sicher, dass sie " & Application.ProductName & " wirklich schließen wollen?" & vbNewLine & "Alle Vorgänge/Module werden gestoppt und nicht mehr ausgeführt!", MsgBoxStyle.YesNo, "Bestätigung erforderlich:")
|
|
If result = MsgBoxResult.No Then
|
|
e.Cancel = True
|
|
Return ' ← wichtig: hier sofort raus, kein Logout
|
|
End If
|
|
|
|
If Not IsNothing(CURRENToWMSession) Then
|
|
_Logger.Debug("Closing frmStart - Now logging out of windream session...")
|
|
Try
|
|
CURRENToWMSession.Logout()
|
|
_Logger.Debug("windream session logged out successfully.")
|
|
Catch ex As Exception
|
|
_Logger.Warn("Error while logging out windream session: " & ex.Message)
|
|
_Logger.Error(ex)
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CaptionForm()
|
|
Dim caption As String
|
|
|
|
If String.IsNullOrWhiteSpace(My.Settings.vInstanceName) Then
|
|
caption = Application.CompanyName & " - " & Application.ProductName
|
|
Else
|
|
caption = Application.CompanyName & " - " & Application.ProductName & " - " & My.Settings.vInstanceName
|
|
End If
|
|
|
|
' Fenster-Titel setzen
|
|
Me.Text = caption
|
|
|
|
Dim trayText As String = caption
|
|
|
|
If trayText.Length > 63 Then
|
|
trayText = trayText.Substring(0, 60) & "..."
|
|
End If
|
|
|
|
' Systray-Tooltip setzen
|
|
niToolcollection.Text = trayText
|
|
End Sub
|
|
|
|
Private Sub FMStart_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
|
|
|
_Instance = Me
|
|
|
|
For Each arg As String In My.Application.CommandLineArgs
|
|
Select Case arg.ToLower()
|
|
Case "/startfim"
|
|
AUTOSTART_FIM = True 'Dateiimport
|
|
Case "/startfih"
|
|
AUTOSTART_FIH = True 'Nachindexierung
|
|
End Select
|
|
Next
|
|
|
|
Try
|
|
'Delete_LogFiles()
|
|
|
|
_MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, My.Application.Info.CompanyName,
|
|
My.Application.Info.ProductName)
|
|
_Logger = _MyLogger.GetLogger()
|
|
_MyLogger.Debug = Not My.Settings.vLogErrorsonly
|
|
|
|
CURR_Logger = _Logger
|
|
CURR_LogConfig = _MyLogger
|
|
|
|
SetupTimerDeleteLogfiles()
|
|
|
|
'Aktueller Benutzer
|
|
Me.tslblVersion.Text = Environment.UserName.ToString
|
|
CaptionForm()
|
|
Me.tslblVersion.Text = "Version: " & My.Application.Info.Version.ToString
|
|
'Aktuelle Machine
|
|
Me.Status_Machine.Text = My.Computer.Name
|
|
'Zeitpunkt der automatischen Löschung von Logs
|
|
If My.Settings.vAutoDeleteLogs Then
|
|
Me.ToolStripStatusLabel_LogDeleteTime.Text = "Logs werden automatisch gelöscht um: " & My.Settings.vDeleteLogsTime.ToShortTimeString & " Uhr."
|
|
Else
|
|
Me.ToolStripStatusLabel_LogDeleteTime.Text = "Automatisches Löschen von Logs ist inaktiv."
|
|
End If
|
|
|
|
Dim connectionString As String = My.Settings.DDECMConString
|
|
connectionString = Regex.Replace(connectionString, "(?i)(password|pwd)\s*=\s*[^;]*", "$1=******")
|
|
Me.ToolStripStatusLabel_ConnectionString.Text = $"Datenbankverbindung: {connectionString}"
|
|
|
|
' timUhrzeit.Start()
|
|
TimerErrorLog.Start()
|
|
|
|
If My.Settings.WM_PERS_LOGIN <> String.Empty Then
|
|
Dim oSPLIT As String()
|
|
oSPLIT = My.Settings.WM_PERS_LOGIN.Split("#")
|
|
If oSPLIT.Length > 0 Then
|
|
If oSPLIT(0) <> "@Domain" Then
|
|
|
|
WMLOGIN_DOMAIN = oSPLIT(0)
|
|
_Logger.Info($"WMLOGIN_DOMAIN: {WMLOGIN_DOMAIN}")
|
|
WMLOGIN_USER = oSPLIT(1)
|
|
_Logger.Info($"WMLOGIN_USER: {WMLOGIN_USER}")
|
|
WMLOGIN_PW = oSPLIT(2)
|
|
Else
|
|
_Logger.Info($"No dedicated WMUser(1)")
|
|
End If
|
|
End If
|
|
|
|
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
_Logger.Error(ex)
|
|
End Try
|
|
Try
|
|
If My.Settings.DDECMConString <> String.Empty Then
|
|
Dim oSPLIT As String()
|
|
oSPLIT = My.Settings.DDECMConString.Split(";")
|
|
Dim oServer As String
|
|
Dim oDB As String
|
|
Dim oUSer As String
|
|
Dim oPW As String
|
|
For Each oSplitPart As String In oSPLIT
|
|
If oSplitPart.Contains("Data Source") Then
|
|
oServer = oSplitPart.Replace("Data Source=", "")
|
|
ElseIf oSplitPart.Contains("Initial Catalog") Then
|
|
oDB = oSplitPart.Replace("Initial Catalog=", "")
|
|
ElseIf oSplitPart.Contains("User ID") Then
|
|
oUSer = oSplitPart.Replace("User ID=", "")
|
|
ElseIf oSplitPart.Contains("Password") Then
|
|
oPW = oSplitPart.Replace("Password=", "")
|
|
End If
|
|
Next
|
|
DB_ECM = New MSSQLServer(_MyLogger, oServer, oDB, oUSer, oPW)
|
|
If DB_ECM.DBInitialized Then
|
|
_Logger.Info("DB ECM SUCCESSFULLY INITIIALIZED")
|
|
Else
|
|
_Logger.Warn("ATTENTION: DB DD_ECM NOT INITIIALIZED")
|
|
End If
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
_Logger.Error(ex)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Private Sub BeendenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeendenToolStripMenuItem.Click
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Sub DateiimporterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
|
|
Open_DI_Main()
|
|
End Sub
|
|
Private Sub btnDIMain_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDIMain.Click
|
|
Open_DI_Main()
|
|
End Sub
|
|
Sub Open_DI_Main()
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmDIHauptseite
|
|
frm = frmDIHauptseite.Instance
|
|
frm.MdiParent = Me
|
|
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
Sub Open_DI_Profile()
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmDIProfilEigenschaften
|
|
frm = frmDIProfilEigenschaften.Instance
|
|
frm.MdiParent = Me
|
|
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Private Sub btnDIProfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDIProfile.Click
|
|
Open_DI_Profile()
|
|
End Sub
|
|
|
|
Private Sub btnRegelverwaltung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRegelverwaltung.Click
|
|
Open_DI_Regelverwaltung()
|
|
End Sub
|
|
Sub Open_DI_Regelverwaltung()
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmDIRegelverwaltung
|
|
frm = frmDIRegelverwaltung.Instance
|
|
frm.MdiParent = Me
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Public Sub ClearGroupBoxes()
|
|
Me.grbDI.Visible = False
|
|
Me.GBNachindexierung.Visible = False
|
|
Me.grbxMoRe.Visible = False
|
|
End Sub
|
|
|
|
Private Sub FMStart_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
|
|
TimerNIRestart.Start()
|
|
'If My.Settings.DI_RUNNING Or AUTOSTART_FIM Then
|
|
If AUTOSTART_FIM Then
|
|
Open_DI_Main()
|
|
End If
|
|
'If NIDurchlaufRunning Or AUTOSTART_FIH Then
|
|
If AUTOSTART_FIH Then
|
|
Open_NI_Main()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnNIProfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNIProfile.Click
|
|
Open_NI_Profile()
|
|
End Sub
|
|
Sub Open_NI_Profile()
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmNIProfileigenschaften
|
|
frm = frmNIProfileigenschaften.Instance
|
|
frm.MdiParent = Me
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
Sub Open_NI_Main()
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmNIHauptseite
|
|
frm = frmNIHauptseite.Instance
|
|
frm.MdiParent = Me
|
|
frm.Show()
|
|
'frm.StartPosition = FormStartPosition.Manual
|
|
'frm.Location = New Point(50, 50)
|
|
'Dim loc = frm.Location.ToString()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
Private Sub btnNIMain_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNIMain.Click
|
|
Open_NI_Main()
|
|
End Sub
|
|
|
|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmNIVerknuepfungen
|
|
frm.MdiParent = Me
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Private Sub ÜberToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ÜberToolStripMenuItem.Click
|
|
frmabout.ShowDialog()
|
|
End Sub
|
|
|
|
Private Sub PasswortverwaltungToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasswortverwaltungToolStripMenuItem.Click
|
|
frmPWChange.ShowDialog()
|
|
End Sub
|
|
|
|
Private Sub ModuleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModuleToolStripMenuItem.Click
|
|
|
|
End Sub
|
|
Sub Open_MoRe_Profile()
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmMORE_Verwaltung
|
|
frm = frmMORE_Verwaltung
|
|
frm.MdiParent = Me
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Private Sub btnOpen_MoReProfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen_MoReProfile.Click
|
|
Open_MoRe_Profile()
|
|
End Sub
|
|
|
|
Private Sub EinblendenAusblendenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles EinblendenAusblendenToolStripMenuItem.Click
|
|
Ein_Aus()
|
|
End Sub
|
|
Sub Ein_Aus()
|
|
Me.ShowInTaskbar = True
|
|
Me.niToolcollection.Visible = False
|
|
Me.WindowState = FormWindowState.Normal
|
|
End Sub
|
|
|
|
Private Sub ContextMenuStrip1_Opening(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
|
|
If Me.Visible = True Then
|
|
EinblendenAusblendenToolStripMenuItem.Text = "Tool Collection minimieren"
|
|
Else
|
|
EinblendenAusblendenToolStripMenuItem.Text = "Tool Collection maximieren/einblenden"
|
|
End If
|
|
End Sub
|
|
Private Sub ZeigeLogFileToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ZeigeLogFileToolStripMenuItem.Click
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmreadLog
|
|
frm = frmreadLog.Instance
|
|
frm.MdiParent = Me
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Private Sub GrundeinstellungenToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles GrundeinstellungenToolStripMenuItem.Click
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmGrundeinstellungen
|
|
frm = frmGrundeinstellungen.Instance
|
|
frm.ShowDialog()
|
|
CaptionForm()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Private Sub ÜbersichtToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ÜbersichtToolStripMenuItem.Click
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmUebersicht
|
|
frm = frmUebersicht.Instance
|
|
frm.MdiParent = Me
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
Public Sub New()
|
|
' Dieser Aufruf ist für den Designer erforderlich.
|
|
InitializeComponent()
|
|
|
|
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
|
End Sub
|
|
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles btnNachbearbeitungAD.Click
|
|
Cursor = Cursors.WaitCursor
|
|
Dim frm As New frmNB_AD
|
|
frm = frmNB_AD.Instance
|
|
frm.MdiParent = Me
|
|
frm.Show()
|
|
Cursor = Cursors.Default
|
|
End Sub
|
|
|
|
Private Sub frmStart_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
|
|
If Me.WindowState = FormWindowState.Minimized Then
|
|
Me.ShowInTaskbar = False
|
|
Me.WindowState = FormWindowState.Minimized
|
|
Me.niToolcollection.Visible = True
|
|
End If
|
|
End Sub
|
|
Private Sub niToolcollection_Click(sender As Object, e As EventArgs) Handles niToolcollection.Click
|
|
Ein_Aus()
|
|
End Sub
|
|
Private Sub ÖffneLogverzeichnisToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ÖffneLogverzeichnisToolStripMenuItem.Click
|
|
Process.Start(Application.StartupPath & "\Log")
|
|
End Sub
|
|
|
|
Private Sub TimerNIRestart_Tick(sender As Object, e As EventArgs) Handles TimerNIRestart.Tick
|
|
If NI_Restart = True Then
|
|
|
|
NI_Restart = False
|
|
Open_NI_Main()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub TimerErrorLog_Tick(sender As Object, e As EventArgs) Handles TimerErrorLog.Tick
|
|
If CURRENT_APPLICATION_LOG <> String.Empty Then
|
|
Dim frm As New frmApplicationLog
|
|
frm = frmApplicationLog.Instance
|
|
|
|
frm.Show()
|
|
End If
|
|
|
|
End Sub
|
|
End Class
|