This commit is contained in:
2025-08-11 16:54:52 +02:00
parent ec752e7b33
commit 5bc542dd08
2 changed files with 39 additions and 22 deletions

View File

@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.4.3.2")>
<Assembly: AssemblyFileVersion("1.4.3.2")>
<Assembly: AssemblyVersion("1.4.3.3")>
<Assembly: AssemblyFileVersion("1.4.3.3")>

View File

@@ -1,10 +1,12 @@
Imports System
Imports System.Collections.Generic
Imports Chilkat
Imports System.Web.Script.Serialization
Imports System.Globalization
Imports System.IO
Imports System.Text
Imports System.Web.Script.Serialization
Imports Chilkat
Imports Renci.SshNet
Imports sun.swing
Public Class cTelotecAPI
@@ -140,31 +142,31 @@ Public Class cTelotecAPI
Console.WriteLine("✅ StoreEXDeclarations Antwort: " & resp.BodyStr)
End Sub
Shared Sub GET_ALL_TELO_Messages()
Shared Sub GET_ALL_TELO_Messages(AnhEinlesen As Boolean)
Dim TELO As New VERAG_PROG_ALLGEMEIN.cTelotecAPI
Dim Company = "ATILLA"
For ii As Integer = 0 To 50
Dim messages As List(Of VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) = TELO.GetTAMessages(Company)
Dim messages As List(Of VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) = TELO.GetTAMessages(Company, AnhEinlesen)
Threading.Thread.Sleep(1000) '
Next
Company = "IMEX"
For ii As Integer = 0 To 50
Dim messages As List(Of VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) = TELO.GetTAMessages(Company)
Dim messages As List(Of VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) = TELO.GetTAMessages(Company, AnhEinlesen)
Threading.Thread.Sleep(1000) '
Next
Company = "DURMAZ"
For ii As Integer = 0 To 50
Dim messages As List(Of VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) = TELO.GetTAMessages(Company)
Dim messages As List(Of VERAG_PROG_ALLGEMEIN.cTelotecAPI.TAMessage) = TELO.GetTAMessages(Company, AnhEinlesen)
Threading.Thread.Sleep(1000) '
Next
End Sub
Function GetTAMessages(Company) As List(Of TAMessage)
Function GetTAMessages(Company, AnhEinlesen) As List(Of TAMessage)
Console.WriteLine("-------------LOS-------------")
@@ -214,14 +216,14 @@ Public Class cTelotecAPI
SaveJsonResponseTo_ATEZFTP(filePath)
' Übergabe an Parserfunktion
Return ParseTAMessagesJson(jsonText)
Return ParseTAMessagesJson(jsonText, AnhEinlesen)
End Function
Public Function ParseTAMessagesFromFile(filePath As String) As List(Of TAMessage)
Public Function ParseTAMessagesFromFile(filePath As String, AnhEinlesen As Boolean) As List(Of TAMessage)
Dim messages As New List(Of TAMessage)()
If Not File.Exists(filePath) Then
@@ -231,7 +233,7 @@ Public Class cTelotecAPI
Try
Dim jsonText As String = File.ReadAllText(filePath, Encoding.UTF8)
Return ParseTAMessagesJson(jsonText)
Return ParseTAMessagesJson(jsonText, AnhEinlesen)
Catch ex As Exception
Console.WriteLine("❌ Fehler beim Lesen/Verarbeiten der Datei: " & ex.Message)
End Try
@@ -240,7 +242,7 @@ Public Class cTelotecAPI
End Function
Public Function ParseTAMessagesJson(jsonText As String) As List(Of TAMessage)
Public Function ParseTAMessagesJson(jsonText As String, AnhEinlesen As Boolean) As List(Of TAMessage)
Dim messages As New List(Of TAMessage)()
Dim json As New Chilkat.JsonObject()
@@ -260,19 +262,25 @@ Public Class cTelotecAPI
msg.externalReference = jmsg.StringOf("externalReference")
msg.msgType = jmsg.StringOf("msgType")
Dim filePath As String = ""
' 💾 Attachment speichern
If AnhEinlesen Then
' 💾 Attachment speichern
Dim attachmentB64 As String = jmsg.StringOf("attachment")
If Not String.IsNullOrWhiteSpace(attachmentB64) AndAlso attachmentB64.ToString <> "null" Then
SaveAttachmentBase64(attachmentB64, TELOTEC_ATTACHMENT_PATH, msg.lrn, filePath)
End If
Dim attachmentB64 As String = jmsg.StringOf("attachment")
If Not String.IsNullOrWhiteSpace(attachmentB64) AndAlso attachmentB64.ToString <> "null" Then
SaveAttachmentBase64(attachmentB64, TELOTEC_ATTACHMENT_PATH, msg.lrn)
End If
Dim contentObj As Chilkat.JsonObject = jmsg.ObjectOf("declarationContent")
If Not contentObj Is Nothing Then
Dim decl As New TADeclaration()
decl.filePath = filePath
decl.mandant_ID = contentObj.StringOf("mandant_ID")
decl.interfaceReferenceId = contentObj.StringOf("interfaceReferenceId")
decl.ifcCustomerId = contentObj.StringOf("ifcCustomerId")
@@ -342,7 +350,7 @@ Public Class cTelotecAPI
'PARSE TO cTELANMEUNG
Dim TC
'-------------------------------
Else
@@ -355,7 +363,7 @@ Public Class cTelotecAPI
Return messages
End Function
Public Sub SaveAttachmentBase64(base64String As String, ByVal TELOTEC_ATTACHMENT_PATH As String, filePrefix As String)
Public Sub SaveAttachmentBase64(base64String As String, ByVal TELOTEC_ATTACHMENT_PATH As String, filePrefix As String, ByRef filePath As String)
Try
If String.IsNullOrWhiteSpace(base64String) Then Exit Sub
@@ -370,11 +378,12 @@ Public Class cTelotecAPI
Next
Dim fileName As String = filePrefix & "_" & Date.Now.ToString("HHmmss") & ".pdf"
Dim filePath As String = Path.Combine(dayDir, fileName)
filePath = Path.Combine(dayDir, fileName)
Dim fileBytes() As Byte = Convert.FromBase64String(base64String)
File.WriteAllBytes(filePath, fileBytes)
Console.WriteLine("📄 PDF gespeichert unter: " & filePath)
Catch ex As Exception
Console.WriteLine("❌ Fehler beim Speichern des Attachments: " & ex.Message)
@@ -533,7 +542,14 @@ Public Class cTelotecAPI
gr.sequenceNumber = grefObj.IntOf("sequenceNumber")
gr.grn = grefObj.StringOf("grn")
gr.accessCode = grefObj.StringOf("accessCode")
gr.amountToBeCovered = grefObj.StringOf("amountToBeCovered")
' gr.amountToBeCovered = grefObj.StringOf("amountToBeCovered")
Dim tmp As String = grefObj.StringOf("amountToBeCovered")
If Not String.IsNullOrEmpty(tmp) Then
gr.amountToBeCovered = Double.Parse(tmp, CultureInfo.InvariantCulture)
Else
gr.amountToBeCovered = 0
End If
gr.currency = grefObj.StringOf("currency")
g.guaranteeReference.Add(gr)
Next
@@ -554,6 +570,7 @@ Public Class cTelotecAPI
Public Class TADeclaration
Public Property filePath As String ' Wenn anhang vorhanden ist, wird der Pfad hier gespeichert
Public Property mandant_ID As String
Public Property interfaceReferenceId As String
Public Property ifcCustomerId As String