Verträge Suche, modal API, Fremd BRG not found
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
Imports System.Data
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.IO
|
||||
Imports System.Linq
|
||||
|
||||
Imports System.Net
|
||||
Imports System.Net.Http
|
||||
Imports System.Text
|
||||
Imports System.Threading.Tasks
|
||||
Imports com.sun.tools.doclets.internal.toolkit.util
|
||||
Imports sun.net.www.http
|
||||
|
||||
|
||||
|
||||
@@ -49,13 +55,27 @@ Public Class frmZollBrgBuchungenFremd
|
||||
row.Cells("Agent").Value = hit.Firma
|
||||
row.Cells("Comment").Value = ""
|
||||
Else
|
||||
' Falls nicht gefunden, optional leeren:
|
||||
row.Cells("Datum").Value = Nothing
|
||||
row.Cells("CustomsOfficeOfDestination").Value = Nothing
|
||||
row.Cells("PlateNumber").Value = Nothing
|
||||
row.Cells("Customer").Value = Nothing
|
||||
row.Cells("Agent").Value = Nothing
|
||||
row.Cells("Comment").Value = "Not found"
|
||||
|
||||
Dim result As Boolean = NctsChecker.HasNoInfo(key)
|
||||
|
||||
If result Then
|
||||
' Falls nicht gefunden, optional leeren:
|
||||
row.Cells("Datum").Value = Nothing
|
||||
row.Cells("CustomsOfficeOfDestination").Value = Nothing
|
||||
row.Cells("PlateNumber").Value = Nothing
|
||||
row.Cells("Customer").Value = Nothing
|
||||
row.Cells("Agent").Value = Nothing
|
||||
row.Cells("Comment").Value = "Not found"
|
||||
Else
|
||||
' Falls nicht gefunden, optional leeren:
|
||||
row.Cells("Datum").Value = Nothing
|
||||
row.Cells("CustomsOfficeOfDestination").Value = Nothing
|
||||
row.Cells("PlateNumber").Value = Nothing
|
||||
row.Cells("Customer").Value = Nothing
|
||||
row.Cells("Agent").Value = Nothing
|
||||
row.Cells("Comment").Value = "?????"
|
||||
End If
|
||||
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
@@ -229,4 +249,45 @@ Public Class frmZollBrgBuchungenFremd
|
||||
End Sub
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class NctsChecker
|
||||
' WICHTIG: direkt mrn_list.jsp, nicht mrn_home.jsp
|
||||
Private Shared ReadOnly baseUrl As String = "https://ec.europa.eu/taxation_customs/dds2/mrn/mrn_list.jsp?Lang=en&MRN="
|
||||
|
||||
''' <summary>
|
||||
''' True = Seite meldet "No information found that satisfies the request."
|
||||
''' False = Daten vorhanden ODER Fehler beim Abruf
|
||||
''' </summary>
|
||||
Public Shared Function HasNoInfo(mrn As String) As Boolean
|
||||
Dim url As String = baseUrl & mrn.Trim()
|
||||
|
||||
Try
|
||||
Dim request As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
|
||||
request.Method = "GET"
|
||||
request.UserAgent = "Mozilla/5.0"
|
||||
|
||||
Using response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
|
||||
Using reader As New StreamReader(response.GetResponseStream(), Encoding.UTF8)
|
||||
Dim html As String = reader.ReadToEnd()
|
||||
|
||||
' Debug: HTML ansehen
|
||||
' File.WriteAllText("C:\temp\ncts_" & mrn & ".html", html)
|
||||
|
||||
' Hier auf den bekannten Text prüfen
|
||||
If html.Contains("No information found that satisfies the request.") Then
|
||||
Return True ' -> keine Information
|
||||
Else
|
||||
Return False ' -> irgendwas gefunden
|
||||
End If
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Catch ex As Exception
|
||||
' Im Fehlerfall: wie gewünscht behandeln
|
||||
' Wenn du bei Fehler lieber auch "keine Info" zurückgeben willst, hier True setzen.
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user