From 0074a9c7485b3cecec46eb20966b2c146e96bfd9 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Fri, 11 Oct 2024 12:11:40 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Bugfix=20=C3=96ffnen=20von=20Msg=20in=20Anh?= =?UTF-8?q?=C3=A4nge=20(Sendungsdetails).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aviso/My Project/AssemblyInfo.vb | 4 ++-- Aviso/frmSendungsdetailsNEU.vb | 13 +++++++++---- Aviso/usrcntlAktDetailsATILLANeu.vb | 10 +++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Aviso/My Project/AssemblyInfo.vb b/Aviso/My Project/AssemblyInfo.vb index d6b263e..6c780f7 100644 --- a/Aviso/My Project/AssemblyInfo.vb +++ b/Aviso/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/Aviso/frmSendungsdetailsNEU.vb b/Aviso/frmSendungsdetailsNEU.vb index 768cea8..5ac3a16 100644 --- a/Aviso/frmSendungsdetailsNEU.vb +++ b/Aviso/frmSendungsdetailsNEU.vb @@ -4154,13 +4154,18 @@ Public Class frmSendungsdetailsNEU Dim docPath = VERAG_PROG_ALLGEMEIN.cDATENSERVER.GET_PDFPath_BY_DocID(dgvAnhang.SelectedRows(0).Cells("anh_docId").Value) - If Not IO.File.Exists(docPath) Then + If Not File.Exists(docPath) Then MsgBox("Die Datei existiert nicht!") Else If docPath.ToString.ToLower.EndsWith(".msg") Then ' MSG - Mails --> lokale Kopie, sonst Fehler (bereits von Benutzer soUndSo geöffnet) - Dim docPathTMP = VERAG_PROG_ALLGEMEIN.cFormularManager.getTMPPath_MSG() - System.IO.File.Copy(docPath, docPathTMP) - Process.Start(docPathTMP) + Try + Dim docPathTMP = VERAG_PROG_ALLGEMEIN.cFormularManager.getTMPPath_MSG() + File.Copy(docPath, docPathTMP) + Process.Start(docPathTMP) + Catch ex As Exception + 'wenn fehler, soll versucht werden, das oríginal zu öffnen. + Process.Start(docPath) + End Try Else Process.Start(docPath) End If diff --git a/Aviso/usrcntlAktDetailsATILLANeu.vb b/Aviso/usrcntlAktDetailsATILLANeu.vb index 3445685..972e0e2 100644 --- a/Aviso/usrcntlAktDetailsATILLANeu.vb +++ b/Aviso/usrcntlAktDetailsATILLANeu.vb @@ -606,9 +606,13 @@ Public Class usrcntlAktDetailsATILLANeu MsgBox("Die Datei existiert nicht!") Else If docPath.ToString.ToLower.EndsWith(".msg") Then ' MSG - Mails --> lokale Kopie, sonst Fehler (bereits von Benutzer soUndSo geöffnet) - Dim docPathTMP = VERAG_PROG_ALLGEMEIN.cFormularManager.getTMPPath_MSG() - File.Copy(docPath, docPathTMP) - Process.Start(docPathTMP) + Try + Dim docPathTMP = VERAG_PROG_ALLGEMEIN.cFormularManager.getTMPPath_MSG() + File.Copy(docPath, docPathTMP) + Process.Start(docPathTMP) + Catch ex As Exception + Process.Start(docPath) + End Try Else Process.Start(docPath) End If From aea776a71f3d4e3f0ffd614bb7fe1221ff7daca2 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Fri, 11 Oct 2024 13:19:04 +0200 Subject: [PATCH 2/2] Anhangsimport - Bugfix --- Aviso/Anhänge/frmSendungAnhangImport.vb | 47 +++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/Aviso/Anhänge/frmSendungAnhangImport.vb b/Aviso/Anhänge/frmSendungAnhangImport.vb index 3711af0..fac6788 100644 --- a/Aviso/Anhänge/frmSendungAnhangImport.vb +++ b/Aviso/Anhänge/frmSendungAnhangImport.vb @@ -1,16 +1,10 @@  -'Imports iTextSharp.text.pdf -'Imports iTextSharp.text +Imports itextsharp.text Imports System.IO Imports Spire.Pdf -Imports Spire.Pdf.Conversion Imports Spire.Pdf.Conversion.Compression Imports Spire.Pdf.Exporting Imports VERAG_PROG_ALLGEMEIN -'Imports GrapeCity.Documents.Pdf - -'Imports Spire.Pdf - Public Class frmSendungAnhangImport @@ -148,9 +142,16 @@ Public Class frmSendungAnhangImport WebBrowser.Visible = (loc <> "") WebBrowser.Navigate(loc) Else + WebBrowser.Visible = False PdfViewer.Visible = (loc <> "") - PdfViewer.LoadFromFile(loc) + + Dim data = File.ReadAllBytes(loc) + Dim pdfStream = New MemoryStream(data) + PdfViewer.LoadFromStream(pdfStream) + + 'NOT WORKING + 'PdfViewer.LoadFromFile(loc) NOT WORKING End If ElseIf typ = "BILD" Then PdfViewer.Visible = False @@ -494,7 +495,7 @@ Public Class frmSendungAnhangImport Try PagesLeft = 0 - Dim pdf As New PdfDocument() + Dim pdf As New Spire.Pdf.PdfDocument() pdf.LoadFromFile(sourceFile) ' Dim r As PdfReader = New PdfReader(sourceFile) Dim pagesToKeep As New List(Of Integer) @@ -511,7 +512,7 @@ Public Class frmSendungAnhangImport Next - Dim pdf1 As New PdfDocument() + Dim pdf1 As New Spire.Pdf.PdfDocument() Dim page As PdfPageBase For Each p In pagesToKeep @@ -580,10 +581,10 @@ Public Class frmSendungAnhangImport - Dim pdf As New PdfDocument() + Dim pdf As New Spire.Pdf.PdfDocument() pdf.LoadFromFile(sourceFile) - Dim pdf1 As New PdfDocument() + Dim pdf1 As New Spire.Pdf.PdfDocument() Dim page As PdfPageBase For Each p In pagesToExtract @@ -658,7 +659,7 @@ Public Class frmSendungAnhangImport Dim Reader As New iTextSharp.text.pdf.PdfReader(SourceFile) If Not TargetFile.ToLower.EndsWith(".pdf") Then TargetFile = TargetFile & ".pdf" Dim srcDoc As New iTextSharp.text.Document() 'Reader.GetPageSizeWithRotation(0)) - Dim PdfCopyProvider As New iTextSharp.text.pdf.PdfCopy(srcDoc, New System.IO.FileStream(TargetFile, System.IO.FileMode.Create)) + Dim PdfCopyProvider As New itextsharp.text.pdf.PdfCopy(srcDoc, New FileStream(TargetFile, System.IO.FileMode.Create)) PdfCopyProvider.SetFullCompression() srcDoc.Open() For Each p In pagesToExtract @@ -1083,7 +1084,7 @@ Public Class frmSendungAnhangImport compressor.CompressToFile(DS.GET_TOP1_PATH) 'Load the pdf document - Dim doc As New PdfDocument() + Dim doc As New Spire.Pdf.PdfDocument() doc.LoadFromFile(DS.GET_TOP1_PATH) 'Compress the content in document @@ -1107,7 +1108,7 @@ Public Class frmSendungAnhangImport End If Return False End Function - Private Shared Sub CompressContent(ByVal doc As PdfDocument) + Private Shared Sub CompressContent(ByVal doc As Spire.Pdf.PdfDocument) 'Disable the incremental update doc.FileInfo.IncrementalUpdate = False @@ -1115,7 +1116,7 @@ Public Class frmSendungAnhangImport doc.CompressionLevel = PdfCompressionLevel.Best End Sub - Private Shared Sub CompressImage(ByVal doc As PdfDocument) + Private Shared Sub CompressImage(ByVal doc As Spire.Pdf.PdfDocument) Try 'Disable the incremental update doc.FileInfo.IncrementalUpdate = False @@ -1625,7 +1626,7 @@ Public Class frmSendungAnhangImport ' Dim F_listItem As String = Path.Combine("c:\mynewpath", Path.GetFileName(s)) ' File.Copy(s, newFile) ' MsgBox(s) - If IO.File.Exists(s) Then + If System.IO.File.Exists(s) Then Dim fi As New FileInfo(s) Dim filename = fi.Name @@ -1827,7 +1828,7 @@ Public Class frmSendungAnhangImport If u.FILE_TYPE <> "PDF" Then Exit Sub ' Dim fi As New FileInfo(u.FILE_PATH) - Dim pdf As New PdfDocument() + Dim pdf As New Spire.Pdf.PdfDocument() pdf.LoadFromFile(u.FILE_PATH) For Each p In pdf.Pages txtSeiten.Text = "1" @@ -2061,7 +2062,7 @@ Public Class frmSendungAnhangImport 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 theStream As System.IO.Stream = CType(e.Data.GetData("FileGroupDescriptor"), System.IO.Stream) Dim fileGroupDescriptor(512) As Byte theStream.Read(fileGroupDescriptor, 0, 512) Dim fileName As System.Text.StringBuilder = New System.Text.StringBuilder("") @@ -2074,7 +2075,7 @@ Public Class frmSendungAnhangImport 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 & VERAG_PROG_ALLGEMEIN.cDATENSERVER.replaceInvalidCahr(fileName.ToString) + Dim myTempFile As String = System.IO.Path.GetTempPath & VERAG_PROG_ALLGEMEIN.cDATENSERVER.replaceInvalidCahr(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 @@ -2091,19 +2092,19 @@ Public Class frmSendungAnhangImport 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 ms As System.IO.MemoryStream = CType(e.Data.GetData("FileContents", True), System.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) + Dim fs As System.IO.FileStream = New System.IO.FileStream(myTempFile, System.IO.FileMode.OpenOrCreate, System.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 + If System.IO.File.Exists(myTempFile) Then ' Assign the file name to the add dialog EmAilAttach = myTempFile Else