MS Module Base StringFunctions

Modules.Jibs Sichtbeleg Anpassung
This commit is contained in:
Developer01
2025-03-14 14:43:11 +01:00
parent 3d388362ec
commit 7c473b9a27
6 changed files with 166 additions and 21 deletions

View File

@@ -89,6 +89,7 @@
<Compile Include="FileWatcher\FileWatcherProperties.vb" /> <Compile Include="FileWatcher\FileWatcherProperties.vb" />
<Compile Include="IDB\Constants.vb" /> <Compile Include="IDB\Constants.vb" />
<Compile Include="MimeEx.vb" /> <Compile Include="MimeEx.vb" />
<Compile Include="StringFunctions.vb" />
<Compile Include="WindowsEx.vb" /> <Compile Include="WindowsEx.vb" />
<Compile Include="ModuleExtensions.vb" /> <Compile Include="ModuleExtensions.vb" />
<Compile Include="FileEx.vb" /> <Compile Include="FileEx.vb" />

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' indem Sie "*" wie unten gezeigt eingeben: ' indem Sie "*" wie unten gezeigt eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.3.6.0")> <Assembly: AssemblyVersion("1.3.7.0")>
<Assembly: AssemblyFileVersion("1.3.6.0")> <Assembly: AssemblyFileVersion("1.3.7.0")>

22
Base/StringFunctions.vb Normal file
View File

@@ -0,0 +1,22 @@
Public Class StringFunctions
Public Shared Function SplitText_Length(ByVal input As String, ByVal maxLength As Integer) As List(Of String)
Dim result As New List(Of String)
For i As Integer = 0 To input.Length - 1 Step maxLength
' Textabschnitt extrahieren
Dim chunk As String = input.Substring(i, Math.Min(maxLength, input.Length - i))
result.Add(chunk)
Next
Return result
End Function
Public Shared Function SplitTextByNewLine(text As String) As List(Of String)
If String.IsNullOrEmpty(text) Then
Return New List(Of String)()
End If
' Zerlege den Text anhand von Zeilenumbrüchen
Dim lines As List(Of String) = text.Split({vbCrLf, vbLf, vbCr}, StringSplitOptions.None).ToList()
Return lines
End Function
End Class

View File

@@ -138,6 +138,7 @@
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" /> <Reference Include="System.IO.Compression" />
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel" />

View File

@@ -30,5 +30,5 @@ Imports System.Runtime.InteropServices
' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern ' Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
<Assembly: AssemblyVersion("2.8.1.0")> <Assembly: AssemblyVersion("2.8.3.0")>
<Assembly: AssemblyFileVersion("2.8.1.0")> <Assembly: AssemblyFileVersion("2.8.3.0")>

View File

@@ -5,7 +5,8 @@ Imports DigitalData.Modules.Base
Imports DigitalData.Modules.Database Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Imports GdPicture14 Imports GdPicture14
Imports System.Drawing
Imports System.Linq
Public Class XRechnungViewDocument Public Class XRechnungViewDocument
Private ReadOnly _logger As Logger Private ReadOnly _logger As Logger
Private ReadOnly _logConfig As LogConfig Private ReadOnly _logConfig As LogConfig
@@ -69,16 +70,23 @@ Public Class XRechnungViewDocument
MyGDPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) MyGDPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
' Dim oCurrent As Integer = MyGDPicturePDF.GetCurrentPage() ' Dim oCurrent As Integer = MyGDPicturePDF.GetCurrentPage()
Dim yPosition As Integer = Create_PageHeader(False) Dim yPosition As Single = Create_PageHeader(False)
Create_PageFooter() Create_PageFooter()
Dim oArea As String = "" Dim oArea As String = ""
Dim oIsPosition As Boolean = False Dim oIsPosition As Boolean = False
Dim oPosCount = 0 Dim oPosCount = 0
Dim oPosTerm As String = "" Dim oPosTerm As String = ""
Dim oPosDesc As String = ""
Dim oCurrencySymbol = "" Dim oCurrencySymbol = ""
Dim oWidthLine = 200
yPosition += 5 yPosition += 5
Dim font As New Font("Helvetica", 10)
Dim xRight As Integer = 100
Dim oIndex As Integer = 0 Dim oIndex As Integer = 0
Dim oYPlus As Integer = 0
Dim oCreateTextBox As Boolean = False
For Each oRow As DataRow In pDTItemValues.Rows For Each oRow As DataRow In pDTItemValues.Rows
Dim Y_eq_lastrow As Boolean = CBool(oRow.Item("Y_eq_lastrow")) Dim Y_eq_lastrow As Boolean = CBool(oRow.Item("Y_eq_lastrow"))
Dim oRowCaption As String = oRow.Item("Row_Caption") Dim oRowCaption As String = oRow.Item("Row_Caption")
@@ -86,6 +94,7 @@ Public Class XRechnungViewDocument
Dim oItemValue As String = oRow.Item("ITEM_VALUE") Dim oItemValue As String = oRow.Item("ITEM_VALUE")
Dim oDisplay As Boolean = oRow.Item("Display") Dim oDisplay As Boolean = oRow.Item("Display")
Dim oAreaSwitch As Boolean = False Dim oAreaSwitch As Boolean = False
If oRow.Item("Area") = "INTERNAL" Then If oRow.Item("Area") = "INTERNAL" Then
If oItemSPECNAME = "STATIC_Y_SWITCH" Then If oItemSPECNAME = "STATIC_Y_SWITCH" Then
yPosition = oItemValue yPosition = oItemValue
@@ -113,6 +122,7 @@ Public Class XRechnungViewDocument
If oArea <> oRow.Item("Area") Then If oArea <> oRow.Item("Area") Then
'########## AREA WECHSEL ########### '########## AREA WECHSEL ###########
oAreaSwitch = True oAreaSwitch = True
oCreateTextBox = False
oArea = oRow.Item("Area") oArea = oRow.Item("Area")
_logger.Debug($"Area-Switch to: {oArea}") _logger.Debug($"Area-Switch to: {oArea}")
Dim oAREACaption As String Dim oAREACaption As String
@@ -127,6 +137,7 @@ Public Class XRechnungViewDocument
oIsPosition = True oIsPosition = True
ElseIf oArea = "AMOUNT" Then ElseIf oArea = "AMOUNT" Then
oAREACaption = "Beträge / Amounts:" oAREACaption = "Beträge / Amounts:"
oCreateTextBox = True
ElseIf oArea = "TAXPOS" Then ElseIf oArea = "TAXPOS" Then
oAREACaption = "Steuerbeträge / Tax amounts:" oAREACaption = "Steuerbeträge / Tax amounts:"
oIsPosition = True oIsPosition = True
@@ -139,17 +150,25 @@ Public Class XRechnungViewDocument
If Not oAREACaption = String.Empty Then If Not oAREACaption = String.Empty Then
'erste Area-Linie 'erste Area-Linie
yPosition += 5 yPosition += 5
MyGDPicturePDF.DrawLine(10, yPosition, 125, yPosition) MyGDPicturePDF.DrawLine(10, yPosition, oWidthLine, yPosition)
'gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line) 'gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line)
yPosition += 5 yPosition += 5
'Area caption 'Area caption
MyGDPicturePDF.DrawText(fontResNameBold, 10, yPosition, oAREACaption) MyGDPicturePDF.DrawText(fontResNameBold, 10, yPosition, oAREACaption)
yPosition += 5 yPosition += 5
If oArea = "TYPE" Then If oArea = "TYPE" Then
MyGDPicturePDF.DrawLine(10, yPosition, 125, yPosition) MyGDPicturePDF.DrawLine(10, yPosition, oWidthLine, yPosition)
' gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line) ' gdpicturePDF.DrawText(fontResName, 10, yPosition, XRechnungStrings.Seperator_Line)
yPosition += 5 yPosition += 5
ElseIf oArea = "POSITION" Then
'Tabellendarstellung
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, "Pos#")
MyGDPicturePDF.DrawText(fontResName, 20, yPosition, "Anz./Am.")
MyGDPicturePDF.DrawText(fontResName, 38, yPosition, "Pos.-Text")
MyGDPicturePDF.DrawText(fontResName, 155, yPosition, "Steuer/Tax")
MyGDPicturePDF.DrawText(fontResName, 175, yPosition, "Betrag/Sum")
yPosition += 5
'Tabellendarstellung Ende
End If End If
End If End If
If oArea = "TYPE" Then If oArea = "TYPE" Then
@@ -162,10 +181,20 @@ Public Class XRechnungViewDocument
oIsPosition = True oIsPosition = True
If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then
oPosCount += 1 oPosCount += 1
oPosTerm = $"{oPosCount}. {oItemValue} * " 'oPosTerm = $"{oPosCount}. {oItemValue} * "
oItemValue = oPosTerm 'oItemValue = oPosTerm
'Tabellendarstellung
oPosTerm = ""
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oPosCount)
'
'Dim otextBoxYPos As Integer = yPosition - 3.5
'MyGDPicturePDF.DrawTextBox(fontResName, 10, otextBoxYPos, 16, YCoo_TextBoxPlus5(otextBoxYPos),
' TextAlignment.TextAlignmentFar, TextAlignment.TextAlignmentNear,
' oPosCount)
MyGDPicturePDF.DrawText(fontResName, 20, yPosition, oItemValue)
'Tabellendarstellung Ende
oDisplay = False oDisplay = False
yPosition -= 5 ' yPosition -= 5
End If End If
ElseIf oArea = "TAXPOS" Then ElseIf oArea = "TAXPOS" Then
oIsPosition = True oIsPosition = True
@@ -179,20 +208,77 @@ Public Class XRechnungViewDocument
End If End If
Else Else
'INDIVIDUELLES VERHALTEN BEI Folge-ITEMS 'INDIVIDUELLES VERHALTEN BEI Folge-ITEMS
_logger.Debug($"FollowItem: {oItemSPECNAME} - ItemValue: {oItemValue}") _logger.Debug($"FollowItem - Area: [{oArea}] - ItemSpecname: [{oItemSPECNAME}] - ItemValue: [{oItemValue}]")
Dim otextBoxYPos As Integer
If oArea = "POSITION" Then If oArea = "POSITION" Then
If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then If oItemSPECNAME = "INVOICE_POSITION_AMOUNT" Then
oPosCount += 1 oPosCount += 1
oPosTerm = $"{oPosCount}. {oItemValue} * " oYPlus = 0
'oPosTerm = $"{oPosCount}. {oItemValue} * "
'Tabellendarstellung
yPosition += 5
oPosTerm = ""
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oPosCount)
'otextBoxYPos = yPosition - 3.5
'MyGDPicturePDF.DrawTextBox(fontResName, 10, otextBoxYPos, 16, YCoo_TextBoxPlus5(otextBoxYPos),
' TextAlignment.TextAlignmentFar, TextAlignment.TextAlignmentNear,
' oPosCount)
MyGDPicturePDF.DrawText(fontResName, 20, yPosition, oItemValue)
'Tabellendarstellung Ende
oDisplay = False oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_POSITION_ARTICLE" Then ElseIf oItemSPECNAME = "INVOICE_POSITION_ARTICLE" Then
oPosTerm += $" {oItemValue}" 'Tabellendarstellung
oYPlus = 0
oPosDesc = ""
oPosDesc = oItemValue
Dim oYDyn As Integer = yPosition - 5
Dim oPartsNL As List(Of String) = StringFunctions.SplitTextByNewLine(oItemValue)
For Each olinepart As String In oPartsNL
Dim oParts As List(Of String) = StringFunctions.SplitText_Length(olinepart, 67)
' Durchlaufen der einzelnen Teile in einer Schleife
For Each part As String In oParts
oYDyn += 5
oYPlus += 5
MyGDPicturePDF.DrawText(fontResName, 38, oYDyn, part)
Next
Next
'Tabellendarstellung Ende
' oPosTerm += $" {oItemValue}"
oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_POSITION_NOTE" Then
'Tabellendarstellung
Dim cleanedText As String = RemoveNewlinesAndTabs(oItemValue)
Dim oParts As List(Of String) = StringFunctions.SplitText_Length(cleanedText, 68)
' Durchlaufen der einzelnen Teile in einer Schleife
Dim oYDyn As Integer = yPosition
Dim oPartsNL As List(Of String) = StringFunctions.SplitTextByNewLine(oItemValue)
For Each olinepart As String In oPartsNL
Dim oPartsPN As List(Of String) = StringFunctions.SplitText_Length(olinepart, 67)
' Durchlaufen der einzelnen Teile in einer Schleife
For Each part As String In oPartsPN
oYDyn += 5
oYPlus += 5
MyGDPicturePDF.DrawText(fontResName, 38, oYDyn, part)
Next
Next
'Tabellendarstellung Ende
'oPosTerm += $" {oItemValue}"
oDisplay = False oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_TAXPOS_TAX_RATE" Or oItemSPECNAME = "INVOICE_TAXPOS_RATE" Then ElseIf oItemSPECNAME = "INVOICE_TAXPOS_TAX_RATE" Or oItemSPECNAME = "INVOICE_TAXPOS_RATE" Then
oPosTerm += $" - {oItemValue} %" 'Tabellendarstellung
MyGDPicturePDF.DrawText(fontResName, 155, yPosition, $"{oItemValue} %")
'Tabellendarstellung ENDE
' oPosTerm += $" - {oItemValue} %"
oDisplay = False oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_POSITION_TAX_AMOUNT" Then ElseIf oItemSPECNAME = "INVOICE_POSITION_TAX_AMOUNT" Then
oPosTerm += $" - {oItemValue} {oCurrencySymbol}" ' oPosTerm += $" - {oItemValue} {oCurrencySymbol}"
'Tabellendarstellung
Dim oYPos = yPosition - 3.5
MyGDPicturePDF.DrawTextBox(fontResName, 175, oYPos, 193, YCoo_TextBoxPlus5(oYPos),
TextAlignment.TextAlignmentFar, TextAlignment.TextAlignmentNear,
$"{oItemValue} {oCurrencySymbol}")
' MyGDPicturePDF.DrawText(fontResName, 175, yPosition, $"{oItemValue} {oCurrencySymbol}")
'Tabellendarstellung Ende
End If End If
oItemValue = oPosTerm oItemValue = oPosTerm
ElseIf oArea = "HEAD" Then ElseIf oArea = "HEAD" Then
@@ -210,26 +296,36 @@ Public Class XRechnungViewDocument
oPosTerm += $" {oItemValue} {oCurrencySymbol}" oPosTerm += $" {oItemValue} {oCurrencySymbol}"
oDisplay = False oDisplay = False
ElseIf oItemSPECNAME = "INVOICE_TAXPOS_TYPE" Then ElseIf oItemSPECNAME = "INVOICE_TAXPOS_TYPE" Then
oPosTerm += $" - {oItemValue}" oPosTerm += $" {oItemValue}"
End If End If
oItemValue = oPosTerm oItemValue = oPosTerm
End If End If
End If End If
If oDisplay = True Then If oDisplay = True And Len(oItemValue) > 0 Then
If Y_eq_lastrow = False And oAreaSwitch = False Then If Y_eq_lastrow = False And oAreaSwitch = False Then
yPosition += 5 yPosition += 5
End If End If
If oArea = "AMOUNT" Then If oArea = "AMOUNT" Then
If oItemSPECNAME = "INVOICE_TOTAL_NET" Or oItemSPECNAME = "INVOICE_TOTAL_GROSS" Then If oItemSPECNAME = "INVOICE_TOTAL_TAX" Or oItemSPECNAME = "INVOICE_TOTAL_NET" Or oItemSPECNAME = "INVOICE_TOTAL_GROSS" Then
oItemValue += $" {oCurrencySymbol}" oItemValue += $" {oCurrencySymbol}"
End If End If
End If End If
If oRowCaption <> String.Empty Then If oRowCaption <> String.Empty Then
'Zuerst die RowCaption
MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oRowCaption) MyGDPicturePDF.DrawText(fontResName, 10, yPosition, oRowCaption)
MyGDPicturePDF.DrawText(fontResName, 70, yPosition, oItemValue) 'Dann den Wert
If oCreateTextBox Then
Dim otextBoxYPos = yPosition - 3
MyGDPicturePDF.DrawTextBox(fontResName, 70, otextBoxYPos, 90, YCoo_TextBoxPlus5(otextBoxYPos),
TextAlignment.TextAlignmentFar, TextAlignment.TextAlignmentCenter,
oItemValue)
Else
MyGDPicturePDF.DrawText(fontResName, 70, yPosition, oItemValue)
End If
Else Else
If Y_eq_lastrow = True Then If Y_eq_lastrow = True Then
MyGDPicturePDF.DrawText(fontResName, oRow.Item("xPosition"), yPosition, oItemValue) MyGDPicturePDF.DrawText(fontResName, oRow.Item("xPosition"), yPosition, oItemValue)
@@ -256,6 +352,12 @@ Public Class XRechnungViewDocument
End If End If
End If End If
Else
'Tabellendarstellung
If oItemSPECNAME = "INVOICE_POSITION_TAX_AMOUNT" And oYPlus > 0 Then
yPosition += oYPlus - 5
End If
'Tabellendarstellung Ende
End If End If
oIndex += 1 oIndex += 1
Next Next
@@ -288,7 +390,26 @@ Public Class XRechnungViewDocument
Return Nothing Return Nothing
End Try End Try
End Function End Function
Private Function RemoveNewlinesAndTabs(ByVal text As String) As String
Return text.Replace(vbCr, " - ").Replace(vbLf, "").Replace(vbTab, " ")
End Function
Private Function YCoo_TextBoxMinus5(yPosition As Integer)
Return yPosition - 5
End Function
Private Function YCoo_TextBoxPlus5(yPosition As Integer)
Return yPosition + 5
End Function
Function SplitTextByNewLine(text As String) As List(Of String)
If String.IsNullOrEmpty(text) Then
Return New List(Of String)()
End If
' Zerlege den Text anhand von Zeilenumbrüchen
Dim lines As List(Of String) = text.Split({vbCrLf, vbLf, vbCr}, StringSplitOptions.None).ToList()
Return lines
End Function
Public Function Create_PageHeader(pFollowPage As Boolean) As Integer Public Function Create_PageHeader(pFollowPage As Boolean) As Integer
'Draw content on the PDF 'Draw content on the PDF
Dim yPosition As Integer = 15 Dim yPosition As Integer = 15