Functions zur Prüfung der Base64 Bilder in den ActiveReports.
This commit is contained in:
@@ -87,6 +87,9 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\PROGRAMMIERUNG\dll\OpenXML\DocumentFormat.OpenXml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DS.Documents.Imaging">
|
||||
<HintPath>..\..\..\Aviso\AVISO\Gemeinsames\bin\Debug\DS.Documents.Imaging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Dynamsoft.Forms.Viewer, Version=8.3.3.726, Culture=neutral, PublicKeyToken=298ad97013b423eb, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\PROGRAMMIERUNG\dll\Dynamsoft\8.3.3\Dynamsoft.Forms.Viewer.dll</HintPath>
|
||||
@@ -123,6 +126,14 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\PROGRAMMIERUNG\dll\McDull.Windows.Forms.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MESCIUS.ActiveReports">
|
||||
<HintPath>..\..\..\Aviso\AVISO\Gemeinsames\bin\Debug\MESCIUS.ActiveReports.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MESCIUS.ActiveReports.Core.Document, Version=4.7.0.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff" />
|
||||
<Reference Include="MESCIUS.ActiveReports.Core.Document.Drawing.Gc, Version=4.7.0.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\Aviso\AVISO\Gemeinsames\bin\Debug\MESCIUS.ActiveReports.Core.Document.Drawing.Gc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Office.Interop.Outlook, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
Imports System.Drawing
|
||||
Imports System.IO
|
||||
Imports System.IO.Pipes
|
||||
Imports System.Net.Mail
|
||||
Imports System.Reflection
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.Text
|
||||
Imports System.Windows.Forms
|
||||
Imports ClosedXML.Excel
|
||||
Imports GrapeCity.ActiveReports
|
||||
Imports GrapeCity.ActiveReports.Core.Document.Drawing.Gc
|
||||
Imports GrapeCity.ActiveReports.SectionReportModel
|
||||
Imports GrapeCity.Documents.Imaging
|
||||
Imports Microsoft.Office.Interop
|
||||
Imports System.IO.Pipes
|
||||
Imports ThoughtWorks.QRCode.Codec
|
||||
|
||||
Public Class cProgramFunctions
|
||||
@@ -71,6 +75,135 @@ Public Class cProgramFunctions
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function CheckAllReportImages() As List(Of String)
|
||||
|
||||
Dim errors As New List(Of String)
|
||||
|
||||
For Each report As GrapeCity.ActiveReports.SectionReport In FindAllReports()
|
||||
|
||||
For Each section As GrapeCity.ActiveReports.SectionReportModel.Section In report.Sections
|
||||
CheckImagesInControls(section.Controls, errors, report.GetType().Name, section.Name)
|
||||
Next
|
||||
|
||||
Next
|
||||
|
||||
Return errors
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function CheckReportImages(report As SectionReport) As List(Of String)
|
||||
|
||||
Dim errors As New List(Of String)
|
||||
|
||||
For Each section As GrapeCity.ActiveReports.SectionReportModel.Section In report.Sections
|
||||
CheckImagesInControls(section.Controls, errors, report.GetType().Name, section.Name)
|
||||
Next
|
||||
|
||||
|
||||
Return errors
|
||||
|
||||
End Function
|
||||
|
||||
Private Shared Sub CheckImagesInControls(ctrls As GrapeCity.ActiveReports.SectionReportModel.ControlCollection, errors As List(Of String), reportName As String, sectionName As String)
|
||||
|
||||
For Each ctrl As GrapeCity.ActiveReports.SectionReportModel.ARControl In ctrls
|
||||
|
||||
If TypeOf ctrl Is GrapeCity.ActiveReports.SectionReportModel.Picture Then
|
||||
|
||||
Dim pic = CType(ctrl, GrapeCity.ActiveReports.SectionReportModel.Picture)
|
||||
|
||||
If Not String.IsNullOrEmpty(pic.ImageBase64String) Then
|
||||
|
||||
If Not IsBase64(pic.ImageBase64String) Then
|
||||
errors.Add($"{reportName} | {sectionName} | {ctrl.Name} → Ungültiger Base64")
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
End Sub
|
||||
|
||||
Public Shared Function IsBase64(value As String) As Boolean
|
||||
If String.IsNullOrWhiteSpace(value) Then Return False
|
||||
|
||||
Try
|
||||
' Data-URL entfernen
|
||||
If value.Contains(",") Then
|
||||
value = value.Substring(value.IndexOf(",") + 1)
|
||||
End If
|
||||
|
||||
' Base64 dekodieren
|
||||
Dim bytes() As Byte = Convert.FromBase64String(value)
|
||||
|
||||
Using ms As New MemoryStream(bytes)
|
||||
' Instanz von GcBitmap erstellen
|
||||
Dim bmp As GcBitmap = Nothing
|
||||
Try
|
||||
bmp = New GcBitmap(ms)
|
||||
' Zugriff erzwingen
|
||||
Dim w As Integer = bmp.Width
|
||||
Dim h As Integer = bmp.Height
|
||||
|
||||
If w <= 0 OrElse h <= 0 Then Return False
|
||||
|
||||
Finally
|
||||
If bmp IsNot Nothing Then
|
||||
bmp.Dispose()
|
||||
End If
|
||||
End Try
|
||||
End Using
|
||||
|
||||
Return True
|
||||
|
||||
Catch ex As TypeInitializationException
|
||||
' Speziell Typeninitialisierer-Fehler abfangen
|
||||
' z. B. "PerTypeValues`1 hat eine Ausnahme verursacht"
|
||||
Return False
|
||||
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
' Alle anderen Fehler ebenfalls als ungültig behandeln
|
||||
Return False
|
||||
|
||||
Catch
|
||||
Return False
|
||||
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
Public Shared Function FindAllReports() As List(Of SectionReport)
|
||||
Dim list As New List(Of SectionReport)
|
||||
|
||||
' Alle geladenen Assemblies durchsuchen
|
||||
For Each asm In AppDomain.CurrentDomain.GetAssemblies()
|
||||
Try
|
||||
For Each t In asm.GetTypes()
|
||||
' Nur konkrete Klassen, die von SectionReport erben
|
||||
If GetType(SectionReport).IsAssignableFrom(t) AndAlso t.IsClass AndAlso Not t.IsAbstract Then
|
||||
Try
|
||||
' Parameterloser Konstruktor
|
||||
Dim instance As SectionReport = CType(Activator.CreateInstance(t), SectionReport)
|
||||
list.Add(instance)
|
||||
Catch ex As Exception
|
||||
' Ignoriere Klassen ohne parameterlosen Konstruktor
|
||||
End Try
|
||||
End If
|
||||
Next
|
||||
Catch
|
||||
' Manche Assemblies lassen sich nicht durchsuchen
|
||||
End Try
|
||||
Next
|
||||
|
||||
Return list
|
||||
End Function
|
||||
|
||||
Dim r As SectionReport
|
||||
|
||||
|
||||
Public Shared Sub tryGetFilialeAbf_ByLRN(ByVal LRN As String, ByRef FilialenNr As Object, ByRef AbfertigungsNr As Object)
|
||||
|
||||
@@ -486,7 +619,7 @@ BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, [Control], New Object(
|
||||
wb.Worksheets(0).Tables.FirstOrDefault().ShowAutoFilter = ShowAutoFilter
|
||||
|
||||
If rangeAsWaehrung IsNot Nothing Then
|
||||
For Each r In rangeAsWaehrung
|
||||
For Each r As String In rangeAsWaehrung
|
||||
Try
|
||||
wb.Worksheets(0).Range(r).Style.NumberFormat.SetFormat("###,###,##0.00 " & waehrungsZeichen)
|
||||
Catch ex As Exception
|
||||
@@ -1121,7 +1254,7 @@ BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, [Control], New Object(
|
||||
End Function
|
||||
Private Const SW_SHOWNOACTIVATE As Integer = 4
|
||||
Private Const SW_RESTORE As Integer = 9
|
||||
Shared Sub bringToFront(processId)
|
||||
Shared Sub bringToFront(processId)
|
||||
' Prozess finden und in den Vordergrund bringen
|
||||
Try
|
||||
Dim process = System.Diagnostics.Process.GetProcessById(processId)
|
||||
|
||||
Reference in New Issue
Block a user