MS_07.03.2016
This commit is contained in:
@@ -5,112 +5,131 @@ Public Class ClassDragDrop
|
||||
Public Shared files_dropped As String()
|
||||
Public Shared Function Drop_File(e As DragEventArgs)
|
||||
Try
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> In Drop_File....", False)
|
||||
files_dropped = Nothing
|
||||
Dim oApp As New Outlook.Application
|
||||
Dim sql As String = "DELETE FROM TBPMO_FILES_USER WHERE HANDLE_TYPE <> 'SCAN' AND UPPER(USER_WORK) = UPPER('" & Environment.UserName & "')"
|
||||
ClassDatabase.Execute_non_Query(sql)
|
||||
Try
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> In Drop_File....", False)
|
||||
files_dropped = Nothing
|
||||
|
||||
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> DataFormats.FileDrop", False)
|
||||
Dim MyFiles() As String
|
||||
Dim i As Integer
|
||||
' Assign the files to an array.
|
||||
MyFiles = e.Data.GetData(DataFormats.FileDrop)
|
||||
' Loop through the array and add the files to the list.
|
||||
For i = 0 To MyFiles.Length - 1
|
||||
Dim sql As String = "DELETE FROM TBPMO_FILES_USER WHERE HANDLE_TYPE <> 'SCAN' AND UPPER(USER_WORK) = UPPER('" & Environment.UserName & "')"
|
||||
ClassDatabase.Execute_non_Query(sql)
|
||||
|
||||
ReDim Preserve files_dropped(i)
|
||||
files_dropped(i) = "@DROPFROMFSYSTEM@" & MyFiles(i)
|
||||
' ListBox1.Items.Add(MyFiles(i))
|
||||
Next
|
||||
Return files_dropped
|
||||
End If
|
||||
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> DataFormats.FileDrop", False)
|
||||
Dim MyFiles() As String
|
||||
Dim i As Integer
|
||||
' Assign the files to an array.
|
||||
MyFiles = e.Data.GetData(DataFormats.FileDrop)
|
||||
' Loop through the array and add the files to the list.
|
||||
For i = 0 To MyFiles.Length - 1
|
||||
|
||||
If e.Data.GetDataPresent("FileGroupDescriptor") AndAlso (e.Data.GetDataPresent("FileContents")) Then
|
||||
Console.WriteLine(">> FileGroupDescriptor/FileContents")
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> FileGroupDescriptor/FileContents", False)
|
||||
'// the first step here is to get the stbFileName
|
||||
'// of the attachment and
|
||||
'// build a full-path name so we can store it
|
||||
'// in the temporary folder
|
||||
'//
|
||||
'// set up to obtain the aryFileGroupDescriptor
|
||||
'// and extract the file name
|
||||
Dim stmInput As IO.Stream = CType(e.Data.GetData("FileGroupDescriptor"), IO.Stream)
|
||||
Dim aryFileGroupDescriptor(512) As Byte ' = new byte[512]
|
||||
stmInput.Read(aryFileGroupDescriptor, 0, 512)
|
||||
'// used to build the stbFileName from the aryFileGroupDescriptor block
|
||||
Dim stbFileName As System.Text.StringBuilder = New System.Text.StringBuilder("")
|
||||
'// this trick gets the stbFileName of the passed attached file
|
||||
Dim intCnt As Integer = 76
|
||||
Do While aryFileGroupDescriptor(intCnt) <> 0
|
||||
stbFileName.Append(Convert.ToChar(aryFileGroupDescriptor(intCnt), System.Globalization.CultureInfo.CreateSpecificCulture("de-DE")))
|
||||
intCnt += 1
|
||||
Loop
|
||||
stmInput.Close()
|
||||
ReDim Preserve files_dropped(i)
|
||||
files_dropped(i) = "@DROPFROMFSYSTEM@" & MyFiles(i)
|
||||
' ListBox1.Items.Add(MyFiles(i))
|
||||
Next
|
||||
Return files_dropped
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in DropFile||DataFormats.FileDrop: " & ex.Message, MsgBoxStyle.Critical)
|
||||
ClassLogger.Add("Unexpected Error in DataFormats.FileDrop: " & ex.Message, True)
|
||||
End Try
|
||||
|
||||
Dim anhaenge = e.Data.GetDataPresent("FileContents")
|
||||
'Dim path As String = "C:\VBProjekte\Dateien"
|
||||
'// put the zip file into the temp directory
|
||||
Dim strOutFile As String = Path.GetTempPath() & stbFileName.ToString()
|
||||
'// create the full-path name
|
||||
'//
|
||||
'// Second step: we have the file name.
|
||||
'// Now we need to get the actual raw
|
||||
'// data for the attached file and copy it to disk so we work on it.
|
||||
'//
|
||||
'// get the actual raw file into memory
|
||||
Dim msInput As IO.MemoryStream = CType(e.Data.GetData("FileContents", True), IO.MemoryStream) 'This returns nothing for an Email
|
||||
If msInput Is Nothing = False Then
|
||||
'// allocate enough bytes to hold the raw date
|
||||
Dim aryFileBytes(CType(msInput.Length, Int32)) As Byte
|
||||
'// set starting position at first byte and read in the raw data
|
||||
msInput.Position = 0
|
||||
msInput.Read(aryFileBytes, 0, CType(msInput.Length, Int32))
|
||||
'// create a file and save the raw zip file to it
|
||||
Dim fsOutput As IO.FileStream = New IO.FileStream(strOutFile, IO.FileMode.Create) ';
|
||||
fsOutput.Write(aryFileBytes, 0, aryFileBytes.Length)
|
||||
fsOutput.Close() ' // close the file
|
||||
Try
|
||||
If e.Data.GetDataPresent("FileGroupDescriptor") AndAlso (e.Data.GetDataPresent("FileContents")) Then
|
||||
Console.WriteLine(">> FileGroupDescriptor/FileContents")
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> FileGroupDescriptor/FileContents", False)
|
||||
'// the first step here is to get the stbFileName
|
||||
'// of the attachment and
|
||||
'// build a full-path name so we can store it
|
||||
'// in the temporary folder
|
||||
'//
|
||||
'// set up to obtain the aryFileGroupDescriptor
|
||||
'// and extract the file name
|
||||
Dim stmInput As IO.Stream = CType(e.Data.GetData("FileGroupDescriptor"), IO.Stream)
|
||||
Dim aryFileGroupDescriptor(512) As Byte ' = new byte[512]
|
||||
stmInput.Read(aryFileGroupDescriptor, 0, 512)
|
||||
'// used to build the stbFileName from the aryFileGroupDescriptor block
|
||||
Dim stbFileName As System.Text.StringBuilder = New System.Text.StringBuilder("")
|
||||
'// this trick gets the stbFileName of the passed attached file
|
||||
Dim intCnt As Integer = 76
|
||||
Do While aryFileGroupDescriptor(intCnt) <> 0
|
||||
stbFileName.Append(Convert.ToChar(aryFileGroupDescriptor(intCnt), System.Globalization.CultureInfo.CreateSpecificCulture("de-DE")))
|
||||
intCnt += 1
|
||||
Loop
|
||||
stmInput.Close()
|
||||
|
||||
Dim finTemp As IO.FileInfo = New IO.FileInfo(strOutFile)
|
||||
'// always good to make sure we actually created the file
|
||||
If (finTemp.Exists = True) Then
|
||||
'MsgBox("Attachment File from Outlook created:" & vbNewLine & strOutFile)
|
||||
' lblFile.Text += "Attachment File from Outlook created" + Environment.NewLine
|
||||
Console.WriteLine(">> Drop of a mailattachment - File")
|
||||
ReDim Preserve files_dropped(0)
|
||||
files_dropped(0) = "@OUTLOOK_ATTMNT@" & strOutFile
|
||||
TEMP_FILES.Add(strOutFile)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Drop an Attachment - File: " & strOutFile, False)
|
||||
Return files_dropped
|
||||
Else
|
||||
ClassLogger.Add(">> Attachment File from Outlook could not be created", False)
|
||||
'lblFile.Text += "Attachment File from Outlook could not be created" + Environment.NewLine
|
||||
Dim anhaenge = e.Data.GetDataPresent("FileContents")
|
||||
'Dim path As String = "C:\VBProjekte\Dateien"
|
||||
'// put the zip file into the temp directory
|
||||
Dim strOutFile As String = Path.GetTempPath() & stbFileName.ToString()
|
||||
'// create the full-path name
|
||||
'//
|
||||
'// Second step: we have the file name.
|
||||
'// Now we need to get the actual raw
|
||||
'// data for the attached file and copy it to disk so we work on it.
|
||||
'//
|
||||
'// get the actual raw file into memory
|
||||
Dim msInput As IO.MemoryStream = CType(e.Data.GetData("FileContents", True), IO.MemoryStream) 'This returns nothing for an Email
|
||||
If msInput Is Nothing = False Then
|
||||
'// allocate enough bytes to hold the raw date
|
||||
Dim aryFileBytes(CType(msInput.Length, Int32)) As Byte
|
||||
'// set starting position at first byte and read in the raw data
|
||||
msInput.Position = 0
|
||||
msInput.Read(aryFileBytes, 0, CType(msInput.Length, Int32))
|
||||
'// create a file and save the raw zip file to it
|
||||
Dim fsOutput As IO.FileStream = New IO.FileStream(strOutFile, IO.FileMode.Create) ';
|
||||
fsOutput.Write(aryFileBytes, 0, aryFileBytes.Length)
|
||||
fsOutput.Close() ' // close the file
|
||||
|
||||
Dim finTemp As IO.FileInfo = New IO.FileInfo(strOutFile)
|
||||
'// always good to make sure we actually created the file
|
||||
If (finTemp.Exists = True) Then
|
||||
'MsgBox("Attachment File from Outlook created:" & vbNewLine & strOutFile)
|
||||
' lblFile.Text += "Attachment File from Outlook created" + Environment.NewLine
|
||||
Console.WriteLine(">> Drop of a mailattachment - File")
|
||||
ReDim Preserve files_dropped(0)
|
||||
files_dropped(0) = "@OUTLOOK_ATTMNT@" & strOutFile
|
||||
TEMP_FILES.Add(strOutFile)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Drop an Attachment - File: " & strOutFile, False)
|
||||
Return files_dropped
|
||||
Else
|
||||
ClassLogger.Add(">> Attachment File from Outlook could not be created", False)
|
||||
'lblFile.Text += "Attachment File from Outlook could not be created" + Environment.NewLine
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in DropFile||Attachment: " & ex.Message, MsgBoxStyle.Critical)
|
||||
ClassLogger.Add("Unexpected Error in Drop Attachment: " & ex.Message, True)
|
||||
End Try
|
||||
|
||||
If e.Data.GetDataPresent("FileGroupDescriptor") Then
|
||||
Console.WriteLine(">> FileGroupDescriptor")
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Drop of OutlookMessage", False)
|
||||
'supports a drop of a Outlook message
|
||||
Dim myobj As Object
|
||||
Try
|
||||
If e.Data.GetDataPresent("FileGroupDescriptor") Then
|
||||
Console.WriteLine(">> FileGroupDescriptor")
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Drop of OutlookMessage", False)
|
||||
Dim oApp As New Outlook.Application
|
||||
|
||||
'supports a drop of a Outlook message
|
||||
Dim myobj As Object
|
||||
|
||||
For i As Integer = 1 To oApp.ActiveExplorer.Selection.Count
|
||||
myobj = oApp.ActiveExplorer.Selection.Item(i)
|
||||
|
||||
'hardcode a destination path for testing
|
||||
Dim strFile As String = IO.Path.Combine(Path.GetTempPath, (myobj.Subject + ".msg").Replace(":", ""))
|
||||
myobj.SaveAs(strFile)
|
||||
TEMP_FILES.Add(strFile)
|
||||
ReDim Preserve files_dropped(i)
|
||||
files_dropped(i) = "@OUTLOOKMESSAGE@" & strFile
|
||||
Next
|
||||
Return files_dropped
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Unexpected Error in DropFile||OutlookMessage: " & ex.Message, MsgBoxStyle.Critical)
|
||||
ClassLogger.Add("Unexpected Error in Drop OutlookMessage: " & ex.Message, True)
|
||||
End Try
|
||||
|
||||
For i As Integer = 1 To oApp.ActiveExplorer.Selection.Count
|
||||
myobj = oApp.ActiveExplorer.Selection.Item(i)
|
||||
|
||||
'hardcode a destination path for testing
|
||||
Dim strFile As String = IO.Path.Combine(Path.GetTempPath, (myobj.Subject + ".msg").Replace(":", ""))
|
||||
myobj.SaveAs(strFile)
|
||||
TEMP_FILES.Add(strFile)
|
||||
ReDim Preserve files_dropped(i)
|
||||
files_dropped(i) = "@OUTLOOKMESSAGE@" & strFile
|
||||
Next
|
||||
Return files_dropped
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in Drop_File: " & ex.Message, MsgBoxStyle.Critical)
|
||||
MsgBox("Unexpected Error in Drop_File: " & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
|
||||
Dim Wert As String = CType(e.Data.GetData(DataFormats.StringFormat), Object)
|
||||
|
||||
Reference in New Issue
Block a user