neu
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
'Imports iTextSharp.text.pdf
|
||||
'Imports iTextSharp.text
|
||||
Imports System.IO
|
||||
Imports Spire.Pdf
|
||||
'Imports GrapeCity.Documents.Pdf
|
||||
|
||||
Imports Spire.Pdf
|
||||
'Imports Spire.Pdf
|
||||
|
||||
|
||||
|
||||
Public Class frmSendungAnhangImport
|
||||
|
||||
@@ -69,7 +72,7 @@ Public Class frmSendungAnhangImport
|
||||
Sub initElement(USRCNTL As usrCntlSendungAnhangElement)
|
||||
AddHandler USRCNTL.ME_CLICK, Sub(STRG_PRESSED)
|
||||
' If BrowserLoaded Then
|
||||
|
||||
|
||||
|
||||
If Not STRG_PRESSED Then
|
||||
|
||||
@@ -117,24 +120,37 @@ Public Class frmSendungAnhangImport
|
||||
End Sub
|
||||
|
||||
Sub initLocationViewer(loc, typ)
|
||||
PdfViewer.CloseDocument()
|
||||
WebBrowser.Navigate("")
|
||||
If typ = "PDF" Then
|
||||
If cbxAlternativePDFAnsicht.Checked Then
|
||||
|
||||
Try
|
||||
|
||||
|
||||
'If PdfViewer IsNot Nothing AndAlso PdfViewer.IsDocumentLoaded Then
|
||||
' PdfViewer.CloseDocument()
|
||||
'End If
|
||||
PdfViewer.Visible = False
|
||||
WebBrowser.Visible = False
|
||||
|
||||
WebBrowser.Navigate("")
|
||||
If typ = "PDF" Then
|
||||
If cbxAlternativePDFAnsicht.Checked Then
|
||||
PdfViewer.Visible = False
|
||||
WebBrowser.Visible = (loc <> "")
|
||||
WebBrowser.Navigate(loc)
|
||||
Else
|
||||
WebBrowser.Visible = False
|
||||
PdfViewer.Visible = (loc <> "")
|
||||
PdfViewer.LoadFromFile(loc)
|
||||
End If
|
||||
ElseIf typ = "BILD" Then
|
||||
PdfViewer.Visible = False
|
||||
WebBrowser.Visible = (loc <> "")
|
||||
WebBrowser.Navigate(loc)
|
||||
Else
|
||||
WebBrowser.Visible = False
|
||||
PdfViewer.Visible = (loc <> "")
|
||||
PdfViewer.LoadFromFile(loc)
|
||||
End If
|
||||
ElseIf typ = "BILD" Then
|
||||
PdfViewer.Visible = False
|
||||
WebBrowser.Visible = (loc <> "")
|
||||
WebBrowser.Navigate(loc)
|
||||
End If
|
||||
Button5.Visible = PdfViewer.Visible
|
||||
Button5.Visible = PdfViewer.Visible
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & ex.StackTrace)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Function getAcitvePnl() As FlowLayoutPanel
|
||||
@@ -1313,7 +1329,7 @@ Public Class frmSendungAnhangImport
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub addData_SendungAnhang(Path)
|
||||
Public Function addData_SendungAnhang(Path, Optional addFlpnl = True) As Integer
|
||||
|
||||
|
||||
Dim fi As New FileInfo(Path)
|
||||
@@ -1325,10 +1341,11 @@ Public Class frmSendungAnhangImport
|
||||
Dim Typ = ""
|
||||
If getFileTypeValid(fi.Extension.Replace(".", ""), Typ) Then
|
||||
If saveToDS(AvisoId, fi.Name, Path, "", Typ, da_id, anhId, destPath) Then
|
||||
addUsrcnlToPnl(destPath, da_id, anhId, filename, Typ)
|
||||
If addFlpnl Then addUsrcnlToPnl(destPath, da_id, anhId, filename, Typ)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
End If
|
||||
Return anhId
|
||||
End Function
|
||||
|
||||
Public Shared Function getFileTypeValid(extension, ByRef Typ) As Boolean
|
||||
Select Case extension.ToString.Replace(".", "").ToUpper
|
||||
@@ -1727,6 +1744,160 @@ Public Class frmSendungAnhangImport
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub flpnlAviso_DragDrop(sender As Object, e As DragEventArgs) Handles flpnlAviso.DragDrop
|
||||
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
|
||||
|
||||
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
|
||||
For Each path In files
|
||||
addData_SendungAnhang(path)
|
||||
Next
|
||||
|
||||
ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then
|
||||
Dim FilePath = EmAilAttach(e)
|
||||
If FilePath <> "" Then
|
||||
addData_SendungAnhang(FilePath)
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
Private Sub flpnlSendungen_DragDrop(sender As Object, e As DragEventArgs) Handles flpnlSendungen.DragDrop
|
||||
If cboSendungen._value = "" Then Exit Sub
|
||||
If cboSendungen._value = "-1" Then Exit Sub
|
||||
|
||||
Try
|
||||
Dim added = False
|
||||
|
||||
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
|
||||
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
|
||||
For Each path In files
|
||||
|
||||
Dim anhID = addData_SendungAnhang(path, False)
|
||||
If anhID > 0 Then
|
||||
added = True
|
||||
Dim ANH = New VERAG_PROG_ALLGEMEIN.cAvisoAnhaenge(anhID)
|
||||
|
||||
Dim f As New frmSendungAnhangUmbenennenUmkateg(ANH.anh_Name, ANH.anh_Art)
|
||||
If f.ShowDialog = DialogResult.OK Then
|
||||
ANH.anh_SendungsId = cboSendungen._value
|
||||
ANH.anh_Name = f.txtBezeichnung.Text
|
||||
ANH.anh_Art = f.cboArt._value
|
||||
ANH.SAVE() 'Eintrag wird überschreiben
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
ElseIf e.Data.GetDataPresent("FileGroupDescriptor") Then
|
||||
Dim FilePath = EmAilAttach(e)
|
||||
If FilePath <> "" Then
|
||||
|
||||
Dim anhID = addData_SendungAnhang(FilePath, False)
|
||||
If anhID > 0 Then
|
||||
added = True
|
||||
Dim ANH = New VERAG_PROG_ALLGEMEIN.cAvisoAnhaenge(anhID)
|
||||
|
||||
Dim f As New frmSendungAnhangUmbenennenUmkateg(ANH.anh_Name, ANH.anh_Art)
|
||||
If f.ShowDialog = DialogResult.OK Then
|
||||
ANH.anh_SendungsId = cboSendungen._value
|
||||
ANH.anh_Name = f.txtBezeichnung.Text
|
||||
ANH.anh_Art = f.cboArt._value
|
||||
ANH.SAVE() 'Eintrag wird überschreiben
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
|
||||
If added Then
|
||||
|
||||
initFlpANH_LIST()
|
||||
' initLocationViewer(ANH.FILE_PATH, )
|
||||
'If flpnlAviso.Controls.Count > 0 Then
|
||||
' DirectCast(flpnlAviso.Controls(0), usrCntlSendungAnhangElement).CLICK_Me()
|
||||
'End If
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & ex.StackTrace)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Function EmAilAttach(e As DragEventArgs) As String
|
||||
Try
|
||||
|
||||
' We have a embedded file. First lets try to get the file name out of memory
|
||||
Dim theStream As IO.Stream = CType(e.Data.GetData("FileGroupDescriptor"), IO.Stream)
|
||||
Dim fileGroupDescriptor(512) As Byte
|
||||
theStream.Read(fileGroupDescriptor, 0, 512)
|
||||
Dim fileName As System.Text.StringBuilder = New System.Text.StringBuilder("")
|
||||
Dim i As Integer = 76
|
||||
|
||||
While Not (fileGroupDescriptor(i) = 0)
|
||||
fileName.Append(Convert.ToChar(fileGroupDescriptor(i)))
|
||||
System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1)
|
||||
End While
|
||||
|
||||
theStream.Close()
|
||||
' We should have the file name or if its an email, the subject line. Create our temp file based on the temp path and this info
|
||||
Dim myTempFile As String = IO.Path.GetTempPath & fileName.ToString
|
||||
' Look to see if this is a email message. If so save that temporarily and get the temp file.
|
||||
If InStr(myTempFile, ".msg") > 0 Then
|
||||
Dim objOL As New Microsoft.Office.Interop.Outlook.Application
|
||||
Dim objMI As Microsoft.Office.Interop.Outlook.MailItem
|
||||
If objOL.ActiveExplorer.Selection.Count > 1 Then
|
||||
MsgBox("Es kann nur ein Element übertagen werden.", MsgBoxStyle.OkOnly Or MsgBoxStyle.Information, "Ein Element pro Vorgang")
|
||||
End If
|
||||
For Each objMI In objOL.ActiveExplorer.Selection()
|
||||
objMI.SaveAs(myTempFile)
|
||||
Exit For
|
||||
Next
|
||||
objOL = Nothing
|
||||
objMI = Nothing
|
||||
Else
|
||||
' If its a attachment we need to pull the file itself out of memory
|
||||
Dim ms As IO.MemoryStream = CType(e.Data.GetData("FileContents", True), IO.MemoryStream)
|
||||
Dim FileBytes(CInt(ms.Length)) As Byte
|
||||
' read the raw data into our variable
|
||||
ms.Position = 0
|
||||
ms.Read(FileBytes, 0, CInt(ms.Length))
|
||||
ms.Close()
|
||||
' save the raw data into our temp file
|
||||
Dim fs As IO.FileStream = New IO.FileStream(myTempFile, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
|
||||
fs.Write(FileBytes, 0, FileBytes.Length)
|
||||
fs.Close()
|
||||
End If
|
||||
' Make sure we have a actual file and also if we do make sure we erase it when done
|
||||
If IO.File.Exists(myTempFile) Then
|
||||
' Assign the file name to the add dialog
|
||||
EmAilAttach = myTempFile
|
||||
Else
|
||||
EmAilAttach = String.Empty
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message & ex.StackTrace)
|
||||
EmAilAttach = String.Empty
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Private Sub flpnlAviso_DragEnter(sender As Object, e As DragEventArgs) Handles flpnlAviso.DragEnter
|
||||
e.Effect = DragDropEffects.All
|
||||
End Sub
|
||||
|
||||
Private Sub flpnlSnd_DragEnter(sender As Object, e As DragEventArgs) Handles flpnlSendungen.DragEnter
|
||||
e.Effect = DragDropEffects.All
|
||||
End Sub
|
||||
'Private Sub flpnlSendungen_Paint(sender As Object, e As PaintEventArgs) Handles flpnlSendungen.Paint
|
||||
' Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
|
||||
' For Each path In files
|
||||
' addData_SendungAnhang(path)
|
||||
' Next
|
||||
'End Sub
|
||||
|
||||
'Private Sub txtBezeichnung_GotFocus(sender As Object, e As EventArgs) Handles txtBezeichnung.GotFocus
|
||||
' txtBezeichnung.SelectAll()
|
||||
'End Sub
|
||||
|
||||
Reference in New Issue
Block a user