ZooFlow: Use BaseClass in Globix classes

This commit is contained in:
Jonathan Jenne
2021-12-14 11:40:24 +01:00
parent 2436fd296f
commit a595a75065
5 changed files with 74 additions and 101 deletions

View File

@@ -5,9 +5,10 @@ Imports DigitalData.Modules.Logging
Imports Microsoft.Office.Interop
Public Class ClassFileDrop
Public files_dropped As String()
Private _LOGGER As Logger
Private clsFilehandle As ClassFilehandle
Inherits Base.BaseClass
Public Property files_dropped As List(Of String)
Private ReadOnly FileHandle As ClassFilehandle
Public Class DroppedFile
Public FilePath As String
@@ -18,20 +19,21 @@ Public Class ClassFileDrop
End Enum
End Class
Public Sub New(LogConfig As LogConfig)
_LOGGER = LogConfig.GetLogger()
clsFilehandle = New ClassFilehandle()
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig)
FileHandle = New ClassFilehandle(pLogConfig)
End Sub
Public Function Drop_File(e As DragEventArgs) As Boolean
Try
_LOGGER.Info("Available Drop Formats:")
Logger.Info("Available Drop Formats:")
For Each oFormat As String In e.Data.GetFormats()
_LOGGER.Debug(oFormat)
Logger.Debug(oFormat)
Next
_LOGGER.Info(">> Drop_File")
files_dropped = Nothing
Logger.Info(">> Drop_File")
files_dropped = New List(Of String)
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim MyFiles() As String
Dim i As Integer
@@ -39,10 +41,8 @@ Public Class ClassFileDrop
MyFiles = DirectCast(e.Data.GetData(DataFormats.FileDrop), String())
' Loop through the array and add the files to the list.
For i = 0 To MyFiles.Length - 1
_LOGGER.Info(">> Simple FileDrop - File: " & MyFiles(i))
ReDim Preserve files_dropped(i)
files_dropped(i) = "|DROPFROMFSYSTEM|" & MyFiles(i)
' ListBox1.Items.Add(MyFiles(i))
Logger.Info(">> Simple FileDrop - File: " & MyFiles(i))
files_dropped.Add("|DROPFROMFSYSTEM|" & MyFiles(i))
Next
Return True
ElseIf (e.Data.GetDataPresent("FileGroupDescriptor")) AndAlso (e.Data.GetDataPresent("FileContents")) Then
@@ -66,7 +66,7 @@ Public Class ClassFileDrop
Loop
stmInput.Close()
'Sonderzeichen entfernen
Dim Tempfilename = clsFilehandle.InvalidCharacters(stbFileName.ToString)
Dim Tempfilename = FileHandle.InvalidCharacters(stbFileName.ToString)
Dim anhaenge = e.Data.GetDataPresent("FileContents")
'Dim path As String = "C:\VBProjekte\Dateien"
'// put the zip file into the temp directory
@@ -89,19 +89,21 @@ Public Class ClassFileDrop
Dim fsOutput As IO.FileStream = New IO.FileStream(strOutFile, IO.FileMode.Create) ';
fsOutput.Write(aryFileBytes, 0, aryFileBytes.Length)
fsOutput.Close() ' // close the file
Dim resultVersion = clsFilehandle.Versionierung_Datei(strOutFile)
Dim resultVersion = FileHandle.Versionierung_Datei(strOutFile)
If resultVersion <> "" Then
strOutFile = resultVersion
End If
Dim finTemp As IO.FileInfo = New IO.FileInfo(strOutFile)
'// always good to make sure we actually created the file
If (finTemp.Exists = True) Then
ReDim Preserve files_dropped(0)
files_dropped(0) = "|OUTLOOK_ATTACHMENT|" & strOutFile
_LOGGER.Info(">> Drop an Attachment - File: " & strOutFile)
files_dropped.Add("|OUTLOOK_ATTACHMENT|" & strOutFile)
'ReDim Preserve files_dropped(0)
'files_dropped(0) = "|OUTLOOK_ATTACHMENT|" & strOutFile
Logger.Info(">> Drop an Attachment - File: " & strOutFile)
Return True
Else
_LOGGER.Info(">> Attachment File from Outlook could not be created")
Logger.Info(">> Attachment File from Outlook could not be created")
End If
End If
End If
@@ -113,7 +115,7 @@ Public Class ClassFileDrop
MsgBox("Unexpected error in Initialisieren von Outlook-API:" & vbNewLine & ex.Message & vbNewLine & vbNewLine & "Evtl ist Outlook nicht in der dafür vorgesehenen For")
End Try
_LOGGER.Info(">> Drop of msg")
Logger.Info(">> Drop of msg")
'supports a drop of a Outlook message
Dim myobj As Object
For i As Integer = 1 To oApp.ActiveExplorer.Selection.Count
@@ -129,14 +131,14 @@ Public Class ClassFileDrop
subj = subj.Replace("/", "-")
End If
'Sonderzeichen entfernen
subj = clsFilehandle.InvalidCharacters(subj)
subj = FileHandle.InvalidCharacters(subj)
'hardcode a destination path for testing
Dim strFile As String = IO.Path.Combine(Path.GetTempPath, subj + ".msg")
strFile = strFile.Replace("?", "")
strFile = strFile.Replace("!", "")
strFile = strFile.Replace("%", "")
strFile = strFile.Replace("$", "")
_LOGGER.Info(">> Drop of msg - File:" & strFile)
Logger.Info(">> Drop of msg - File:" & strFile)
Try
myobj.SaveAs(strFile)
Catch ex As Exception
@@ -144,8 +146,9 @@ Public Class ClassFileDrop
Return False
End Try
ReDim Preserve files_dropped(i)
files_dropped(i) = "|OUTLOOK_MESSAGE|" & strFile
'ReDim Preserve files_dropped(i)
'files_dropped(i) = "|OUTLOOK_MESSAGE|" & strFile
files_dropped.Add("|OUTLOOK_MESSAGE|" & strFile)
Next
Return True
'Drop eines Outlook Attachments