Bugfix Creditsafe-Report
This commit is contained in:
@@ -3,6 +3,7 @@ Imports System.Globalization
|
||||
Imports System.IO
|
||||
Imports com.oracle.xmlns.internal.webservices.jaxws_databinding
|
||||
Imports com.sun.org.apache.bcel.internal.generic
|
||||
Imports itextsharp.text.pdf
|
||||
Imports java.rmi.server
|
||||
Imports javax.swing.plaf
|
||||
Imports SDL.EORI
|
||||
@@ -2758,7 +2759,7 @@ Public Class usrCntlKundenuebersicht
|
||||
|
||||
|
||||
Dim company As New cCreditSafeAPI.Company("", "", land, KUNDE_ERW.kde_CreditSaveNo, KUNDE_ERW.kde_CreditSaveId, Nothing, "", "", "", "", "", "", "", "")
|
||||
Dim pdfObject As Byte() = Nothing
|
||||
|
||||
If lblBonitaetsdatum._value <> Nothing Then
|
||||
|
||||
Dim lastChecked As Date = Date.ParseExact(lblBonitaetsdatum._value, "dd.MM.yyyy", System.Globalization.DateTimeFormatInfo.InvariantInfo)
|
||||
@@ -2767,22 +2768,18 @@ Public Class usrCntlKundenuebersicht
|
||||
If cs.checkDateOfLastRequest(company) < lastChecked Then
|
||||
Dim a As MsgBoxResult = MsgBox("Seit der letzen Abfrage (" & lastChecked.ToShortDateString & ") wurde bei Creditsafe keine Änderung gemacht!" & vbNewLine & "Trotzdem Creditreport-Daten aktualisieren?", vbYesNo)
|
||||
If a = vbYes Then
|
||||
cs.getReport(company, True)
|
||||
pdfObject = cs.getPDF(company)
|
||||
setCreditSafeEntry(company, pdfObject, kdNr)
|
||||
|
||||
setCreditsafereportEntry(cs, company)
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
cs.getReport(company, True)
|
||||
pdfObject = cs.getPDF(company)
|
||||
setCreditSafeEntry(company, pdfObject, kdNr)
|
||||
setCreditsafereportEntry(cs, company)
|
||||
|
||||
End If
|
||||
Else
|
||||
|
||||
cs.getReport(company, True)
|
||||
pdfObject = cs.getPDF(company)
|
||||
setCreditSafeEntry(company, pdfObject, kdNr)
|
||||
setCreditsafereportEntry(cs, company)
|
||||
|
||||
End If
|
||||
|
||||
@@ -2971,4 +2968,20 @@ Public Class usrCntlKundenuebersicht
|
||||
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
|
||||
genUIDEORIList(kdNr, "EORI")
|
||||
End Sub
|
||||
|
||||
Private Sub setCreditsafereportEntry(cs As cCreditSafeAPI, company As cCreditSafeAPI.Company)
|
||||
|
||||
Dim pdfObject As Byte() = Nothing
|
||||
Dim failureDesc As String = ""
|
||||
cs.getReport(company, True)
|
||||
pdfObject = cs.getPDF(company, failureDesc)
|
||||
If pdfObject Is Nothing Then
|
||||
setCreditSafeEntry(company, Nothing, kdNr)
|
||||
MsgBox("Fehler beim Erstellen des PDF-Dokuments" & vbNewLine & failureDesc)
|
||||
Else
|
||||
setCreditSafeEntry(company, pdfObject, kdNr)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
@@ -5,9 +5,11 @@ Imports System.Text
|
||||
Imports System.Web.UI.WebControls
|
||||
Imports System.Windows.Forms
|
||||
Imports Chilkat
|
||||
Imports iTextSharp.text.pdf
|
||||
Imports Microsoft.Office.Interop.Outlook
|
||||
Imports Newtonsoft.Json
|
||||
Imports Spire.Pdf.Lists
|
||||
Imports Spire.Pdf.OPC
|
||||
Imports VERAG_PROG_ALLGEMEIN.IDEV_Intrastat
|
||||
Imports VERAG_PROG_ALLGEMEIN.TESTJSON
|
||||
|
||||
@@ -75,7 +77,7 @@ Public Class cCreditSafeAPI
|
||||
|
||||
|
||||
|
||||
Shared Function SendGetRequestWithAuthHeader(url As String, company As Company, acceptContentType As String, method As String, authenticationToken As String) As String
|
||||
Shared Function SendGetRequestWithAuthHeader(url As String, company As Company, acceptContentType As String, method As String, authenticationToken As String, ByRef failureDesc As String) As String
|
||||
Try
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
@@ -91,6 +93,8 @@ Public Class cCreditSafeAPI
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
failureDesc = rest.LastErrorText
|
||||
Return failureDesc
|
||||
End If
|
||||
|
||||
rest.ClearAllQueryParams()
|
||||
@@ -115,8 +119,21 @@ Public Class cCreditSafeAPI
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
MsgBox(rest.LastErrorText)
|
||||
failureDesc = rest.LastErrorText
|
||||
Return failureDesc
|
||||
Else
|
||||
Return pdfData.ToString
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
Dim sbErrorText As New Chilkat.StringBuilder
|
||||
sbErrorText.AppendBd(pdfData, "utf-8", 0, 0)
|
||||
failureDesc = sbErrorText.GetAsString()
|
||||
Return failureDesc & vbNewLine & url
|
||||
Else
|
||||
|
||||
Return pdfData.GetEncoded("base64")
|
||||
End If
|
||||
|
||||
|
||||
|
||||
End If
|
||||
|
||||
Else
|
||||
@@ -124,7 +141,8 @@ Public Class cCreditSafeAPI
|
||||
responseJson = rest.FullRequestNoBody(method, url)
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
MsgBox(rest.LastErrorText)
|
||||
failureDesc = rest.LastErrorText
|
||||
Return failureDesc
|
||||
|
||||
Else
|
||||
Return responseJson
|
||||
@@ -156,9 +174,9 @@ Public Class cCreditSafeAPI
|
||||
Shared Function searchCompanies(company As Company, ByRef dataTable As DataTable) As String
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
|
||||
Dim failureDesc As String
|
||||
Dim myUrl As String = API_STRING & "/v1/companies"
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, company, "application/json", "GET", token)
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, company, "application/json", "GET", token, failureDesc)
|
||||
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
@@ -250,6 +268,7 @@ Public Class cCreditSafeAPI
|
||||
End Function
|
||||
|
||||
Shared Function getReport(ByRef company As Company, withPDF As Boolean) As String 'Shared Function getReport(ByRef company As Company, withPDF As Boolean, ByRef bytes As Byte()) As String
|
||||
Dim failureDesc As String
|
||||
Dim myUrl As String = API_STRING & "/v1/companies/" & company.creditSafeId & "/"
|
||||
If company.country = "DE" Then
|
||||
'Abfragen für DE benötigen einen Reason-Code
|
||||
@@ -257,7 +276,8 @@ Public Class cCreditSafeAPI
|
||||
myUrl &= "&?language=DE&?template=full"
|
||||
Else
|
||||
|
||||
myUrl &= "?language=DE&?template=full"
|
||||
'myUrl &= "?language=DE&?template=full"
|
||||
myUrl &= "?template=full"
|
||||
End If
|
||||
|
||||
Dim acceptContentType = "application/json"
|
||||
@@ -267,7 +287,7 @@ Public Class cCreditSafeAPI
|
||||
|
||||
|
||||
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, Nothing, acceptContentType, "GET", token)
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, Nothing, acceptContentType, "GET", token, failureDesc)
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
Dim success As Boolean = json.Load(jsonRespString)
|
||||
@@ -410,11 +430,13 @@ Public Class cCreditSafeAPI
|
||||
company.csFailure = json.StringOf("details")
|
||||
End If
|
||||
|
||||
Return "ohnePDF"
|
||||
Return failureDesc
|
||||
|
||||
End Function
|
||||
|
||||
Shared Function getPDF(ByRef company As Company) As Byte()
|
||||
Shared Function getPDF(ByRef company As Company, ByRef failure As String) As Byte()
|
||||
|
||||
If company IsNot Nothing AndAlso company.creditSafeId <> "" Then
|
||||
|
||||
Dim myUrl As String = API_STRING & "/v1/companies/" & company.creditSafeId & "/"
|
||||
If company.country = "DE" Then
|
||||
@@ -423,17 +445,29 @@ Public Class cCreditSafeAPI
|
||||
myUrl &= "&?language=DE&?template=full"
|
||||
Else
|
||||
|
||||
myUrl &= "?language=DE&?template=full"
|
||||
myUrl &= "?template=full"
|
||||
End If
|
||||
|
||||
Dim acceptContentType = "application/pdf"
|
||||
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, Nothing, acceptContentType, "GET", token)
|
||||
|
||||
If jsonRespString IsNot Nothing Then
|
||||
Return Convert.FromBase64String(jsonRespString)
|
||||
Dim pdfData2 As New Chilkat.BinData
|
||||
Dim failureDesc As String
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, Nothing, acceptContentType, "GET", token, failureDesc)
|
||||
failure = failureDesc
|
||||
If jsonRespString IsNot Nothing And failure = "" Then
|
||||
Dim success = pdfData2.AppendEncoded(jsonRespString, "base64")
|
||||
If success Then
|
||||
Return pdfData2.GetBinary
|
||||
End If
|
||||
|
||||
'Return Convert.FromBase64String(test)
|
||||
End If
|
||||
|
||||
Else
|
||||
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
@@ -456,7 +490,6 @@ Public Class cCreditSafeAPI
|
||||
If company.Street <> "" Then rest.AddQueryParam("street", company.Street)
|
||||
If company.Postalcode <> "" Then rest.AddQueryParam("postCode", company.Postalcode)
|
||||
If company.City <> "" Then rest.AddQueryParam("city", company.City)
|
||||
|
||||
End If
|
||||
|
||||
|
||||
@@ -467,9 +500,9 @@ Public Class cCreditSafeAPI
|
||||
|
||||
|
||||
Shared Function checkDateOfLastRequest(company As Company) As Date
|
||||
|
||||
Dim failureDesc As String
|
||||
Dim myUrl As String = API_STRING & "/v1/companies"
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, company, "application/json", "GET", token)
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, company, "application/json", "GET", token, failureDesc)
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
Dim success As Boolean = json.Load(jsonRespString)
|
||||
|
||||
Reference in New Issue
Block a user