Bugfix Creditsafe-Report
This commit is contained in:
@@ -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
|
||||
@@ -242,7 +260,7 @@ Public Class cCreditSafeAPI
|
||||
End Select
|
||||
|
||||
j = j + 1
|
||||
End While
|
||||
End While
|
||||
Next
|
||||
|
||||
Return "Anzahl gefundener Datensätze: " & numCompanies
|
||||
@@ -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,29 +430,43 @@ 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
|
||||
'Abfragen für DE benötigen einen Reason-Code
|
||||
myUrl &= "?customData=de_reason_code::2"
|
||||
myUrl &= "&?language=DE&?template=full"
|
||||
Else
|
||||
|
||||
myUrl &= "?template=full"
|
||||
End If
|
||||
|
||||
Dim acceptContentType = "application/pdf"
|
||||
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
|
||||
|
||||
Dim myUrl As String = API_STRING & "/v1/companies/" & company.creditSafeId & "/"
|
||||
If company.country = "DE" Then
|
||||
'Abfragen für DE benötigen einen Reason-Code
|
||||
myUrl &= "?customData=de_reason_code::2"
|
||||
myUrl &= "&?language=DE&?template=full"
|
||||
Else
|
||||
|
||||
myUrl &= "?language=DE&?template=full"
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim acceptContentType = "application/pdf"
|
||||
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, Nothing, acceptContentType, "GET", token)
|
||||
|
||||
If jsonRespString IsNot Nothing Then
|
||||
Return Convert.FromBase64String(jsonRespString)
|
||||
End If
|
||||
|
||||
|
||||
End Function
|
||||
@@ -450,26 +484,25 @@ Public Class cCreditSafeAPI
|
||||
Else
|
||||
|
||||
If company.vatNo <> "" Then
|
||||
rest.AddQueryParam("vatNo", company.vatNo)
|
||||
Else
|
||||
rest.AddQueryParam("vatNo", company.vatNo)
|
||||
Else
|
||||
If company.name <> "" Then rest.AddQueryParam("name", company.name)
|
||||
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
|
||||
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
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