Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Windream Imports DigitalData.Modules.Config Imports DigitalData.GUIs.WiDigShared Imports DigitalData.Modules.Encryption Public Class frmMain Private _ArgumentLength As Integer Private LogConfig As LogConfig Private Logger As Logger Private Config As ConfigManager(Of ClassConfig) Private WiDig As ClassWIDig Private Windream As Windream Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load Try Me.Hide() Me.Visible = False Dim oLogConfig As New LogConfig(LogConfig.PathType.AppData, Nothing, "Form", "Digital Data", "WIDig") LogConfig = oLogConfig Logger = LogConfig.GetLogger Config = New ConfigManager(Of ClassConfig)(LogConfig, ClassWIDig.GetAppDataPath, ClassWIDig.GetAppDataPath) LogConfig.Debug = Config.Config.LOG_DEBUG Logger = LogConfig.GetLogger Logger.Debug("Initializing MainForm....") WiDig = New ClassWIDig(LogConfig, Config.Config) Dim oUserPW = WiDig.GetUserPWPlain() Me.txtPW.Text = oUserPW If WiDig.Connect2Windream(oUserPW) = True Then Dim oArguments As String() = Environment.GetCommandLineArgs() If WiDig.ParseArgs(oArguments) = True Then If WiDig.StreamORIndexFile() = True Then WiDig.ErrorWhileImporting = False Else WiDig.ErrorWhileImporting = True End If Else BarStaticinfo.Caption = $"Error in ParseArgs - {Now.ToString}" BarStaticinfo.ItemAppearance.Normal.BackColor = Color.Red End If Else WiDig.ErrorMessage = "Could not initialize windream" End If txtUser.Text = Config.Config.WMUsername Me.txtPW.Text = oUserPW txtWMDrive.Text = Config.Config.WMDrive txtWMRelpath.Text = Config.Config.WMRelPath txtWMServer.Text = Config.Config.WMUserPW txtDomain.Text = Config.Config.Domain 'txtCommands.Text = CONFIG.Config.Arguments txtCommands.Text = My.Settings.TestParams If WiDig.ErrorWhileParsing = True Then MsgBox("Error in Parsing or Indexing!", MsgBoxStyle.Critical, Text) Me.Visible = True End If Catch ex As Exception MsgBox("Error while initializing: " & vbNewLine & vbNewLine & ex.Message, MsgBoxStyle.Critical, Text) Logger.Error(ex) End Try End Sub Public Sub InitUserConfig() Dim oProgramDataPath = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Digital Data", "WIDig") Dim oUserAppDataPath = IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Digital Data", "WIDig") End Sub Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown If WiDig?.ErrorWhileImporting = False Then Me.Close() End If If WiDig?.ErrorWhileParsing = True And Environment.GetCommandLineArgs().Length <> 1 Then MsgBox("A unexpected error occured while Parsing arguments!" & vbNewLine & WiDig?.ErrorMessage, MsgBoxStyle.Critical) Process.Start(LogConfig.LogDirectory) End If If WiDig?.ErrorWhileImporting = True Then MsgBox("A unexpected error occured while initializing!" & vbNewLine & WiDig?.ErrorMessage, MsgBoxStyle.Critical) End If End Sub Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick Dim wrapper As New EncryptionLegacy("!35452didalog=") Dim cipherText As String = wrapper.EncryptData(Me.txtPW.Text) Dim pw As String = cipherText Config.Config.WMUserPW = pw Config.Config.WMUsername = txtUser.Text Config.Config.WMDrive = txtWMDrive.Text Config.Config.WMRelPath = txtWMRelpath.Text Config.Config.WMServer = txtWMServer.Text Config.Config.Domain = txtDomain.Text Config.Save() BarStaticinfo.Caption = $"WM-Settings saved - {Now.ToString}" BarStaticinfo.ItemAppearance.Normal.BackColor = Color.Lime End Sub Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick Windream = New Windream(LogConfig, False, txtWMDrive.Text, txtWMRelpath.Text, True, txtWMServer.Text, txtUser.Text, txtPW.Text, txtDomain.Text) If Not IsNothing(Windream) Then MsgBox("Windream-Connext successfull!", MsgBoxStyle.Information) End If End Sub Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter RibbonPageGroup1.Enabled = True End Sub Private Sub GroupBox1_Leave(sender As Object, e As EventArgs) Handles GroupBox1.Leave RibbonPageGroup1.Enabled = False End Sub Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick Process.Start(LogConfig.LogDirectory) End Sub Private Sub BarButtonItem5_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem5.ItemClick My.Settings.TestParams = txtCommands.Text My.Settings.Save() 'CONFIG.Config.Arguments = txtCommands.Text 'CONFIG.Save() Dim oArgs() As String = txtCommands.Text.Split("|") Logger.Debug($"[{oArgs.Length}] Arguments will be checked...") If IsNothing(Windream) Then Dim oUserPW = WiDig.GetUserPWPlain() If WiDig.Connect2Windream(oUserPW) = False Then MsgBox("Windream could not be initialized!! Check Your log!", MsgBoxStyle.Critical) Exit Sub End If End If If WiDig.ParseArgs(oArgs) = False Then MsgBox("An unexpected error occured while parsing arguments. Check the log!", MsgBoxStyle.Critical) Process.Start(LogConfig.LogDirectory) Else If WiDig.StreamORIndexFile() = True Then MsgBox("Import succeeded!", MsgBoxStyle.Information) Else MsgBox("Unexpected Error while streaming or indexing WMFile! Check the logfile!", MsgBoxStyle.Critical) Process.Start(LogConfig.LogDirectory) End If End If End Sub Private Sub txtCommands_GotFocus(sender As Object, e As EventArgs) Handles txtCommands.GotFocus RibbonPageGroup3.Enabled = True End Sub Private Sub txtCommands_LostFocus(sender As Object, e As EventArgs) Handles txtCommands.LostFocus RibbonPageGroup3.Enabled = False End Sub Private Sub GroupBox2_Enter(sender As Object, e As EventArgs) Handles GroupBox2.Enter RibbonPageGroup3.Enabled = False End Sub End Class