credtisafe -> korrekter bericht wird nun als pdf angefügt
This commit is contained in:
@@ -2795,18 +2795,21 @@ Public Class usrCntlKundenuebersicht
|
|||||||
If cs.checkDateOfLastRequest(company) < lastChecked Then
|
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)
|
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
|
If a = vbYes Then
|
||||||
cs.getReport(company, True, pdfObject)
|
cs.getReport(company, True)
|
||||||
|
pdfObject = cs.getPDF(company)
|
||||||
setCreditSafeEntry(company, pdfObject, kdNr)
|
setCreditSafeEntry(company, pdfObject, kdNr)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Else
|
Else
|
||||||
cs.getReport(company, True, pdfObject)
|
cs.getReport(company, True)
|
||||||
|
pdfObject = cs.getPDF(company)
|
||||||
setCreditSafeEntry(company, pdfObject, kdNr)
|
setCreditSafeEntry(company, pdfObject, kdNr)
|
||||||
|
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
|
|
||||||
cs.getReport(company, True, pdfObject)
|
cs.getReport(company, True)
|
||||||
|
pdfObject = cs.getPDF(company)
|
||||||
setCreditSafeEntry(company, pdfObject, kdNr)
|
setCreditSafeEntry(company, pdfObject, kdNr)
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -107,15 +107,32 @@ Public Class cCreditSafeAPI
|
|||||||
rest.AddHeader("Accept", acceptContentType)
|
rest.AddHeader("Accept", acceptContentType)
|
||||||
|
|
||||||
|
|
||||||
|
Dim responseJson As String
|
||||||
|
Dim pdfData As New Chilkat.BinData
|
||||||
|
|
||||||
Dim responseJson As String = rest.FullRequestNoBody(method, url)
|
If acceptContentType.Contains("application/pdf") Then
|
||||||
If (rest.LastMethodSuccess <> True) Then
|
|
||||||
Debug.WriteLine(rest.LastErrorText)
|
responseJson = rest.FullRequestNoBodyBd(method, url, pdfData)
|
||||||
MsgBox(rest.LastErrorText)
|
If (rest.LastMethodSuccess <> True) Then
|
||||||
|
Debug.WriteLine(rest.LastErrorText)
|
||||||
|
MsgBox(rest.LastErrorText)
|
||||||
|
Else
|
||||||
|
Return pdfData.ToString
|
||||||
|
End If
|
||||||
|
|
||||||
|
Else
|
||||||
|
|
||||||
|
responseJson = rest.FullRequestNoBody(method, url)
|
||||||
|
If (rest.LastMethodSuccess <> True) Then
|
||||||
|
Debug.WriteLine(rest.LastErrorText)
|
||||||
|
MsgBox(rest.LastErrorText)
|
||||||
|
|
||||||
|
Else
|
||||||
|
Return responseJson
|
||||||
|
End If
|
||||||
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Return responseJson
|
|
||||||
|
|
||||||
Catch ex As WebException
|
Catch ex As WebException
|
||||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||||
@@ -205,7 +222,7 @@ Public Class cCreditSafeAPI
|
|||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Shared Function getReport(ByRef company As Company, withPDF As Boolean, ByRef bytes As Byte()) As String
|
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 myUrl As String = API_STRING & "/v1/companies/" & company.creditSafeId & "/"
|
Dim myUrl As String = API_STRING & "/v1/companies/" & company.creditSafeId & "/"
|
||||||
If company.country = "DE" Then
|
If company.country = "DE" Then
|
||||||
'Abfragen für DE benötigen einen Reason-Code
|
'Abfragen für DE benötigen einen Reason-Code
|
||||||
@@ -217,9 +234,9 @@ Public Class cCreditSafeAPI
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
Dim acceptContentType = "application/json"
|
Dim acceptContentType = "application/json"
|
||||||
If withPDF Then
|
'If withPDF Then
|
||||||
acceptContentType &= "+pdf"
|
' acceptContentType &= "+pdf"
|
||||||
End If
|
'End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -314,23 +331,61 @@ Public Class cCreditSafeAPI
|
|||||||
company.csFailure = json.StringOf("details")
|
company.csFailure = json.StringOf("details")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If withPDF Then
|
'If withPDF Then
|
||||||
Dim sb As New Chilkat.StringBuilder
|
' Dim sb As New Chilkat.StringBuilder
|
||||||
json.StringOfSb("pdfReportStream", sb)
|
' json.StringOfSb("pdfReportStream", sb)
|
||||||
|
|
||||||
Dim bd As New Chilkat.BinData
|
' Dim bd As New Chilkat.BinData
|
||||||
bd.AppendEncodedSb(sb, "base64")
|
' bd.AppendEncodedSb(sb, "base64")
|
||||||
|
|
||||||
bytes = Convert.FromBase64String(sb.ToString)
|
' bytes = Convert.FromBase64String(sb.ToString)
|
||||||
|
|
||||||
Return "mitPDF"
|
' Return "mitPDF"
|
||||||
|
|
||||||
End If
|
'End If
|
||||||
|
|
||||||
Return "ohnePDF"
|
Return "ohnePDF"
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Shared Function getPDF(ByRef company As Company) As Byte()
|
||||||
|
|
||||||
|
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"
|
||||||
|
Else
|
||||||
|
|
||||||
|
myUrl &= "?language=DE"
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim acceptContentType = "application/pdf"
|
||||||
|
|
||||||
|
Dim jsonRespString = SendGetRequestWithAuthHeader(myUrl, Nothing, acceptContentType, "GET", token)
|
||||||
|
|
||||||
|
'Dim json As New Chilkat.JsonObject
|
||||||
|
'Dim success As Boolean = json.Load(jsonRespString)
|
||||||
|
'If (success <> True) Then
|
||||||
|
' Debug.WriteLine(json.LastErrorText)
|
||||||
|
|
||||||
|
'End If
|
||||||
|
|
||||||
|
'Dim sb As New Chilkat.StringBuilder
|
||||||
|
'json.StringOfSb("pdfReportStream", sb)
|
||||||
|
|
||||||
|
'Dim bd As New Chilkat.BinData
|
||||||
|
'bd.AppendEncodedSb(sb, "base64")
|
||||||
|
|
||||||
|
'Return Convert.FromBase64String(sb.ToString)
|
||||||
|
If jsonRespString IsNot Nothing Then
|
||||||
|
Return Convert.FromBase64String(jsonRespString)
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Shared Sub setSearchParam(ByRef rest As Chilkat.Rest, ByRef company As Company)
|
Shared Sub setSearchParam(ByRef rest As Chilkat.Rest, ByRef company As Company)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user