Merge branch 'newMaster2024' of https://dev.azure.com/VeragAG/_git/SDL into newMaster2024
This commit is contained in:
@@ -67,44 +67,62 @@ Public Class cHMRC
|
|||||||
Shared Function SEND_GVMS(GVMS As VERAG_PROG_ALLGEMEIN.cGVMS, Optional updateGMR As String = "")
|
Shared Function SEND_GVMS(GVMS As VERAG_PROG_ALLGEMEIN.cGVMS, Optional updateGMR As String = "")
|
||||||
|
|
||||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||||
Dim AccessToken = ""
|
|
||||||
grantAccess(AccessToken, "write:goods-movement-system+read:pull-notifications", "AVISO")
|
|
||||||
|
|
||||||
If AccessToken <> "" Then
|
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||||
|
|
||||||
|
If TOKEN.hasEntry Then
|
||||||
|
|
||||||
|
' Dim AccessToken = ""
|
||||||
|
'grantAccess(AccessToken, "write:goods-movement-system+read:pull-notifications", "AVISO")
|
||||||
|
|
||||||
|
If TOKEN.token_BEARER_TOKEN <> "" Then
|
||||||
Dim Notification_Box_Id = ""
|
Dim Notification_Box_Id = ""
|
||||||
Dim Notification_Message_Id = ""
|
Dim Notification_Message_Id = ""
|
||||||
If genGVMS_GMR(GVMS, AccessToken, Notification_Box_Id, Notification_Message_Id, updateGMR) Then
|
If genGVMS_GMR(GVMS, TOKEN.token_BEARER_TOKEN, Notification_Box_Id, Notification_Message_Id, updateGMR) Then
|
||||||
GVMS.SAVE()
|
GVMS.SAVE()
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Shared Function GET_GVMS_LIST()
|
Shared Function GET_GVMS_LIST()
|
||||||
|
|
||||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||||
Dim AccessToken = ""
|
|
||||||
grantAccess(AccessToken, "write:goods-movement-system", "AVISO")
|
|
||||||
|
|
||||||
If AccessToken <> "" Then
|
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||||
If getGVMS_LIST(AccessToken) Then
|
|
||||||
|
If TOKEN.hasEntry Then
|
||||||
|
|
||||||
|
|
||||||
|
'Dim AccessToken = ""
|
||||||
|
'grantAccess(AccessToken, "write:goods-movement-system", "AVISO")
|
||||||
|
|
||||||
|
If TOKEN.token_BEARER_TOKEN <> "" Then
|
||||||
|
If getGVMS_LIST(TOKEN.token_BEARER_TOKEN) Then
|
||||||
MsgBox("LISTE: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
MsgBox("LISTE: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Shared Function GET_GVMS_GMR(GMR As String)
|
Shared Function GET_GVMS_GMR(GMR As String)
|
||||||
|
|
||||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||||
Dim AccessToken = ""
|
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||||
grantAccess(AccessToken, "write:goods-movement-system", "AVISO")
|
|
||||||
|
|
||||||
If AccessToken <> "" Then
|
If TOKEN.hasEntry Then
|
||||||
If getGVMS_GMR(GMR, AccessToken) Then
|
|
||||||
|
'Dim AccessToken = ""
|
||||||
|
'grantAccess(AccessToken, "write:goods-movement-system", "AVISO")
|
||||||
|
|
||||||
|
If TOKEN.token_BEARER_TOKEN <> "" Then
|
||||||
|
If getGVMS_GMR(GMR, TOKEN.token_BEARER_TOKEN) Then
|
||||||
MsgBox("GMR: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
MsgBox("GMR: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@@ -112,34 +130,43 @@ Public Class cHMRC
|
|||||||
Shared Function DELETE_GMR(GVMS As VERAG_PROG_ALLGEMEIN.cGVMS)
|
Shared Function DELETE_GMR(GVMS As VERAG_PROG_ALLGEMEIN.cGVMS)
|
||||||
|
|
||||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||||
Dim AccessToken = ""
|
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||||
grantAccess(AccessToken, "write:goods-movement-system+read:pull-notifications", "AVISO")
|
|
||||||
|
|
||||||
If AccessToken <> "" Then
|
If TOKEN.hasEntry Then
|
||||||
|
'Dim AccessToken = ""
|
||||||
|
'grantAccess(TOKEN.token_BEARER_TOKEN, "write:goods-movement-system+read:pull-notifications", "AVISO")
|
||||||
|
|
||||||
|
If TOKEN.token_BEARER_TOKEN <> "" Then
|
||||||
Dim Notification_Box_Id = ""
|
Dim Notification_Box_Id = ""
|
||||||
Dim Notification_Message_Id = ""
|
Dim Notification_Message_Id = ""
|
||||||
If delGVMS_GMR(GVMS, AccessToken, Notification_Box_Id, Notification_Message_Id) Then
|
If delGVMS_GMR(GVMS, TOKEN.token_BEARER_TOKEN, Notification_Box_Id, Notification_Message_Id) Then
|
||||||
'GVMS.delete()
|
'GVMS.delete()
|
||||||
MsgBox("GELÖSCHT: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
MsgBox("GELÖSCHT: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Shared Function GET_NOTIFICATIONS(Notification_Box_Id As String) As Boolean
|
Shared Function GET_NOTIFICATIONS(Notification_Box_Id As String) As Boolean
|
||||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||||
Dim AccessTokenNotTEST1 = grantAccessApplication("", "read:pull-notifications")
|
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||||
If AccessTokenNotTEST1 <> "" Then
|
|
||||||
getGVMS_Notifications(AccessTokenNotTEST1, Notification_Box_Id) 'Notification_Box_Id) '"877b619c-33c1-4ab6-a34f-8bd7542e0596"
|
If TOKEN.hasEntry Then
|
||||||
|
' Dim AccessTokenNotTEST1 = grantAccessApplication("", "read:pull-notifications")
|
||||||
|
' If AccessTokenNotTEST1 <> "" Then
|
||||||
|
getGVMS_Notifications(TOKEN.token_BEARER_TOKEN, Notification_Box_Id) 'Notification_Box_Id) '"877b619c-33c1-4ab6-a34f-8bd7542e0596"
|
||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
Shared Function Acknowledge_NOTIFICATIONS(Notification_Box_Id As String, Notification_Message_Id As String) As Boolean
|
Shared Function Acknowledge_NOTIFICATIONS(Notification_Box_Id As String, Notification_Message_Id As String) As Boolean
|
||||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||||
MsgBox("3")
|
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||||
Dim AccessTokenNotTEST1 = grantAccessApplication("", "write:notifications")
|
|
||||||
If AccessTokenNotTEST1 <> "" Then
|
If TOKEN.hasEntry Then
|
||||||
MsgBox("4")
|
'Dim AccessTokenNotTEST1 = grantAccessApplication("", "write:notifications")
|
||||||
getGVMS_AcknolageNotifications(AccessTokenNotTEST1, Notification_Box_Id, Notification_Message_Id) '"877b619c-33c1-4ab6-a34f-8bd7542e0596"
|
' If AccessTokenNotTEST1 <> "" Then
|
||||||
|
' MsgBox("4")
|
||||||
|
getGVMS_AcknolageNotifications(TOKEN.token_BEARER_TOKEN, Notification_Box_Id, Notification_Message_Id) '"877b619c-33c1-4ab6-a34f-8bd7542e0596"
|
||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
@@ -223,18 +250,21 @@ Public Class cHMRC
|
|||||||
|
|
||||||
'---------------------------NOTIFICATIONS---------------------------
|
'---------------------------NOTIFICATIONS---------------------------
|
||||||
|
|
||||||
Dim AccessTokenNotTEST1 = grantAccessApplication("", "read:pull-notifications")
|
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||||
If AccessTokenNotTEST1 <> "" Then
|
|
||||||
getGVMS_Notifications(AccessTokenNotTEST1, "877b619c-33c1-4ab6-a34f-8bd7542e0596")
|
If TOKEN.hasEntry Then
|
||||||
|
' Dim AccessTokenNotTEST1 = grantAccessApplication("", "read:pull-notifications")
|
||||||
|
' If AccessTokenNotTEST1 <> "" Then
|
||||||
|
getGVMS_Notifications(TOKEN.token_BEARER_TOKEN, "877b619c-33c1-4ab6-a34f-8bd7542e0596")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'-------------------------------------------------------------------
|
'-------------------------------------------------------------------
|
||||||
Exit Sub
|
Exit Sub
|
||||||
|
|
||||||
|
|
||||||
Dim AccessToken = ""
|
' Dim AccessToken = ""
|
||||||
'grantAccess(AccessToken, "write:goods-movement-system")
|
'grantAccess(AccessToken, "write:goods-movement-system")
|
||||||
grantAccess(AccessToken, "write:goods-movement-system+read:pull-notifications", "AVISO")
|
' grantAccess(AccessToken, "write:goods-movement-system+read:pull-notifications", "AVISO")
|
||||||
'getHMRC_Token(AccessToken, "write:goods-movement-system")
|
'getHMRC_Token(AccessToken, "write:goods-movement-system")
|
||||||
|
|
||||||
' MsgBox(AccessToken)
|
' MsgBox(AccessToken)
|
||||||
@@ -471,7 +501,7 @@ Public Class cHMRC
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
Shared Sub HMRC_RefreshToken(ByVal TOKEN As cHMRCToken, HMRC_APPLICATION As String)
|
Shared Sub HMRC_RefreshToken(ByRef TOKEN As cHMRCToken, HMRC_APPLICATION As String)
|
||||||
|
|
||||||
If DateDiff(DateInterval.Minute, TOKEN.token_refresh_datetime, Now) < 230 Then 'bis 240 MIN / 4hr
|
If DateDiff(DateInterval.Minute, TOKEN.token_refresh_datetime, Now) < 230 Then 'bis 240 MIN / 4hr
|
||||||
'Token ist noch frisch
|
'Token ist noch frisch
|
||||||
@@ -507,7 +537,7 @@ Public Class cHMRC
|
|||||||
|
|
||||||
' rest.AddQueryParam("scope", scope)
|
' rest.AddQueryParam("scope", scope)
|
||||||
|
|
||||||
|
MsgBox(CREDENTIALS.API_STRING)
|
||||||
' Anfrage senden
|
' Anfrage senden
|
||||||
Dim resp As Chilkat.HttpResponse = http.PostUrlEncoded(CREDENTIALS.API_STRING & "/oauth/token", req)
|
Dim resp As Chilkat.HttpResponse = http.PostUrlEncoded(CREDENTIALS.API_STRING & "/oauth/token", req)
|
||||||
|
|
||||||
@@ -535,7 +565,7 @@ Public Class cHMRC
|
|||||||
'json.EmitCompact = False
|
'json.EmitCompact = False
|
||||||
'json.WriteFile(tokenFile)
|
'json.WriteFile(tokenFile)
|
||||||
|
|
||||||
TOKEN.token_BEARER_TOKEN = newRefreshToken
|
TOKEN.token_BEARER_TOKEN = If(accessToken <> "", accessToken, newRefreshToken)
|
||||||
TOKEN.token_refresh_datetime = Now
|
TOKEN.token_refresh_datetime = Now
|
||||||
TOKEN.SAVE()
|
TOKEN.SAVE()
|
||||||
|
|
||||||
@@ -1505,9 +1535,8 @@ Public Class cHMRC
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
If forceNewToken OrElse TOKEN.hasEntry = False OrElse TOKEN.token_BEARER_TOKEN = "" Then
|
If forceNewToken OrElse TOKEN.hasEntry = False OrElse TOKEN.token_BEARER_TOKEN Is Nothing OrElse TOKEN.token_BEARER_TOKEN = "" Then
|
||||||
Dim AccessToken = ""
|
Dim AccessToken = ""
|
||||||
|
|
||||||
grantAccess(AccessToken, appl, HMRC_APPLICATION)
|
grantAccess(AccessToken, appl, HMRC_APPLICATION)
|
||||||
TOKEN.token_Application = APPLICATION
|
TOKEN.token_Application = APPLICATION
|
||||||
TOKEN.token_BEARER_TOKEN = AccessToken
|
TOKEN.token_BEARER_TOKEN = AccessToken
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
Imports VERAG_PROG_ALLGEMEIN.CC015B_TR_EXT_V4_3
|
Imports Org.BouncyCastle.Ocsp
|
||||||
|
Imports VERAG_PROG_ALLGEMEIN.CC015B_TR_EXT_V4_3
|
||||||
Imports VERAG_PROG_ALLGEMEIN.ENS_CC315A
|
Imports VERAG_PROG_ALLGEMEIN.ENS_CC315A
|
||||||
|
|
||||||
Public Class cHMRC_ENS
|
Public Class cHMRC_ENS
|
||||||
@@ -13,6 +14,7 @@ Public Class cHMRC_ENS
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Shared Function helloWorldENS(ByVal response As String) As Boolean
|
Shared Function helloWorldENS(ByVal response As String) As Boolean
|
||||||
|
|
||||||
|
|
||||||
@@ -29,18 +31,16 @@ Public Class cHMRC_ENS
|
|||||||
' HTTP-Client initialisieren
|
' HTTP-Client initialisieren
|
||||||
Dim http As New Chilkat.Http
|
Dim http As New Chilkat.Http
|
||||||
|
|
||||||
' HMRC OAuth2 Access Token (muss vorher abgerufen werden)
|
|
||||||
Dim accessToken As String = "YOUR_ACCESS_TOKEN"
|
|
||||||
|
|
||||||
' Falls das Token fehlt, Hinweis ausgeben
|
' Falls das Token fehlt, Hinweis ausgeben
|
||||||
If String.IsNullOrEmpty(accessToken) Then
|
If String.IsNullOrEmpty(TOKEN.token_BEARER_TOKEN) Then
|
||||||
Console.WriteLine("Fehler: Kein OAuth2-Token gefunden!")
|
Console.WriteLine("Fehler: Kein OAuth2-Token gefunden!")
|
||||||
Return False
|
Return False
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Setze die benötigten Header
|
' Setze die benötigten Header
|
||||||
http.SetRequestHeader("Authorization", "Bearer " & accessToken)
|
http.SetRequestHeader("Accept", "application/vnd.hmrc.1.0+xml")
|
||||||
http.SetRequestHeader("Accept", "application/vnd.hmrc.1.0+json")
|
http.SetRequestHeader("Content-Type", "application/xml; charset=UTF-8")
|
||||||
|
http.SetRequestHeader("Authorization", "Bearer " & TOKEN.token_BEARER_TOKEN)
|
||||||
|
|
||||||
' API-Endpunkt für User-Restricted Hello API
|
' API-Endpunkt für User-Restricted Hello API
|
||||||
Dim url As String = "https://test-api.service.hmrc.gov.uk/hello/application"
|
Dim url As String = "https://test-api.service.hmrc.gov.uk/hello/application"
|
||||||
@@ -52,8 +52,10 @@ Public Class cHMRC_ENS
|
|||||||
' Fehlerbehandlung
|
' Fehlerbehandlung
|
||||||
If (http.LastMethodSuccess <> True) Then
|
If (http.LastMethodSuccess <> True) Then
|
||||||
Console.WriteLine("Fehler: " & http.LastErrorText)
|
Console.WriteLine("Fehler: " & http.LastErrorText)
|
||||||
|
MsgBox("Fehler: " & http.LastErrorText)
|
||||||
Else
|
Else
|
||||||
Console.WriteLine("Antwort von HMRC API: " & response)
|
Console.WriteLine("Antwort von HMRC API: " & response)
|
||||||
|
MsgBox("Antwort von HMRC API: " & response)
|
||||||
End If
|
End If
|
||||||
Return True
|
Return True
|
||||||
End If
|
End If
|
||||||
@@ -73,7 +75,7 @@ Public Class cHMRC_ENS
|
|||||||
Else
|
Else
|
||||||
url = "api.service.hmrc.gov.uk"
|
url = "api.service.hmrc.gov.uk"
|
||||||
End If
|
End If
|
||||||
|
MsgBox(url)
|
||||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||||
|
|
||||||
'-------------------------------------------------------
|
'-------------------------------------------------------
|
||||||
@@ -96,7 +98,7 @@ Public Class cHMRC_ENS
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dim TOKEN = cHMRC.getTOKEN("ENS")
|
Dim TOKEN = cHMRC.getTOKEN("ENS", True)
|
||||||
|
|
||||||
If TOKEN.hasEntry Then
|
If TOKEN.hasEntry Then
|
||||||
|
|
||||||
@@ -118,7 +120,7 @@ Public Class cHMRC_ENS
|
|||||||
req.LoadBodyFromString(ENS_CC315A.Serialize, "utf-8")
|
req.LoadBodyFromString(ENS_CC315A.Serialize, "utf-8")
|
||||||
|
|
||||||
' Füge benötigte Header hinzu
|
' Füge benötigte Header hinzu
|
||||||
req.AddHeader("Accept", "application/x-www-form-urlencoded") '"application/vnd.hmrc.1.0+xml")
|
req.AddHeader("Accept", "application/vnd.hmrc.1.0+xml") '"application/vnd.hmrc.1.0+xml")
|
||||||
req.AddHeader("Content-Type", "application/xml; charset=UTF-8") '"application/xml")
|
req.AddHeader("Content-Type", "application/xml; charset=UTF-8") '"application/xml")
|
||||||
req.AddHeader("Authorization", "Bearer " & TOKEN.token_BEARER_TOKEN)
|
req.AddHeader("Authorization", "Bearer " & TOKEN.token_BEARER_TOKEN)
|
||||||
' req.AddHeader("Gov-Client-Connection-Method", "WEB_APP_VIA_SERVER")
|
' req.AddHeader("Gov-Client-Connection-Method", "WEB_APP_VIA_SERVER")
|
||||||
|
|||||||
Reference in New Issue
Block a user