offerten, Bonit, Kundenuebersicht
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.IO
|
||||
Imports System.Net
|
||||
Imports System.Numerics
|
||||
Imports System.Reflection
|
||||
@@ -8,6 +9,7 @@ Imports System.Text.RegularExpressions
|
||||
Imports System.Threading
|
||||
Imports System.Web.UI
|
||||
Imports Microsoft.VisualBasic.ApplicationServices
|
||||
Imports Org.BouncyCastle.Ocsp
|
||||
|
||||
|
||||
Public Class cCreditSafeAPI
|
||||
@@ -100,7 +102,7 @@ Public Class cCreditSafeAPI
|
||||
|
||||
|
||||
|
||||
Shared Function SendGetRequestWithAuthHeader(url As String, company As Company, acceptContentType As String, method As String, authenticationToken As String, ByRef failureDesc As String, Optional isMonitoring As Boolean = False) As String
|
||||
Shared Function SendGetRequestWithAuthHeader(url As String, company As Company, acceptContentType As String, method As String, authenticationToken As String, ByRef failureDesc As String, Optional isMonitoring As Boolean = False, Optional csvImport As Boolean = False, Optional csvFile As String = "") As String
|
||||
Try
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
@@ -127,9 +129,16 @@ Public Class cCreditSafeAPI
|
||||
|
||||
End If
|
||||
|
||||
rest.AddHeader("Content-Type", "application/json")
|
||||
If isMonitoring AndAlso csvFile <> "" Then
|
||||
rest.PartSelector = "0"
|
||||
rest.AddHeader("Content-Type", "multipart/form-data")
|
||||
rest.AddHeader("Expect", "100-continue")
|
||||
Else
|
||||
rest.AddHeader("Content-Type", "application/json")
|
||||
rest.AddHeader("Accept", acceptContentType)
|
||||
End If
|
||||
|
||||
rest.AddHeader("Authorization", "Bearer " & authenticationToken)
|
||||
rest.AddHeader("Accept", acceptContentType)
|
||||
|
||||
|
||||
Dim responseJson As String
|
||||
@@ -137,38 +146,75 @@ Public Class cCreditSafeAPI
|
||||
|
||||
If isMonitoring Then
|
||||
|
||||
If csvImport Then
|
||||
Dim fileInfo As New FileInfo(csvFile)
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
success = json.UpdateString("id", company.creditSafeId)
|
||||
success = json.UpdateString("personalReference", "VERAG AG")
|
||||
success = json.UpdateString("freeText", "hinzugefügt am " & Today.ToShortDateString)
|
||||
success = json.UpdateString("personalLimit", "")
|
||||
Dim content As String = File.ReadAllText(csvFile)
|
||||
'content = content.Replace(";", ",")
|
||||
'File.WriteAllText(csvFile, content)
|
||||
|
||||
Debug.WriteLine(json.Emit())
|
||||
Dim fileStream As New Chilkat.Stream
|
||||
fileStream.SourceFile = csvFile
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
json.EmitSb(sbRequestBody)
|
||||
rest.PartSelector = "1"
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
success = rest.FullRequestSb(method, url, sbRequestBody, sbResponseBody)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
failureDesc = rest.LastErrorText
|
||||
Return failureDesc
|
||||
rest.AddHeader("Content-Disposition", "form-data; name=""importcsv""")
|
||||
rest.AddHeader("Content-Type", "file")
|
||||
'rest.SetMultipartBodyString(content)
|
||||
rest.SetMultipartBodyStream(fileStream)
|
||||
|
||||
Else
|
||||
rest.PartSelector = "0"
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
failureDesc = rest.ResponseStatusText & IIf(responseJson <> "", vbNewLine & responseJson, "")
|
||||
Dim strResponseBody As String = rest.FullRequestMultipart(method, url.Replace(API_STRING, ""))
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
failureDesc = rest.LastErrorText
|
||||
Return failureDesc
|
||||
Else
|
||||
|
||||
Return responseJson
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
failureDesc = rest.ResponseStatusText & IIf(responseJson <> "", vbNewLine & responseJson, "")
|
||||
Return failureDesc
|
||||
Else
|
||||
|
||||
Return responseJson
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
Else
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
success = json.UpdateString("id", company.creditSafeId)
|
||||
success = json.UpdateString("personalReference", "VERAG AG")
|
||||
success = json.UpdateString("freeText", "hinzugefügt am " & Today.ToShortDateString)
|
||||
success = json.UpdateString("personalLimit", "")
|
||||
|
||||
Debug.WriteLine(json.Emit())
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
json.EmitSb(sbRequestBody)
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
success = rest.FullRequestSb(method, url, sbRequestBody, sbResponseBody)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
failureDesc = rest.LastErrorText
|
||||
Return failureDesc
|
||||
|
||||
Else
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
failureDesc = rest.ResponseStatusText & IIf(responseJson <> "", vbNewLine & responseJson, "")
|
||||
Return failureDesc
|
||||
Else
|
||||
|
||||
Return responseJson
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
@@ -264,6 +310,16 @@ Public Class cCreditSafeAPI
|
||||
End Function
|
||||
|
||||
|
||||
Shared Function AddCompaniesCSVToPortfolio(csvFilePath As String, Optional PortfolioID As String = "1662419") As String
|
||||
|
||||
Dim myUri As String = API_STRING & "/v1/monitoring/portfolios/" & PortfolioID & "/import" 'Default
|
||||
|
||||
Dim jsonRespString = SendGetRequestWithAuthHeader(myUri, Nothing, "application/json", "POST", token, "", True, True, csvFilePath)
|
||||
|
||||
Return jsonRespString
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Shared Function searchCompanies(company As Company, ByRef dataTable As DataTable) As String
|
||||
|
||||
@@ -406,6 +462,11 @@ Public Class cCreditSafeAPI
|
||||
|
||||
Dim numCompanies As Integer = companieData.Size
|
||||
|
||||
Dim CL As Double = -1
|
||||
Dim CR As Integer = -1
|
||||
Dim CL_Date As Date = company.lastChecked
|
||||
Dim CR_Date As Date = company.lastChecked
|
||||
|
||||
For i = 0 To 1
|
||||
|
||||
|
||||
@@ -481,8 +542,10 @@ Public Class cCreditSafeAPI
|
||||
If cEvent.newValue IsNot Nothing AndAlso IsNumeric(cEvent.newValue) AndAlso Not cEvent.newValue.ToString.Contains("€") Then
|
||||
If cEvent.localEventCode = "CL" Or cEvent.globalEventCode = "CL" Then
|
||||
cEvent.newValueCL = cEvent.newValue
|
||||
setCL_CR_Entry(CDate(cEvent.eventDate), "CL", cEvent.newValueCL, CL, CR, CL_Date, CR_Date)
|
||||
ElseIf cEvent.localEventCode = "CR" Or cEvent.globalEventCode = "CR" Then
|
||||
cEvent.newValueCR = cEvent.newValue
|
||||
setCL_CR_Entry(CDate(cEvent.eventDate), "CR", cEvent.newValueCR, CL, CR, CL_Date, CR_Date)
|
||||
End If
|
||||
Else
|
||||
|
||||
@@ -490,11 +553,13 @@ Public Class cCreditSafeAPI
|
||||
cEvent.newValue = Regex.Replace(cEvent.newValue, "\s+", "")
|
||||
cEvent.newValue = Regex.Replace(cEvent.newValue, "[^\d]", "")
|
||||
cEvent.newValueCL = cEvent.newValue
|
||||
setCL_CR_Entry(CDate(cEvent.eventDate), "CL", cEvent.newValueCL, CL, CR, CL_Date, CR_Date)
|
||||
|
||||
ElseIf cEvent.localEventCode = "CR" Or cEvent.globalEventCode = "CR" Then
|
||||
cEvent.newValue = Regex.Replace(cEvent.newValue, "\s+", "")
|
||||
cEvent.newValue = Regex.Replace(cEvent.newValue, "[^\d]", "")
|
||||
cEvent.newValueCR = cEvent.newValue
|
||||
setCL_CR_Entry(CDate(cEvent.eventDate), "CR", cEvent.newValueCR, CL, CR, CL_Date, CR_Date)
|
||||
End If
|
||||
|
||||
End If
|
||||
@@ -511,15 +576,68 @@ Public Class cCreditSafeAPI
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
If dtEvents.Rows.Count > 1 Then
|
||||
dtEvents.DefaultView.Sort = "eventDate ASC"
|
||||
dtEvents = dtEvents.DefaultView.ToTable
|
||||
'viewEvents = New DataView(dtEvents, "localEventCode IN ('CL','CR') or e.globalEventCode IN ('CL','CR')", "", DataViewRowState.CurrentRows)
|
||||
End If
|
||||
|
||||
If company.kdNr > 0 Then
|
||||
Dim KUNDE As New cKunde(company.kdNr)
|
||||
|
||||
If KUNDE.Bonitätsdatum <= CL_Date Or KUNDE.Bonitätsdatum <= CR_Date Then
|
||||
|
||||
If KUNDE.Bonität <> CR Then
|
||||
KUNDE.Bonität = CR
|
||||
KUNDE.Bonitätsdatum = CDate(CR_Date)
|
||||
End If
|
||||
|
||||
If KUNDE.Höchstkredit <> CL Then
|
||||
KUNDE.Höchstkredit = CL
|
||||
KUNDE.Bonitätsdatum = CDate(CL_Date)
|
||||
End If
|
||||
|
||||
KUNDE.SAVE()
|
||||
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Return "Anzahl gefundener Datensätze: " & numCompanies
|
||||
|
||||
End Function
|
||||
|
||||
Private Shared Sub setCL_CR_Entry(cs_date As Date, type As String, value As Object, CL As Double, CR As Integer, CL_Date As Date, CR_Date As Date)
|
||||
|
||||
Select Case type
|
||||
|
||||
Case "CR"
|
||||
Dim saveCR As Boolean = False
|
||||
If CR_Date <= cs_date Then
|
||||
cs_date = CR_Date
|
||||
saveCR = True
|
||||
End If
|
||||
|
||||
If saveCR Then CR = value
|
||||
|
||||
Case "CL"
|
||||
Dim saveCL As Boolean = False
|
||||
If CL_Date <= cs_date Then
|
||||
cs_date = CL_Date
|
||||
saveCL = True
|
||||
End If
|
||||
|
||||
If saveCL Then CL = value
|
||||
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
|
||||
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 & "/"
|
||||
@@ -878,6 +996,7 @@ Public Class cCreditSafeAPI
|
||||
|
||||
Public Property creditSafeId As String
|
||||
Public Property name As String
|
||||
Public Property kdNr As Integer
|
||||
Public Property vatNo As String
|
||||
Public Property country As String
|
||||
Public Property creditsafeNo As String
|
||||
@@ -903,7 +1022,7 @@ Public Class cCreditSafeAPI
|
||||
|
||||
|
||||
|
||||
Public Sub New(_language As String, _name As String, _vatNo As String, _country As String, _creditsafeNo As String, _creditSafeId As String, _lastChecked As Date, _street As String, _postalCode As String, _city As String, _sumEmployees As String, _businessPurpose As String, _shareholder As String, _ceo As String, _bank As String, _csTurnover As String)
|
||||
Public Sub New(_language As String, _name As String, _vatNo As String, _country As String, _creditsafeNo As String, _creditSafeId As String, _lastChecked As Date, _street As String, _postalCode As String, _city As String, _sumEmployees As String, _businessPurpose As String, _shareholder As String, _ceo As String, _bank As String, _csTurnover As String, _kdNr As Integer)
|
||||
creditSafeId = _creditSafeId
|
||||
name = _name
|
||||
vatNo = _vatNo
|
||||
@@ -920,6 +1039,7 @@ Public Class cCreditSafeAPI
|
||||
csBank = _bank
|
||||
language = _language
|
||||
csTurnover = _csTurnover
|
||||
kdNr = _kdNr
|
||||
End Sub
|
||||
|
||||
Public Sub New()
|
||||
|
||||
Reference in New Issue
Block a user