From 0feb7b4122c0b461b53f85e43b7e99488367bf68 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 12 Mar 2020 11:55:24 +0100 Subject: [PATCH] clean up --- Global_Indexer/ClassFileDrop.vb | 149 ++++++++++++++++++++++++++++ Global_Indexer/ClassInit.vb | 2 + Global_Indexer/frmStart.Designer.vb | 17 +++- Global_Indexer/frmStart.resx | 98 +++++++++--------- Global_Indexer/frmStart.vb | 48 ++------- 5 files changed, 221 insertions(+), 93 deletions(-) diff --git a/Global_Indexer/ClassFileDrop.vb b/Global_Indexer/ClassFileDrop.vb index ff84d63..4997b8f 100644 --- a/Global_Indexer/ClassFileDrop.vb +++ b/Global_Indexer/ClassFileDrop.vb @@ -1,9 +1,22 @@ Imports System.IO Imports Microsoft.Office.Interop + + + Public Class ClassFileDrop Public Shared files_dropped As String() + + ' Tobit David Drag Drop: https://www.david-forum.de/thread/12671-drag-and-drop-von-faxen-und-mails-in-net-anwendung/ + 'Private Declare Function DVEmlFromMailItem Lib "DvApi32" (ByVal oMailItem As MailItem, ByVal strFileName As String) As Long + Public Shared Function Drop_File(e As DragEventArgs) Try + LOGGER.Info("Available Drop Formats:") + + For Each oFormat As String In e.Data.GetFormats() + LOGGER.Info(oFormat) + Next + LOGGER.Info(">> Drop_File") files_dropped = Nothing If e.Data.GetDataPresent(DataFormats.FileDrop) Then @@ -132,4 +145,140 @@ Public Class ClassFileDrop End Function + 'Private Sub DragDrop_HandleTobit(e As DragEventArgs) + ' If e.Data.GetDataPresent("#TobitMsgData") Then + ' Dim Quellpfad As String = "" + ' Dim Dateinamen As String() + ' 'Quellpfad zu den David Dateien auslesen + ' Using ms As MemoryStream = e.Data.GetData("#TobitMsgData") + ' Dim bytes As Byte() = ms.ToArray() + ' Dim n As Integer = 0 + ' Dim c As Char + ' Do While True + ' c = Convert.ToChar(bytes(n)) + ' If bytes(n) <> 0 Then + ' Quellpfad &= c + ' n += 1 + ' Else + ' Exit Do + ' End If + ' Loop + ' End Using + ' 'Dateinamen der gedroppten Emails auslesen + ' Using ms As MemoryStream = e.Data.GetData("FileGroupDescriptor") + ' 'Header sind 4B + ' 'Jeder Datensatz ist 332B + ' 'Bei Index 72 des Datensatzes beginnt das "Dateiname.eml" + ' Dim bytes As Byte() = ms.ToArray() + ' ReDim Dateinamen(Int(bytes.Count / 332) - 1) + ' ' Array mit so vielen Elementen wie Datensätze im FileGroupDescriptor sind + ' Dim AnzahlMails As Integer = bytes(0) + ' Dim Dateiname As String + ' Dim n As Integer + ' For i = 0 To AnzahlMails - 1 + ' Dateiname = "" + ' n = 0 + ' Do While True + ' 'Solange die Bytes auslesen, bis man einen vbNullChar liest + ' If bytes(i * 332 + 4 + 72 + n) <> 0 Then + ' Dateiname = Dateiname & Convert.ToChar(bytes(i * 332 + 4 + 72 + n)) + + ' n += 1 + ' Else + ' Exit Do + ' End If + ' Loop + ' Dateinamen(i) = Dateiname + ' Next + ' End Using + ' Using EntryDataEx As MemoryStream = e.Data.GetData("#TobitEntryDataEx") + ' Dim bytes As Byte() = EntryDataEx.ToArray() + ' 'Die Größe des Headers steht im ersten Byte + ' Dim HeadExSize As Integer = bytes(0) + ' 'Die Anzahl der Datensätze steht im 8. - 11. Byte + ' Dim nCountEntries As Integer = BitConverter.ToInt32(bytes, 8) + ' Dim nPositions(nCountEntries - 1) As Integer + ' For i = 0 To nCountEntries - 1 + ' 'Datensätze in der #TobitEntryDataEx sind 269 Byte groß. + ' 'In den ersten 4 Bytes steht die QID aus der archive.dat + ' nPositions(i) = BitConverter.ToInt32(bytes, HeadExSize + i * 269) + ' Next + + ' Using fs As New FileStream(Quellpfad & "\archive.dat", FileMode.Open, FileAccess.Read) + + ' 'archive.dat als MemoryStream kopieren + ' Using ms As New MemoryStream + ' fs.CopyTo(ms) + ' 'MemoryStream in ein Byte-Array konvertieren + ' Dim archiveBytes As Byte() = ms.ToArray() + ' 'Datensätze in der archive.dat sind 430 Byte groß + ' For i = 16 To archiveBytes.Length - 1 Step 430 + + ' 'Das 17.-20. Byte ist die QID die wir suchen + ' Dim QID As Integer = BitConverter.ToInt32(archiveBytes, i) + ' 'Wenn die QID übereinstimmt mit einer der David-Mails, dann lies den Dateinamen im Archiv aus + ' If nPositions.Contains(QID) Then + + ' 'Der Index der QID (0, ..., nCountEntries - 1) + ' Dim nPosIndex As Integer = -1 + ' For j = 0 To nPositions.Length - 1 + ' If QID = nPositions(j) Then + ' nPosIndex = j + ' Exit For + ' End If + ' Next + ' 'Alle Bytes ab dem 17. bis zum Ende des Datensatzes aus der archive.bat auslesen und als String konvertieren + ' Dim byteString As String = "" + ' For j = 0 To 429 - 17 + ' byteString &= Convert.ToChar(archiveBytes(i + j)) + ' Next + ' 'Index der Id herausfinden (Index des Quellpfads im byteString + Länge des Quellpfads + 1 "\") + ' Dim IdIndex As Integer = byteString.IndexOf(Quellpfad, StringComparison.OrdinalIgnoreCase) + Quellpfad.Length + 1 + ' 'Die Id sind dann die 8 Zeichen ab dem IdIndex + ' Dim Id As String = byteString.Substring(IdIndex, 8) + ' 'EML speichern + ' DavidEmlSpeichern(Quellpfad, Dateinamen(nPosIndex), QID, Id) + ' End If + ' Next + ' End Using + ' End Using + ' End Using + ' End If + 'End Sub + + 'Private Sub DavidEmlSpeichern(ArchivePfad As String, Dateiname As String, ID As String, FaxID As String) + ' Dim oApp As DavidAPIClass + ' Dim oAcc As Account + ' Dim oArchive As Archive + ' Dim oMessageItems As MessageItems + ' Dim oMailItem As MailItem + ' oApp = New DavidAPIClass() + ' oApp.LoginOptions = DvLoginOptions.DvLoginForceAsyncDuplicate + ' oAcc = oApp.Logon("DavidServer", "", "", "", "", "NOAUTH") + ' oArchive = oAcc.ArchiveFromID(ArchivePfad) + ' If FaxID.First() = "M" Then + ' 'Faxe beginnen mit M + ' 'Bei Faxen kann man einfach die .001 Datei kopieren und als TIF speichern + ' File.Copy(ArchivePfad & "\" & FaxID & ".001", "C:\Temp\" & Dateiname, True) + ' ListeAktualisieren() + ' ElseIf FaxID.First() = "I" Then + ' 'Emails beginnen mit I + ' 'Bei Emails muss man die DVEmlFromMailItem mit dem richtigen oMailItem aufrufen + ' oMessageItems = oArchive.MailItems + ' For Each oMailItem In oMessageItems + ' If oMailItem._ID = ID Then + ' Dim fileName As String = Space(260) + ' If DVEmlFromMailItem(oMailItem, fileName) <> 0 Then + ' fileName = Trim(fileName) + ' fileName = fileName.Substring(0, fileName.Length - 1) + ' File.Copy(fileName, "C:\Temp\" & Dateiname, True) + ' ListeAktualisieren() + ' End If + ' Exit For + ' End If + ' Next + ' End If + 'End Sub + + End Class diff --git a/Global_Indexer/ClassInit.vb b/Global_Indexer/ClassInit.vb index 5177331..2f113db 100644 --- a/Global_Indexer/ClassInit.vb +++ b/Global_Indexer/ClassInit.vb @@ -18,9 +18,11 @@ Public Class ClassInit Public Sub InitConfig() CONFIG = New ConfigManager(Of ClassConfig)(LOGCONFIG, Application.UserAppDataPath, Application.CommonAppDataPath) + LOGCONFIG.Debug = Not CONFIG.Config.LogErrorsOnly MyConnectionString = DecryptConnectionString(CONFIG.Config.ConnectionString) LogErrorsOnly = CONFIG.Config.LogErrorsOnly + 'myPreviewActive = CONFIG.Config.FilePreview FW_started = CONFIG.Config.FolderWatchStarted CURR_DELETE_ORIGIN = CONFIG.Config.DeleteOriginalFile diff --git a/Global_Indexer/frmStart.Designer.vb b/Global_Indexer/frmStart.Designer.vb index 592b05b..bfbb4ac 100644 --- a/Global_Indexer/frmStart.Designer.vb +++ b/Global_Indexer/frmStart.Designer.vb @@ -1,6 +1,6 @@  _ Partial Class frmStart - Inherits System.Windows.Forms.Form + Inherits DevExpress.XtraEditors.XtraForm 'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. _ @@ -54,6 +54,8 @@ Partial Class frmStart Me.btnChoosefiles = New System.Windows.Forms.Button() Me.MenuStrip1.SuspendLayout() Me.StatusStrip1.SuspendLayout() + CType(Me.MyDataset, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.TBHOTKEY_USER_PROFILEBindingSource, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'MenuStrip1 @@ -148,6 +150,7 @@ Partial Class frmStart ' Me.LabelControl1.AllowDrop = True Me.LabelControl1.Appearance.Font = CType(resources.GetObject("LabelControl1.Appearance.Font"), System.Drawing.Font) + Me.LabelControl1.Appearance.Options.UseFont = True resources.ApplyResources(Me.LabelControl1, "LabelControl1") Me.LabelControl1.Name = "LabelControl1" ' @@ -161,28 +164,29 @@ Partial Class frmStart resources.ApplyResources(Me.LabelMachine, "LabelMachine") Me.LabelMachine.Id = 3 Me.LabelMachine.Name = "LabelMachine" - Me.LabelMachine.TextAlignment = System.Drawing.StringAlignment.Near ' 'LabelUser ' resources.ApplyResources(Me.LabelUser, "LabelUser") Me.LabelUser.Id = 4 Me.LabelUser.Name = "LabelUser" - Me.LabelUser.TextAlignment = System.Drawing.StringAlignment.Near ' 'LabelLoggedIn ' resources.ApplyResources(Me.LabelLoggedIn, "LabelLoggedIn") Me.LabelLoggedIn.Id = 5 Me.LabelLoggedIn.Name = "LabelLoggedIn" - Me.LabelLoggedIn.TextAlignment = System.Drawing.StringAlignment.Near ' 'LabelVersion ' resources.ApplyResources(Me.LabelVersion, "LabelVersion") Me.LabelVersion.Id = 6 Me.LabelVersion.Name = "LabelVersion" - Me.LabelVersion.TextAlignment = System.Drawing.StringAlignment.Near + ' + 'MyDataset + ' + Me.MyDataset.DataSetName = "MyDataset" + Me.MyDataset.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema ' 'TBHOTKEY_USER_PROFILETableAdapter ' @@ -201,6 +205,7 @@ Partial Class frmStart Me.TableAdapterManager.TBDD_USERTableAdapter = Nothing Me.TableAdapterManager.TBGI_CONFIGURATIONTableAdapter = Nothing Me.TableAdapterManager.TBGI_OBJECTTYPE_EMAIL_INDEXTableAdapter = Nothing + Me.TableAdapterManager.TBGI_REGEX_DOCTYPETableAdapter = Nothing Me.TableAdapterManager.TBHOTKEY_PATTERNS_REWORKTableAdapter = Nothing Me.TableAdapterManager.TBHOTKEY_PATTERNSTableAdapter = Nothing Me.TableAdapterManager.TBHOTKEY_PROFILETableAdapter = Nothing @@ -234,6 +239,8 @@ Partial Class frmStart Me.MenuStrip1.PerformLayout() Me.StatusStrip1.ResumeLayout(False) Me.StatusStrip1.PerformLayout() + CType(Me.MyDataset, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.TBHOTKEY_USER_PROFILEBindingSource, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() diff --git a/Global_Indexer/frmStart.resx b/Global_Indexer/frmStart.resx index b8badcc..efd9f6b 100644 --- a/Global_Indexer/frmStart.resx +++ b/Global_Indexer/frmStart.resx @@ -121,6 +121,43 @@ 400, 17 + + 0, 0 + + + 295, 24 + + + + 5 + + + MenuStrip1 + + + MenuStrip1 + + + System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + 108, 20 + + + Konfiguration + + + 221, 22 + + + Administration + 232, 22 @@ -133,12 +170,6 @@ Hotkey - Einstellungen - - 221, 22 - - - Administration - 218, 6 @@ -166,54 +197,14 @@ Info - - 108, 20 - - - Konfiguration - - - 0, 0 - - - 294, 24 - - - - 5 - - - MenuStrip1 - - - MenuStrip1 - - - System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - 515, 17 - - 133, 17 - - - FolderWatch ist aktiv - - - False - - 0, 128 + 0, 137 - 294, 22 + 295, 22 6 @@ -233,6 +224,15 @@ 2 + + 133, 17 + + + FolderWatch ist aktiv + + + False + 1072, 17 @@ -634,7 +634,7 @@ auf dieses Fenster oder... 6, 13 - 294, 150 + 295, 159 Segoe UI, 8.25pt diff --git a/Global_Indexer/frmStart.vb b/Global_Indexer/frmStart.vb index 5f17162..ace1bd3 100644 --- a/Global_Indexer/frmStart.vb +++ b/Global_Indexer/frmStart.vb @@ -336,21 +336,8 @@ Public Class frmStart End Sub Private Sub frmStart_Load(sender As Object, e As EventArgs) Handles Me.Load - 'Me.TransparencyKey = Color.Transparent - ' Me.BackColor = Color.Transparent Cursor = Cursors.WaitCursor - ' My.Application.ChangeUICulture("en") - 'My.Application.ChangeCulture("en") - Dim i = My.Application.UICulture.ToString() - Try - - - 'Dim sql = sql_UserID - - 'Dim splash As New frmSplash() - 'splash.ShowDialog() - 'Lizenz abgellaufen, überprüfen ob User Admin ist If LICENSE_COUNT < UserLoggedin Then If USER_IS_ADMIN = True Then @@ -583,16 +570,6 @@ Public Class frmStart MsgBox("For the final changing of language, a restart is required!", MsgBoxStyle.Information) End If Application.Restart() - ''Sprache anpassen - 'SetLanguage() - 'LANGUAGE_CHANGED = False - 'If USER_IS_ADMIN = True Then - ' ToolStripSeparator1.Visible = True - ' AdministrationToolStripMenuItem.Visible = True - 'Else - ' ToolStripSeparator1.Visible = False - ' AdministrationToolStripMenuItem.Visible = False - 'End If End If Start_Folderwatch() Me.TopMost = True @@ -606,7 +583,6 @@ Public Class frmStart Load_Hotkeys() Me.Visible = True End If - End Sub Private Sub TimerFolderWatch_Tick(sender As Object, e As EventArgs) Handles TimerFolderWatch.Tick @@ -753,23 +729,19 @@ Public Class frmStart Private Sub btnChoosefiles_Click(sender As Object, e As EventArgs) Handles btnChoosefiles.Click Try - Dim openFileDialog1 As New OpenFileDialog - Dim fName As String - 'openFileDialog1.InitialDirectory = "c:\" - 'openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" - 'openFileDialog1.FilterIndex = 2 - - openFileDialog1.RestoreDirectory = True - - openFileDialog1.Multiselect = True + Dim oFileName As String + Dim oOpenFileDialog As New OpenFileDialog With { + .RestoreDirectory = True, + .Multiselect = True + } - If openFileDialog1.ShowDialog() = DialogResult.OK Then + If oOpenFileDialog.ShowDialog() = DialogResult.OK Then Dim i As Integer = 0 ClassFileDrop.files_dropped = Nothing - For Each fName In openFileDialog1.FileNames + For Each oFileName In oOpenFileDialog.FileNames ReDim Preserve ClassFileDrop.files_dropped(i) - LOGGER.Info(">> Chosen File: " & fName) - ClassFileDrop.files_dropped(i) = "|DROPFROMFSYSTEM|" & fName + LOGGER.Info(">> Chosen File: " & oFileName) + ClassFileDrop.files_dropped(i) = "|DROPFROMFSYSTEM|" & oFileName i += 1 Next TimerCheckDroppedFiles.Start() @@ -777,7 +749,5 @@ Public Class frmStart Catch ex As Exception MsgBox("Unexpected Error in Choose Files for Indexing:" & vbNewLine & ex.Message, MsgBoxStyle.Critical) End Try - End Sub - End Class \ No newline at end of file