Merge branch 'newMaster2024' of https://dev.azure.com/VeragAG/_git/SDL into newMaster2024
This commit is contained in:
@@ -67,42 +67,60 @@ Public Class cHMRC
|
||||
Shared Function SEND_GVMS(GVMS As VERAG_PROG_ALLGEMEIN.cGVMS, Optional updateGMR As String = "")
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
Dim AccessToken = ""
|
||||
grantAccess(AccessToken, "write:goods-movement-system+read:pull-notifications", "AVISO")
|
||||
|
||||
If AccessToken <> "" Then
|
||||
Dim Notification_Box_Id = ""
|
||||
Dim Notification_Message_Id = ""
|
||||
If genGVMS_GMR(GVMS, AccessToken, Notification_Box_Id, Notification_Message_Id, updateGMR) Then
|
||||
GVMS.SAVE()
|
||||
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_Message_Id = ""
|
||||
If genGVMS_GMR(GVMS, TOKEN.token_BEARER_TOKEN, Notification_Box_Id, Notification_Message_Id, updateGMR) Then
|
||||
GVMS.SAVE()
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
Shared Function GET_GVMS_LIST()
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
Dim AccessToken = ""
|
||||
grantAccess(AccessToken, "write:goods-movement-system", "AVISO")
|
||||
|
||||
If AccessToken <> "" Then
|
||||
If getGVMS_LIST(AccessToken) Then
|
||||
MsgBox("LISTE: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
||||
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||
|
||||
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)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Shared Function GET_GVMS_GMR(GMR As String)
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
Dim AccessToken = ""
|
||||
grantAccess(AccessToken, "write:goods-movement-system", "AVISO")
|
||||
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||
|
||||
If AccessToken <> "" Then
|
||||
If getGVMS_GMR(GMR, AccessToken) Then
|
||||
MsgBox("GMR: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
||||
If TOKEN.hasEntry 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)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -112,15 +130,19 @@ Public Class cHMRC
|
||||
Shared Function DELETE_GMR(GVMS As VERAG_PROG_ALLGEMEIN.cGVMS)
|
||||
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
Dim AccessToken = ""
|
||||
grantAccess(AccessToken, "write:goods-movement-system+read:pull-notifications", "AVISO")
|
||||
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||
|
||||
If AccessToken <> "" Then
|
||||
Dim Notification_Box_Id = ""
|
||||
Dim Notification_Message_Id = ""
|
||||
If delGVMS_GMR(GVMS, AccessToken, Notification_Box_Id, Notification_Message_Id) Then
|
||||
'GVMS.delete()
|
||||
MsgBox("GELÖSCHT: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
||||
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_Message_Id = ""
|
||||
If delGVMS_GMR(GVMS, TOKEN.token_BEARER_TOKEN, Notification_Box_Id, Notification_Message_Id) Then
|
||||
'GVMS.delete()
|
||||
MsgBox("GELÖSCHT: " & Now.ToShortDateString & " " & Now.ToShortTimeString)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -128,18 +150,23 @@ Public Class cHMRC
|
||||
|
||||
Shared Function GET_NOTIFICATIONS(Notification_Box_Id As String) As Boolean
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
Dim AccessTokenNotTEST1 = grantAccessApplication("", "read:pull-notifications")
|
||||
If AccessTokenNotTEST1 <> "" Then
|
||||
getGVMS_Notifications(AccessTokenNotTEST1, Notification_Box_Id) 'Notification_Box_Id) '"877b619c-33c1-4ab6-a34f-8bd7542e0596"
|
||||
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||
|
||||
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 Function
|
||||
Shared Function Acknowledge_NOTIFICATIONS(Notification_Box_Id As String, Notification_Message_Id As String) As Boolean
|
||||
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
|
||||
MsgBox("3")
|
||||
Dim AccessTokenNotTEST1 = grantAccessApplication("", "write:notifications")
|
||||
If AccessTokenNotTEST1 <> "" Then
|
||||
MsgBox("4")
|
||||
getGVMS_AcknolageNotifications(AccessTokenNotTEST1, Notification_Box_Id, Notification_Message_Id) '"877b619c-33c1-4ab6-a34f-8bd7542e0596"
|
||||
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||
|
||||
If TOKEN.hasEntry Then
|
||||
'Dim AccessTokenNotTEST1 = grantAccessApplication("", "write:notifications")
|
||||
' 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 Function
|
||||
|
||||
@@ -223,18 +250,21 @@ Public Class cHMRC
|
||||
|
||||
'---------------------------NOTIFICATIONS---------------------------
|
||||
|
||||
Dim AccessTokenNotTEST1 = grantAccessApplication("", "read:pull-notifications")
|
||||
If AccessTokenNotTEST1 <> "" Then
|
||||
getGVMS_Notifications(AccessTokenNotTEST1, "877b619c-33c1-4ab6-a34f-8bd7542e0596")
|
||||
Dim TOKEN = cHMRC.getTOKEN("GVMS")
|
||||
|
||||
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
|
||||
|
||||
'-------------------------------------------------------------------
|
||||
Exit Sub
|
||||
|
||||
|
||||
Dim AccessToken = ""
|
||||
' Dim AccessToken = ""
|
||||
'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")
|
||||
|
||||
' MsgBox(AccessToken)
|
||||
@@ -471,7 +501,7 @@ Public Class cHMRC
|
||||
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
|
||||
'Token ist noch frisch
|
||||
@@ -507,7 +537,7 @@ Public Class cHMRC
|
||||
|
||||
' rest.AddQueryParam("scope", scope)
|
||||
|
||||
|
||||
MsgBox(CREDENTIALS.API_STRING)
|
||||
' Anfrage senden
|
||||
Dim resp As Chilkat.HttpResponse = http.PostUrlEncoded(CREDENTIALS.API_STRING & "/oauth/token", req)
|
||||
|
||||
@@ -535,7 +565,7 @@ Public Class cHMRC
|
||||
'json.EmitCompact = False
|
||||
'json.WriteFile(tokenFile)
|
||||
|
||||
TOKEN.token_BEARER_TOKEN = newRefreshToken
|
||||
TOKEN.token_BEARER_TOKEN = If(accessToken <> "", accessToken, newRefreshToken)
|
||||
TOKEN.token_refresh_datetime = Now
|
||||
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 = ""
|
||||
|
||||
grantAccess(AccessToken, appl, HMRC_APPLICATION)
|
||||
TOKEN.token_Application = APPLICATION
|
||||
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
|
||||
|
||||
Public Class cHMRC_ENS
|
||||
@@ -13,6 +14,7 @@ Public Class cHMRC_ENS
|
||||
|
||||
|
||||
|
||||
|
||||
Shared Function helloWorldENS(ByVal response As String) As Boolean
|
||||
|
||||
|
||||
@@ -29,18 +31,16 @@ Public Class cHMRC_ENS
|
||||
' HTTP-Client initialisieren
|
||||
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
|
||||
If String.IsNullOrEmpty(accessToken) Then
|
||||
If String.IsNullOrEmpty(TOKEN.token_BEARER_TOKEN) Then
|
||||
Console.WriteLine("Fehler: Kein OAuth2-Token gefunden!")
|
||||
Return False
|
||||
End If
|
||||
|
||||
' Setze die benötigten Header
|
||||
http.SetRequestHeader("Authorization", "Bearer " & accessToken)
|
||||
http.SetRequestHeader("Accept", "application/vnd.hmrc.1.0+json")
|
||||
http.SetRequestHeader("Accept", "application/vnd.hmrc.1.0+xml")
|
||||
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
|
||||
Dim url As String = "https://test-api.service.hmrc.gov.uk/hello/application"
|
||||
@@ -52,8 +52,10 @@ Public Class cHMRC_ENS
|
||||
' Fehlerbehandlung
|
||||
If (http.LastMethodSuccess <> True) Then
|
||||
Console.WriteLine("Fehler: " & http.LastErrorText)
|
||||
MsgBox("Fehler: " & http.LastErrorText)
|
||||
Else
|
||||
Console.WriteLine("Antwort von HMRC API: " & response)
|
||||
MsgBox("Antwort von HMRC API: " & response)
|
||||
End If
|
||||
Return True
|
||||
End If
|
||||
@@ -73,7 +75,7 @@ Public Class cHMRC_ENS
|
||||
Else
|
||||
url = "api.service.hmrc.gov.uk"
|
||||
End If
|
||||
|
||||
MsgBox(url)
|
||||
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
|
||||
|
||||
@@ -118,7 +120,7 @@ Public Class cHMRC_ENS
|
||||
req.LoadBodyFromString(ENS_CC315A.Serialize, "utf-8")
|
||||
|
||||
' 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("Authorization", "Bearer " & TOKEN.token_BEARER_TOKEN)
|
||||
' req.AddHeader("Gov-Client-Connection-Method", "WEB_APP_VIA_SERVER")
|
||||
|
||||
Reference in New Issue
Block a user