From 633ab61c6f430fde32dfb228fb5c71f42ea771c6 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Thu, 29 Aug 2024 09:32:08 +0200 Subject: [PATCH] =?UTF-8?q?Datenserver=20Druckertest=20aus=20Performancegr?= =?UTF-8?q?=C3=BCnden=20deaktiviert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DATENSERVER/cDATENSERVER.vb | 254 ++++++++++-------- 1 file changed, 143 insertions(+), 111 deletions(-) diff --git a/VERAG_PROG_ALLGEMEIN/DATENSERVER/cDATENSERVER.vb b/VERAG_PROG_ALLGEMEIN/DATENSERVER/cDATENSERVER.vb index 49dfd472..4547dfe6 100644 --- a/VERAG_PROG_ALLGEMEIN/DATENSERVER/cDATENSERVER.vb +++ b/VERAG_PROG_ALLGEMEIN/DATENSERVER/cDATENSERVER.vb @@ -259,38 +259,44 @@ Public Class cDATENSERVER End Function Public Shared Function replaceInvalidCahr(ByRef s As String) As String + Try - s = s.Replace("İ", "I") - s = s.Replace("İ", "I") - s = s.Replace("ı", "i") - s = s.Replace("€", "E") - s = s.Replace(",", ".") - s = s.Replace("'", "") - s = s.Replace("´", "") - s = s.Replace("^", "") ' Es gibt Ü, die so geschreiben werden: Ü .... - s = s.Replace("Ì", ".") - s = s.Replace("Ü", "U") ' .... das zum Beispiel - s = s.Replace("А", "A") 'cyrillic A - s = s.Replace("Р", "P") 'cyrillic P - s = s.Replace("С", "C") 'cyrillic C - s = s.Replace("Т", "T") 'cyrillic T - s = s.Replace("Ѕ", "S") 'cyrillic S - s = s.Replace("І", "I") 'cyrillic I - s = s.Replace("Ј", "J") 'cyrillic J - s = s.Replace("Е", "E") 'cyrillic E - s = s.Replace("?", "") + s = s.Replace("İ", "I") + s = s.Replace("İ", "I") + s = s.Replace("ı", "i") + s = s.Replace("€", "E") + s = s.Replace(",", ".") + s = s.Replace("'", "") + s = s.Replace("´", "") + s = s.Replace("^", "") ' Es gibt Ü, die so geschreiben werden: Ü .... + s = s.Replace("Ì", ".") + s = s.Replace("Ü", "U") ' .... das zum Beispiel - Dim temp = s - s = Regex.Replace(s, "[бБвгГдДёЁжЖзЗиИйЙкКлЛмнпПртфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяЯ]", "").Replace("""", "") 'REMOVE cyrillic letters - 'If s = "" Then s = temp + s = s.Replace("А", "A") 'cyrillic A + s = s.Replace("Р", "P") 'cyrillic P + s = s.Replace("С", "C") 'cyrillic C + s = s.Replace("Т", "T") 'cyrillic T + s = s.Replace("Ѕ", "S") 'cyrillic S + s = s.Replace("І", "I") 'cyrillic I + s = s.Replace("Ј", "J") 'cyrillic J + s = s.Replace("Е", "E") 'cyrillic E + s = s.Replace("?", "") - Dim tempBytes = System.Text.Encoding.GetEncoding("ISO-8859-8").GetBytes(s) - s = System.Text.Encoding.UTF8.GetString(tempBytes) - s = s.Replace("�", "") - s = s.Replace("?", "") + Dim temp = s + s = Regex.Replace(s, "[бБвгГдДёЁжЖзЗиИйЙкКлЛмнпПртфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяЯ]", "").Replace("""", "") 'REMOVE cyrillic letters + 'If s = "" Then s = temp - Return s + Dim tempBytes = System.Text.Encoding.GetEncoding("ISO-8859-8").GetBytes(s) + s = System.Text.Encoding.UTF8.GetString(tempBytes) + s = s.Replace("�", "") + s = s.Replace("?", "") + + Return s + + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try End Function Public Function uploadDataToDATENSERVER(srcPath, Optional bezeichnung = "", Optional endung = "", Optional allowMsg = True, Optional coll_archiv = False, Optional delteFromFileSystem = True, Optional enableOverwritting = False) As Boolean @@ -479,7 +485,7 @@ Public Class cDATENSERVER End Using Return False Catch ex As Exception - MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try Return da_id End Function @@ -578,7 +584,7 @@ Public Class cDATENSERVER 'SQL.doSQL("DELETE FROM [tblDatenarchiv_Collection] WHERE [coll_daId]=" & id & " ", "FMZOLL") End If Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) Return False End Try Return True @@ -1059,7 +1065,7 @@ Public Class cFormularManager image.SetAbsolutePosition(bc.x, pagesize.Top - bc.y) over.AddImage(image) Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try Next End If @@ -1079,7 +1085,7 @@ Public Class cFormularManager pdf.Close() Return destPath Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) Return "" End Try @@ -1248,8 +1254,99 @@ Public Class cFormularManager Public Shared Sub PrintViaSpirePDF(PDFFile As String(), Optional printerName As String = "") + + '---------------------WEGEN PERFORMANCE-PROBLEMEN DEAKTIVIERT! + 'Try + ' Dim printerPaperSizeA4 As Boolean = False + ' If printerName = "" Then + ' Dim sPrinters As ArrayList + + ' If VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_LIST IsNot Nothing Then + ' sPrinters = VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_LIST + ' Else + ' sPrinters = New ArrayList + ' For Each sPrinter As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters + ' sPrinters.Add(sPrinter) + ' Next + ' End If + + ' If VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_STANDARD <> String.Empty Then + + ' For Each printer In sPrinters + + ' If printer.ToString.ToLower.Contains(VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_STANDARD.ToLower) Then + ' printerName = printer + ' For Each installedPrinter In System.Drawing.Printing.PrinterSettings.InstalledPrinters + ' If printerName = installedPrinter.ToString Then + ' Dim currentInstalledPrinter As New System.Drawing.Printing.PrinterSettings + ' currentInstalledPrinter.PrinterName = printerName + ' For Each sizes In currentInstalledPrinter.PaperSizes + ' If sizes.PaperName = "A4" Then + ' printerPaperSizeA4 = True + ' Exit For + ' End If + + ' Next + ' Exit For + ' End If + ' Next + ' Exit For + ' End If + ' Next + ' End If + ' End If + + ' If printerName = "" Then + ' Dim oPS As New System.Drawing.Printing.PrinterSettings + ' printerName = oPS.PrinterName + ' For Each sizes In oPS.PaperSizes + ' If sizes.PaperName = "A4" Then printerPaperSizeA4 = True + ' Exit For + ' Next + ' Else + ' If Not printerPaperSizeA4 Then + ' Dim currentInstalledPrinter As New System.Drawing.Printing.PrinterSettings + ' currentInstalledPrinter.PrinterName = printerName + ' For Each sizes In currentInstalledPrinter.PaperSizes + ' If sizes.PaperName = "A4" Then printerPaperSizeA4 = True + ' Exit For + ' Next + ' End If + + ' End If + + ' If printerName = "" Then + ' MsgBox("Drucker konnte nicht ermittelt werden!") + ' Exit Sub + ' End If + + ' If Not printerPaperSizeA4 Then + ' MsgBox("Der ermittelte Drucker " & printerName & " unterstützt keinen A4 Ausdrucke!" & vbNewLine & "Vorang wird abgebrochen!") + ' Exit Sub + ' End If + + ' VERAG_PROG_ALLGEMEIN.cProgramFunctions.spireLoadLicense() + ' For Each pdfPath In PDFFile + ' Dim doc As New Spire.Pdf.PdfDocument(pdfPath) + + ' doc.PageSettings.Size = Spire.Pdf.PdfPageSize.A4 + + ' doc.PageSettings.Orientation = Spire.Pdf.PdfPageOrientation.Landscape + ' doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True) + ' doc.PrintSettings.PrinterName = printerName + + ' If doc.PrintSettings.IsValid Then + ' doc.Print() + ' Else + ' MsgBox("Druckereinstellungen ungültig!") + ' Exit Sub + ' End If + + ' Next + + + Try - Dim printerPaperSizeA4 As Boolean = False If printerName = "" Then Dim sPrinters As ArrayList @@ -1264,59 +1361,23 @@ Public Class cFormularManager If VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_STANDARD <> String.Empty Then - For Each printer In sPrinters - - If printer.ToString.ToLower.Contains(VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_STANDARD.ToLower) Then - printerName = printer - For Each installedPrinter In System.Drawing.Printing.PrinterSettings.InstalledPrinters - If printerName = installedPrinter.ToString Then - Dim currentInstalledPrinter As New System.Drawing.Printing.PrinterSettings - currentInstalledPrinter.PrinterName = printerName - For Each sizes In currentInstalledPrinter.PaperSizes - If sizes.PaperName = "A4" Then printerPaperSizeA4 = True - Exit For - Next - Exit For - End If - Next - Exit For + For i As Integer = 0 To sPrinters.Count - 1 + If i.ToString.ToLower.Contains(VERAG_PROG_ALLGEMEIN.cAllgemein.PRINTER_STANDARD.ToLower) Then + printerName = i End If Next End If - End If - If printerName = "" Then + If printerName = "" Then Dim oPS As New System.Drawing.Printing.PrinterSettings printerName = oPS.PrinterName - For Each sizes In oPS.PaperSizes - If sizes.PaperName = "A4" Then printerPaperSizeA4 = True - Exit For - Next - Else - If Not printerPaperSizeA4 Then - Dim currentInstalledPrinter As New System.Drawing.Printing.PrinterSettings - currentInstalledPrinter.PrinterName = printerName - For Each sizes In currentInstalledPrinter.PaperSizes - If sizes.PaperName = "A4" Then printerPaperSizeA4 = True - Exit For - Next - End If - End If - - 'Dim docs As Spire.Pdf.PdfDocument() = {New Spire.Pdf.PdfDocument("C:\Users\DEVELOPER1\Desktop\Agrotel.pdf")} + End If If printerName = "" Then MsgBox("Drucker konnte nicht ermittelt werden!") - Exit Sub End If - - If Not printerPaperSizeA4 Then - MsgBox("Der ermittelte Drucker " & printerName & " unterstützt keinen A4 Ausdrucke!" & vbNewLine & "Vorang wird abgebrochen!") - Exit Sub - End If - VERAG_PROG_ALLGEMEIN.cProgramFunctions.spireLoadLicense() For Each pdfPath In PDFFile Dim doc As New Spire.Pdf.PdfDocument(pdfPath) @@ -1326,42 +1387,13 @@ Public Class cFormularManager doc.PageSettings.Orientation = Spire.Pdf.PdfPageOrientation.Landscape doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.FitSize, True) doc.PrintSettings.PrinterName = printerName + doc.Print() - If doc.PrintSettings.IsValid Then - doc.Print() - Else - MsgBox("Druckereinstellungen ungültig!") - Exit Sub - End If - - - - 'doc.PrintDocument.DefaultPageSettings.Landscape = True - 'doc.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize - - 'doc.PrinterName = printerName - 'doc.PrintDocument.Print() - - - 'Dim doc As New Spire.Pdf.PdfDocument - 'doc.LoadFromFile(pdfPath) - 'doc.Pages(0).TryCompressImage(0) - ''signature.SetSignNameWidth(float width); - 'doc.SaveToFile("C:\Users\DEVELOPER1\Desktop\TEST.pdf", 0, 0, Spire.Pdf.FileFormat.PDF) - - - 'Dim doc2 As New Spire.Pdf.PdfDocument("C:\Users\DEVELOPER1\Desktop\TEST.pdf") - 'doc2.PageSettings.Size = Spire.Pdf.PdfPageSize.A4 - 'doc2.PrintDocument.DefaultPageSettings.Landscape = True - 'doc2.PageScaling = Spire.Pdf.PdfPrintPageScaling.FitSize - - 'doc2.PrinterName = printerName - 'doc2.PrintDocument.Print() Next Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try End Sub @@ -1408,7 +1440,7 @@ Public Class cFormularManager Next Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try End Sub @@ -1451,7 +1483,7 @@ Public Class cFormularManager Next Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try End Sub @@ -1491,7 +1523,7 @@ Public Class cFormularManager Return targetPath Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try Return "" End Function @@ -1588,7 +1620,7 @@ Public Class cFormularManager 'End Using Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try End Sub @@ -2004,7 +2036,7 @@ Public Class DATENVERVER_OPTIONS IO.File.Copy(pfad, tmpPath) Return tmpPath Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try Return pfad End Function @@ -2016,7 +2048,7 @@ Public Class DATENVERVER_OPTIONS IO.File.Copy(pfad, tmpPath) Return tmpPath Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try Return pfad End Function @@ -2219,7 +2251,7 @@ Public Class DATENVERVER_OPTIONS Return targetPath Catch ex As Exception - MsgBox(ex.Message & ex.StackTrace) + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) End Try Return "" End Function