This commit is contained in:
2025-02-19 10:47:45 +01:00
parent 2bb9d5691e
commit 5611778265
2 changed files with 84 additions and 53 deletions

View File

@@ -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