This commit is contained in:
Jonathan Jenne 2020-03-12 11:55:24 +01:00
parent 5f5bb9f20c
commit 0feb7b4122
5 changed files with 221 additions and 93 deletions

View File

@ -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

View File

@ -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

View File

@ -1,6 +1,6 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmStart
Inherits System.Windows.Forms.Form
Inherits DevExpress.XtraEditors.XtraForm
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
@ -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()

View File

@ -121,6 +121,43 @@
<value>400, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="MenuStrip1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="MenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>295, 24</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="MenuStrip1.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="MenuStrip1.Text" xml:space="preserve">
<value>MenuStrip1</value>
</data>
<data name="&gt;&gt;MenuStrip1.Name" xml:space="preserve">
<value>MenuStrip1</value>
</data>
<data name="&gt;&gt;MenuStrip1.Type" xml:space="preserve">
<value>System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;MenuStrip1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;MenuStrip1.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="KonfigurationToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>108, 20</value>
</data>
<data name="KonfigurationToolStripMenuItem.Text" xml:space="preserve">
<value>Konfiguration</value>
</data>
<data name="AdministrationToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>221, 22</value>
</data>
<data name="AdministrationToolStripMenuItem.Text" xml:space="preserve">
<value>Administration</value>
</data>
<data name="GlobalIndexerEinstellungenToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>232, 22</value>
</data>
@ -133,12 +170,6 @@
<data name="HotkeyEisntellungenToolStripMenuItem.Text" xml:space="preserve">
<value>Hotkey - Einstellungen</value>
</data>
<data name="AdministrationToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>221, 22</value>
</data>
<data name="AdministrationToolStripMenuItem.Text" xml:space="preserve">
<value>Administration</value>
</data>
<data name="ToolStripSeparator1.Size" type="System.Drawing.Size, System.Drawing">
<value>218, 6</value>
</data>
@ -166,54 +197,14 @@
<data name="InfoToolStripMenuItem.Text" xml:space="preserve">
<value>Info</value>
</data>
<data name="KonfigurationToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>108, 20</value>
</data>
<data name="KonfigurationToolStripMenuItem.Text" xml:space="preserve">
<value>Konfiguration</value>
</data>
<data name="MenuStrip1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="MenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>294, 24</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="MenuStrip1.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="MenuStrip1.Text" xml:space="preserve">
<value>MenuStrip1</value>
</data>
<data name="&gt;&gt;MenuStrip1.Name" xml:space="preserve">
<value>MenuStrip1</value>
</data>
<data name="&gt;&gt;MenuStrip1.Type" xml:space="preserve">
<value>System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;MenuStrip1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;MenuStrip1.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<metadata name="StatusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>515, 17</value>
</metadata>
<data name="tslblFW.Size" type="System.Drawing.Size, System.Drawing">
<value>133, 17</value>
</data>
<data name="tslblFW.Text" xml:space="preserve">
<value>FolderWatch ist aktiv</value>
</data>
<data name="tslblFW.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="StatusStrip1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 128</value>
<value>0, 137</value>
</data>
<data name="StatusStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>294, 22</value>
<value>295, 22</value>
</data>
<data name="StatusStrip1.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -233,6 +224,15 @@
<data name="&gt;&gt;StatusStrip1.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="tslblFW.Size" type="System.Drawing.Size, System.Drawing">
<value>133, 17</value>
</data>
<data name="tslblFW.Text" xml:space="preserve">
<value>FolderWatch ist aktiv</value>
</data>
<data name="tslblFW.Visible" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<metadata name="TimerFolderWatch.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>1072, 17</value>
</metadata>
@ -634,7 +634,7 @@ auf dieses Fenster oder...</value>
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>294, 150</value>
<value>295, 159</value>
</data>
<data name="$this.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 8.25pt</value>

View File

@ -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
Dim oFileName As String
Dim oOpenFileDialog As New OpenFileDialog With {
.RestoreDirectory = True,
.Multiselect = True
}
openFileDialog1.RestoreDirectory = True
openFileDialog1.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