Windows: Add extensive logging for FileDrop

This commit is contained in:
Jonathan Jenne 2022-02-28 13:00:10 +01:00
parent 35116d4b8b
commit bdb8127a51

View File

@ -54,7 +54,11 @@ Partial Public Class FileDrop
End Function
Public Function GetFileFormat(pEvent As DragEventArgs) As FileFormat
Logger.Debug("Determining FileFormat")
If IsThunderbird(pEvent) Then
Logger.Debug("File is a Thunderbird File")
If IsThunderbirdAttachment(pEvent) Then
Return FileFormat.ThunderbirdAttachment
@ -67,6 +71,8 @@ Partial Public Class FileDrop
End If
If IsOutlook(pEvent) Then
Logger.Debug("File is an Outlook File")
If IsOutlookAttachment(pEvent) Then
Return FileFormat.OutlookAttachment
@ -79,6 +85,8 @@ Partial Public Class FileDrop
End If
If IsNormalFile(pEvent) Then
Logger.Debug("File is a normal File")
Return FileFormat.LocalFile
Else
@ -88,7 +96,13 @@ Partial Public Class FileDrop
Public Function GetFiles(pEvent As DragEventArgs) As List(Of DroppedFile)
Try
Dim oFormats As List(Of String) = GetFileFormats(pEvent)
Dim oFormatString = String.Join(", ", oFormats)
Logger.Debug("Available Formats: [{0}]", oFormatString)
Dim oFormat = GetFileFormat(pEvent)
Logger.Debug("Format: [{0}]", oFormat.ToString)
Dim oFiles As New List(Of DroppedFile)
Select Case oFormat
@ -115,9 +129,12 @@ Partial Public Class FileDrop
End Select
Logger.Debug("Handled [{0}] dropped files.", oFiles.Count)
Return oFiles
Catch ex As Exception
Logger.Warn("Error while handling dropped files.")
Logger.Error(ex)
Return Nothing
@ -165,10 +182,15 @@ Partial Public Class FileDrop
End While
End Using
Return oBuilder.ToString
Dim oFileName As String = oBuilder.ToString
Logger.Debug("Outlook filename is [{0}]", oFileName)
Return oFileName
End Function
Private Function GetOutlookFileContents_FromDragEvent(pEvent As DragEventArgs) As List(Of Byte())
Logger.Debug("Getting file contents")
Using oStream As IO.MemoryStream = pEvent.Data.GetData("FileContents", True)
If oStream Is Nothing Then
Return Nothing
@ -185,6 +207,9 @@ Partial Public Class FileDrop
End Function
Private Function GetOutlookFileContents_FromInterop(pEvent As DragEventArgs) As List(Of Byte())
Logger.Debug("Getting file contents")
Logger.Debug("Creating Outlook Application")
Dim oApp As Outlook.Application
Try
oApp = New Outlook.Application()
@ -197,6 +222,8 @@ Partial Public Class FileDrop
Dim oMailItem As Outlook.MailItem
For oIndex As Integer = 1 To oApp.ActiveExplorer.Selection.Count
Try
Logger.Debug("Fetching mail [{0}]")
oMailItem = oApp.ActiveExplorer.Selection.Item(oIndex)
Dim oSubject As String = ConvertTextToSlug(oMailItem.Subject)
@ -229,8 +256,11 @@ Partial Public Class FileDrop
Return oResults
Catch ex As Exception
Logger.Error(ex)
End Try
Next
Return Nothing
End Function
Public Function GetFormat(pEvent As DragEventArgs, pFormat As String, pAutoConvert As Boolean) As Object