From 255f7a50f48071029836a09892b094344d64727b Mon Sep 17 00:00:00 2001 From: "m.ilhan" Date: Wed, 19 Mar 2025 15:33:35 +0100 Subject: [PATCH] =?UTF-8?q?klassen=20f=C3=BCr=20ens=20angepasst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ATEZ/NCTS_API/NCTS-P5/CC015C.Designer.vb | 80 +- .../HMRC/ENS/CC315A-v11-2.Designer.vb | 92 +- .../HMRC/ENS/CC328A/CC304A-v10-0.Designer.vb | 90 +- .../HMRC/ENS/CC328A/CC305A-v10-0.Designer.vb | 58 +- .../HMRC/ENS/CC328A/CC316A-v10-0.Designer.vb | 28 +- .../HMRC/ENS/CC328A/CC328A-v10-0.Designer.vb | 80 +- VERAG_PROG_ALLGEMEIN/Schnittstellen/cHMRC.vb | 1715 +++++++++++++++++ .../VERAG_PROG_ALLGEMEIN.vbproj | 2 +- 8 files changed, 1932 insertions(+), 213 deletions(-) create mode 100644 VERAG_PROG_ALLGEMEIN/Schnittstellen/cHMRC.vb diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/NCTS_API/NCTS-P5/CC015C.Designer.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/NCTS_API/NCTS-P5/CC015C.Designer.vb index 36cee9cc..02af0e72 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/NCTS_API/NCTS-P5/CC015C.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/NCTS_API/NCTS-P5/CC015C.Designer.vb @@ -805,7 +805,7 @@ Namespace NCTS_P5_CC015C Me._transitOperation = New TransitOperationType06() End Sub - + Public Property messageSender() As String Get Return Me._messageSender @@ -815,7 +815,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property messageRecipient() As String Get Return Me._messageRecipient @@ -835,7 +835,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property messageIdentification() As String Get Return Me._messageIdentification @@ -855,7 +855,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property correlationIdentifier() As String Get Return Me._correlationIdentifier @@ -1359,7 +1359,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property declarationType() As String Get Return Me._declarationType @@ -1369,7 +1369,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property additionalDeclarationType() As String Get Return Me._additionalDeclarationType @@ -1399,7 +1399,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property security() As String Get Return Me._security @@ -1419,7 +1419,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property specificCircumstanceIndicator() As String Get Return Me._specificCircumstanceIndicator @@ -1651,7 +1651,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property type() As String Get Return Me._type @@ -3033,7 +3033,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property phoneNumber() As String Get Return Me._phoneNumber @@ -3238,7 +3238,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property status() As String Get Return Me._status @@ -3689,7 +3689,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property currency() As String Get Return Me._currency @@ -3965,7 +3965,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property inlandModeOfTransport() As String Get Return Me._inlandModeOfTransport @@ -3975,7 +3975,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property modeOfTransportAtTheBorder() As String Get Return Me._modeOfTransportAtTheBorder @@ -4981,7 +4981,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property role() As String Get Return Me._role @@ -5803,7 +5803,7 @@ Namespace NCTS_P5_CC015C Me._customsOffice = New CustomsOfficeType02() End Sub - + Public Property typeOfLocation() As String Get Return Me._typeOfLocation @@ -5813,7 +5813,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property qualifierOfIdentification() As String Get Return Me._qualifierOfIdentification @@ -5843,7 +5843,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property UNLocode() As String Get Return Me._uNLocode @@ -7045,7 +7045,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property phoneNumber() As String Get Return Me._phoneNumber @@ -7247,7 +7247,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property typeOfIdentification() As String Get Return Me._typeOfIdentification @@ -7651,7 +7651,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property customsOfficeAtBorderReferenceNumber() As String Get Return Me._customsOfficeAtBorderReferenceNumber @@ -7661,7 +7661,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property typeOfIdentification() As String Get Return Me._typeOfIdentification @@ -7871,7 +7871,7 @@ Namespace NCTS_P5_CC015C Private Shared _serializerXml As XmlSerializer #End Region - + Public Property UNLocode() As String Get Return Me._uNLocode @@ -8071,7 +8071,7 @@ Namespace NCTS_P5_CC015C Private Shared _serializerXml As XmlSerializer #End Region - + Public Property UNLocode() As String Get Return Me._uNLocode @@ -8283,7 +8283,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property type() As String Get Return Me._type @@ -8497,7 +8497,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property type() As String Get Return Me._type @@ -8717,7 +8717,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property type() As String Get Return Me._type @@ -8917,7 +8917,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property type() As String Get Return Me._type @@ -9117,7 +9117,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property code() As String Get Return Me._code @@ -9866,7 +9866,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property typeOfIdentification() As String Get Return Me._typeOfIdentification @@ -10078,7 +10078,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property type() As String Get Return Me._type @@ -10338,7 +10338,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property declarationType() As String Get Return Me._declarationType @@ -11086,7 +11086,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property cusCode() As String Get Return Me._cusCode @@ -11294,7 +11294,7 @@ Namespace NCTS_P5_CC015C Private Shared _serializerXml As XmlSerializer #End Region - + Public Property harmonizedSystemSubHeadingCode() As String Get Return Me._harmonizedSystemSubHeadingCode @@ -11492,7 +11492,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property UNNumber() As String Get Return Me._uNNumber @@ -11884,7 +11884,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property typeOfPackages() As String Get Return Me._typeOfPackages @@ -12106,7 +12106,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property type() As String Get Return Me._type @@ -12136,7 +12136,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property typeOfPackages() As String Get Return Me._typeOfPackages @@ -12156,7 +12156,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property measurementUnitAndQualifier() As String Get Return Me._measurementUnitAndQualifier @@ -12366,7 +12366,7 @@ Namespace NCTS_P5_CC015C End Set End Property - + Public Property type() As String Get Return Me._type diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC315A-v11-2.Designer.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC315A-v11-2.Designer.vb index 28e0dc83..df9c5792 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC315A-v11-2.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC315A-v11-2.Designer.vb @@ -224,6 +224,7 @@ Namespace ENS_CC315A End Set End Property + Public Property CUSOFFLON() As CUSOFFLONType Get @@ -264,6 +265,7 @@ Namespace ENS_CC315A End Set End Property + Public Property CUSOFFFENT730() As CUSOFFFENT730Type Get @@ -284,6 +286,7 @@ Namespace ENS_CC315A End Set End Property + Public Property TRACARENT601() As TRACARENT601Type Get @@ -307,28 +310,28 @@ Namespace ENS_CC315A ''' Test whether GOOITEGDS should be serialized ''' Public Overridable Function ShouldSerializeGOOITEGDS() As Boolean - Return GOOITEGDS IsNot Nothing And GOOITEGDS.Count > 0 + Return GOOITEGDS IsNot Nothing AndAlso GOOITEGDS.Count > 0 End Function ''' ''' Test whether ITI should be serialized ''' Public Overridable Function ShouldSerializeITI() As Boolean - Return ITI IsNot Nothing And ITI.Count > 0 + Return ITI IsNot Nothing AndAlso ITI.Count > 0 End Function ''' ''' Test whether SEAID529 should be serialized ''' Public Overridable Function ShouldSerializeSEAID529() As Boolean - Return SEAID529 IsNot Nothing And SEAID529.Count > 0 + Return SEAID529 IsNot Nothing AndAlso SEAID529.Count > 0 End Function ''' ''' Test whether CUSOFFSENT740 should be serialized ''' Public Overridable Function ShouldSerializeCUSOFFSENT740() As Boolean - Return CUSOFFSENT740 IsNot Nothing And CUSOFFSENT740.Count > 0 + Return CUSOFFSENT740 IsNot Nothing AndAlso CUSOFFSENT740.Count > 0 End Function ''' @@ -463,17 +466,24 @@ Namespace ENS_CC315A Dim memoryStream As MemoryStream = Nothing Try memoryStream = New MemoryStream() - Dim xmlWriterSettings As System.Xml.XmlWriterSettings = New System.Xml.XmlWriterSettings() + Dim xmlWriterSettings As New System.Xml.XmlWriterSettings() xmlWriterSettings.Encoding = encoding xmlWriterSettings.Indent = True xmlWriterSettings.IndentChars = " " - xmlWriterSettings.NewLineOnAttributes = True + ' Optional: Entfernen Sie NewLineOnAttributes, wenn es zu ungewollter Formatierung führt. xmlWriterSettings.OmitXmlDeclaration = True Dim xmlWriter As System.Xml.XmlWriter = XmlWriter.Create(memoryStream, xmlWriterSettings) - SerializerXml.Serialize(xmlWriter, Me) + + ' Erstelle ein Namespace-Objekt mit dem gewünschten Präfix – es wird nur im Root-Element deklariert. + Dim ns As New XmlSerializerNamespaces() + ns.Add("ie", "http://ics.dgtaxud.ec/CC315A") + + ' Übergib das ns-Objekt beim Serialisieren + SerializerXml.Serialize(xmlWriter, Me, ns) + memoryStream.Seek(0, SeekOrigin.Begin) streamReader = New StreamReader(memoryStream, encoding) - Return streamReader.ReadToEnd + Return streamReader.ReadToEnd() Finally If (Not (streamReader) Is Nothing) Then streamReader.Dispose() @@ -484,6 +494,7 @@ Namespace ENS_CC315A End Try End Function + Public Overridable Overloads Function Serialize() As String Return Serialize(System.Text.Encoding.UTF8) End Function @@ -3599,74 +3610,69 @@ Namespace ENS_CC315A + DesignerCategoryAttribute("code")> Partial Public Class PACGS2Type #Region "Private fields" Private _kinOfPacGS23 As String - Private _numOfPacGS24 As String - Private _numOfPieGS25 As String - Private _marNumOfPacGSL21 As String - Private _marNumOfPacGSL21LNG As String - Private Shared _serializerXml As XmlSerializer #End Region - + Public Property KinOfPacGS23() As String Get Return Me._kinOfPacGS23 End Get - Set - Me._kinOfPacGS23 = Value + Set(ByVal value As String) + Me._kinOfPacGS23 = value End Set End Property - + Public Property NumOfPacGS24() As String Get Return Me._numOfPacGS24 End Get - Set - Me._numOfPacGS24 = Value + Set(ByVal value As String) + Me._numOfPacGS24 = value End Set End Property - + Public Property NumOfPieGS25() As String Get Return Me._numOfPieGS25 End Get - Set - Me._numOfPieGS25 = Value + Set(ByVal value As String) + Me._numOfPieGS25 = value End Set End Property - + Public Property MarNumOfPacGSL21() As String Get Return Me._marNumOfPacGSL21 End Get - Set - Me._marNumOfPacGSL21 = Value + Set(ByVal value As String) + Me._marNumOfPacGSL21 = value End Set End Property - + Public Property MarNumOfPacGSL21LNG() As String Get Return Me._marNumOfPacGSL21LNG End Get - Set - Me._marNumOfPacGSL21LNG = Value + Set(ByVal value As String) + Me._marNumOfPacGSL21LNG = value End Set End Property + Private Shared ReadOnly Property SerializerXml() As XmlSerializer Get If (_serializerXml Is Nothing) Then @@ -5396,40 +5402,37 @@ Namespace ENS_CC315A #Region "Private fields" Private _docTypDC21 As String - Private _docRefDC23 As String - Private _docRefDCLNG As String - Private Shared _serializerXml As XmlSerializer #End Region - + Public Property DocTypDC21() As String Get Return Me._docTypDC21 End Get - Set + Set(ByVal Value As String) Me._docTypDC21 = Value End Set End Property - + Public Property DocRefDC23() As String Get Return Me._docRefDC23 End Get - Set + Set(ByVal Value As String) Me._docRefDC23 = Value End Set End Property - + Public Property DocRefDCLNG() As String Get Return Me._docRefDCLNG End Get - Set + Set(ByVal Value As String) Me._docRefDCLNG = Value End Set End Property @@ -5816,6 +5819,7 @@ Namespace ENS_CC315A End Set End Property + Public Property TRACONCO2() As TRACONCO2Type Get @@ -5899,35 +5903,35 @@ Namespace ENS_CC315A ''' Test whether PRODOCDC2 should be serialized ''' Public Overridable Function ShouldSerializePRODOCDC2() As Boolean - Return PRODOCDC2 IsNot Nothing And PRODOCDC2.Count > 0 + Return PRODOCDC2 IsNot Nothing AndAlso PRODOCDC2.Count > 0 End Function ''' ''' Test whether SPEMENMT2 should be serialized ''' Public Overridable Function ShouldSerializeSPEMENMT2() As Boolean - Return SPEMENMT2 IsNot Nothing And SPEMENMT2.Count > 0 + Return SPEMENMT2 IsNot Nothing AndAlso SPEMENMT2.Count > 0 End Function ''' ''' Test whether CONNR2 should be serialized ''' Public Overridable Function ShouldSerializeCONNR2() As Boolean - Return CONNR2 IsNot Nothing And CONNR2.Count > 0 + Return CONNR2 IsNot Nothing AndAlso CONNR2.Count > 0 End Function ''' ''' Test whether IDEMEATRAGI970 should be serialized ''' Public Overridable Function ShouldSerializeIDEMEATRAGI970() As Boolean - Return IDEMEATRAGI970 IsNot Nothing And IDEMEATRAGI970.Count > 0 + Return IDEMEATRAGI970 IsNot Nothing AndAlso IDEMEATRAGI970.Count > 0 End Function ''' ''' Test whether PACGS2 should be serialized ''' Public Overridable Function ShouldSerializePACGS2() As Boolean - Return PACGS2 IsNot Nothing And PACGS2.Count > 0 + Return PACGS2 IsNot Nothing AndAlso PACGS2.Count > 0 End Function ''' diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC304A-v10-0.Designer.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC304A-v10-0.Designer.vb index 47ab198f..4fd30e27 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC304A-v10-0.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC304A-v10-0.Designer.vb @@ -71,7 +71,7 @@ Namespace CC304A_v10_0 Me._hEAHEA = New HEAHEAType() End Sub - + Public Property MesSenMES3() As String Get Return Me._mesSenMES3 @@ -81,7 +81,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property MesRecMES6() As String Get Return Me._mesRecMES6 @@ -91,7 +91,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property DatOfPreMES9() As String Get Return Me._datOfPreMES9 @@ -101,7 +101,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property TimOfPreMES10() As String Get Return Me._timOfPreMES10 @@ -111,7 +111,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property PriMES15() As String Get Return Me._priMES15 @@ -131,7 +131,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property MesIdeMES19() As String Get Return Me._mesIdeMES19 @@ -151,7 +151,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property CorIdeMES25() As String Get Return Me._corIdeMES25 @@ -483,7 +483,7 @@ Namespace CC304A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property DocNumHEA5() As String Get Return Me._docNumHEA5 @@ -493,7 +493,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property TraModAtBorHEA76() As String Get Return Me._traModAtBorHEA76 @@ -503,7 +503,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property IdeOfMeaOfTraCroHEA85() As String Get Return Me._ideOfMeaOfTraCroHEA85 @@ -513,7 +513,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property IdeOfMeaOfTraCroHEA85LNG() As String Get Return Me._ideOfMeaOfTraCroHEA85LNG @@ -523,7 +523,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property NatOfMeaOfTraCroHEA87() As String Get Return Me._natOfMeaOfTraCroHEA87 @@ -533,7 +533,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property ComRefNumHEA() As String Get Return Me._comRefNumHEA @@ -543,7 +543,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property ConRefNumHEA() As String Get Return Me._conRefNumHEA @@ -553,7 +553,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property AmeAccDatTimHEA111() As String Get Return Me._ameAccDatTimHEA111 @@ -563,7 +563,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property DatTimAmeHEA113() As String Get Return Me._datTimAmeHEA113 @@ -753,7 +753,7 @@ Namespace CC304A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NamTRACARENT604() As String Get Return Me._namTRACARENT604 @@ -763,7 +763,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property StrNumTRACARENT607() As String Get Return Me._strNumTRACARENT607 @@ -773,7 +773,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property PstCodTRACARENT606() As String Get Return Me._pstCodTRACARENT606 @@ -783,7 +783,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property CtyTRACARENT603() As String Get Return Me._ctyTRACARENT603 @@ -793,7 +793,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property CouCodTRACARENT605() As String Get Return Me._couCodTRACARENT605 @@ -803,7 +803,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property TRACARENT601LNG() As String Get Return Me._tRACARENT601LNG @@ -993,7 +993,7 @@ Namespace CC304A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property RefNumCUSOFFFENT731() As String Get Return Me._refNumCUSOFFFENT731 @@ -1003,7 +1003,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property ExpDatOfArrFIRENT733() As String Get Return Me._expDatOfArrFIRENT733 @@ -1193,7 +1193,7 @@ Namespace CC304A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NamPLD1() As String Get Return Me._namPLD1 @@ -1203,7 +1203,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property StrAndNumPLD1() As String Get Return Me._strAndNumPLD1 @@ -1213,7 +1213,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property PosCodPLD1() As String Get Return Me._posCodPLD1 @@ -1223,7 +1223,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property CitPLD1() As String Get Return Me._citPLD1 @@ -1233,7 +1233,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property CouCodPLD1() As String Get Return Me._couCodPLD1 @@ -1243,7 +1243,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property PERLODSUMDECLNG() As String Get Return Me._pERLODSUMDECLNG @@ -1443,7 +1443,7 @@ Namespace CC304A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NamTRE1() As String Get Return Me._namTRE1 @@ -1453,7 +1453,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property StrAndNumTRE1() As String Get Return Me._strAndNumTRE1 @@ -1463,7 +1463,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property PosCodTRE1() As String Get Return Me._posCodTRE1 @@ -1473,7 +1473,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property CitTRE1() As String Get Return Me._citTRE1 @@ -1483,7 +1483,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property CouCodTRE1() As String Get Return Me._couCodTRE1 @@ -1493,7 +1493,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property TRAREPLNG() As String Get Return Me._tRAREPLNG @@ -1685,7 +1685,7 @@ Namespace CC304A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NatIDEMEATRAGI973() As String Get Return Me._natIDEMEATRAGI973 @@ -1695,7 +1695,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property IdeMeaTraGIMEATRA971() As String Get Return Me._ideMeaTraGIMEATRA971 @@ -1705,7 +1705,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property IdeMeaTraGIMEATRA972LNG() As String Get Return Me._ideMeaTraGIMEATRA972LNG @@ -1883,7 +1883,7 @@ Namespace CC304A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property ConNumNR21() As String Get Return Me._conNumNR21 @@ -2065,7 +2065,7 @@ Namespace CC304A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property DocTypDC21() As String Get Return Me._docTypDC21 @@ -2075,7 +2075,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property DocRefDC23() As String Get Return Me._docRefDC23 @@ -2085,7 +2085,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property DocRefDCLNG() As String Get Return Me._docRefDCLNG @@ -2278,7 +2278,7 @@ Namespace CC304A_v10_0 Me._pRODOCDC2 = New List(Of PRODOCDC2Type)() End Sub - + Public Property IteNumGDS7() As String Get Return Me._iteNumGDS7 @@ -2288,7 +2288,7 @@ Namespace CC304A_v10_0 End Set End Property - + Public Property ComRefNumGIM1() As String Get Return Me._comRefNumGIM1 diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC305A-v10-0.Designer.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC305A-v10-0.Designer.vb index 78620446..0fe062b7 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC305A-v10-0.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC305A-v10-0.Designer.vb @@ -68,7 +68,7 @@ Namespace CC305A_v10_0 Me._hEAHEA = New HEAHEAType() End Sub - + Public Property MesSenMES3() As String Get Return Me._mesSenMES3 @@ -78,7 +78,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property MesRecMES6() As String Get Return Me._mesRecMES6 @@ -88,7 +88,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property DatOfPreMES9() As String Get Return Me._datOfPreMES9 @@ -98,7 +98,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property TimOfPreMES10() As String Get Return Me._timOfPreMES10 @@ -108,7 +108,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property PriMES15() As String Get Return Me._priMES15 @@ -128,7 +128,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property MesIdeMES19() As String Get Return Me._mesIdeMES19 @@ -148,7 +148,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property CorIdeMES25() As String Get Return Me._corIdeMES25 @@ -464,7 +464,7 @@ Namespace CC305A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property DocNumHEA5() As String Get Return Me._docNumHEA5 @@ -474,7 +474,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property AmeRejMotCodHEA604() As String Get Return Me._ameRejMotCodHEA604 @@ -484,7 +484,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property AmeRejMotTexHEA605() As String Get Return Me._ameRejMotTexHEA605 @@ -494,7 +494,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property AmeRejMotTexHEA605LNG() As String Get Return Me._ameRejMotTexHEA605LNG @@ -504,7 +504,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property DatTimAmeHEA113() As String Get Return Me._datTimAmeHEA113 @@ -514,7 +514,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property AmeRejDatTimHEA112() As String Get Return Me._ameRejDatTimHEA112 @@ -692,7 +692,7 @@ Namespace CC305A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property RefNumCUSOFFFENT731() As String Get Return Me._refNumCUSOFFFENT731 @@ -882,7 +882,7 @@ Namespace CC305A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NamPLD1() As String Get Return Me._namPLD1 @@ -892,7 +892,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property StrAndNumPLD1() As String Get Return Me._strAndNumPLD1 @@ -902,7 +902,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property PosCodPLD1() As String Get Return Me._posCodPLD1 @@ -912,7 +912,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property CitPLD1() As String Get Return Me._citPLD1 @@ -922,7 +922,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property CouCodPLD1() As String Get Return Me._couCodPLD1 @@ -932,7 +932,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property PERLODSUMDECLNG() As String Get Return Me._pERLODSUMDECLNG @@ -1132,7 +1132,7 @@ Namespace CC305A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NamTRE1() As String Get Return Me._namTRE1 @@ -1142,7 +1142,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property StrAndNumTRE1() As String Get Return Me._strAndNumTRE1 @@ -1152,7 +1152,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property PosCodTRE1() As String Get Return Me._posCodTRE1 @@ -1162,7 +1162,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property CitTRE1() As String Get Return Me._citTRE1 @@ -1172,7 +1172,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property CouCodTRE1() As String Get Return Me._couCodTRE1 @@ -1182,7 +1182,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property TRAREPLNG() As String Get Return Me._tRAREPLNG @@ -1386,7 +1386,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property ErrPoiER12() As String Get Return Me._errPoiER12 @@ -1396,7 +1396,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property ErrReaER13() As String Get Return Me._errReaER13 @@ -1406,7 +1406,7 @@ Namespace CC305A_v10_0 End Set End Property - + Public Property OriAttValER14() As String Get Return Me._oriAttValER14 diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC316A-v10-0.Designer.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC316A-v10-0.Designer.vb index 75405886..7ce53892 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC316A-v10-0.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC316A-v10-0.Designer.vb @@ -59,7 +59,7 @@ Namespace CC316A_v10_0 Me._hEAHEA = New HEAHEAType() End Sub - + Public Property MesSenMES3() As String Get Return Me._mesSenMES3 @@ -69,7 +69,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property MesRecMES6() As String Get Return Me._mesRecMES6 @@ -79,7 +79,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property DatOfPreMES9() As String Get Return Me._datOfPreMES9 @@ -89,7 +89,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property TimOfPreMES10() As String Get Return Me._timOfPreMES10 @@ -99,7 +99,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property PriMES15() As String Get Return Me._priMES15 @@ -119,7 +119,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property MesIdeMES19() As String Get Return Me._mesIdeMES19 @@ -139,7 +139,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property CorIdeMES25() As String Get Return Me._corIdeMES25 @@ -421,7 +421,7 @@ Namespace CC316A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property RefNumHEA4() As String Get Return Me._refNumHEA4 @@ -431,7 +431,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property DecRejReaHEA252() As String Get Return Me._decRejReaHEA252 @@ -441,7 +441,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property DecRejReaHEA252LNG() As String Get Return Me._decRejReaHEA252LNG @@ -451,7 +451,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property DecRejDatTimHEA116() As String Get Return Me._decRejDatTimHEA116 @@ -645,7 +645,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property ErrPoiER12() As String Get Return Me._errPoiER12 @@ -655,7 +655,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property ErrReaER13() As String Get Return Me._errReaER13 @@ -665,7 +665,7 @@ Namespace CC316A_v10_0 End Set End Property - + Public Property OriAttValER14() As String Get Return Me._oriAttValER14 diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC328A-v10-0.Designer.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC328A-v10-0.Designer.vb index a15e638c..3db13a48 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC328A-v10-0.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/HMRC/ENS/CC328A/CC328A-v10-0.Designer.vb @@ -71,7 +71,7 @@ Namespace CC328A_v10_0 Me._hEAHEA = New HEAHEAType() End Sub - + Public Property MesSenMES3() As String Get Return Me._mesSenMES3 @@ -81,7 +81,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property MesRecMES6() As String Get Return Me._mesRecMES6 @@ -91,7 +91,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property DatOfPreMES9() As String Get Return Me._datOfPreMES9 @@ -101,7 +101,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property TimOfPreMES10() As String Get Return Me._timOfPreMES10 @@ -111,7 +111,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property PriMES15() As String Get Return Me._priMES15 @@ -131,7 +131,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property MesIdeMES19() As String Get Return Me._mesIdeMES19 @@ -151,7 +151,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property CorIdeMES25() As String Get Return Me._corIdeMES25 @@ -483,7 +483,7 @@ Namespace CC328A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property RefNumHEA4() As String Get Return Me._refNumHEA4 @@ -493,7 +493,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property DocNumHEA5() As String Get Return Me._docNumHEA5 @@ -503,7 +503,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property TraModAtBorHEA76() As String Get Return Me._traModAtBorHEA76 @@ -513,7 +513,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property NatHEA001() As String Get Return Me._natHEA001 @@ -523,7 +523,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property IdeOfMeaOfTraCroHEA85() As String Get Return Me._ideOfMeaOfTraCroHEA85 @@ -533,7 +533,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property IdeOfMeaOfTraCroHEA85LNG() As String Get Return Me._ideOfMeaOfTraCroHEA85LNG @@ -543,7 +543,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property ComRefNumHEA() As String Get Return Me._comRefNumHEA @@ -553,7 +553,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property ConRefNumHEA() As String Get Return Me._conRefNumHEA @@ -563,7 +563,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property DecRegDatTimHEA115() As String Get Return Me._decRegDatTimHEA115 @@ -753,7 +753,7 @@ Namespace CC328A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NamTRACARENT604() As String Get Return Me._namTRACARENT604 @@ -763,7 +763,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property StrNumTRACARENT607() As String Get Return Me._strNumTRACARENT607 @@ -773,7 +773,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property PstCodTRACARENT606() As String Get Return Me._pstCodTRACARENT606 @@ -783,7 +783,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property CtyTRACARENT603() As String Get Return Me._ctyTRACARENT603 @@ -793,7 +793,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property CouCodTRACARENT605() As String Get Return Me._couCodTRACARENT605 @@ -803,7 +803,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property TRACARENT601LNG() As String Get Return Me._tRACARENT601LNG @@ -993,7 +993,7 @@ Namespace CC328A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property RefNumCUSOFFFENT731() As String Get Return Me._refNumCUSOFFFENT731 @@ -1003,7 +1003,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property ExpDatOfArrFIRENT733() As String Get Return Me._expDatOfArrFIRENT733 @@ -1193,7 +1193,7 @@ Namespace CC328A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NamPLD1() As String Get Return Me._namPLD1 @@ -1203,7 +1203,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property StrAndNumPLD1() As String Get Return Me._strAndNumPLD1 @@ -1213,7 +1213,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property PosCodPLD1() As String Get Return Me._posCodPLD1 @@ -1223,7 +1223,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property CitPLD1() As String Get Return Me._citPLD1 @@ -1233,7 +1233,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property CouCodPLD1() As String Get Return Me._couCodPLD1 @@ -1243,7 +1243,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property PERLODSUMDECLNG() As String Get Return Me._pERLODSUMDECLNG @@ -1431,7 +1431,7 @@ Namespace CC328A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property RefNumCOL1() As String Get Return Me._refNumCOL1 @@ -1613,7 +1613,7 @@ Namespace CC328A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property NatIDEMEATRAGI973() As String Get Return Me._natIDEMEATRAGI973 @@ -1623,7 +1623,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property IdeMeaTraGIMEATRA971() As String Get Return Me._ideMeaTraGIMEATRA971 @@ -1633,7 +1633,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property IdeMeaTraGIMEATRA972LNG() As String Get Return Me._ideMeaTraGIMEATRA972LNG @@ -1811,7 +1811,7 @@ Namespace CC328A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property ConNumNR21() As String Get Return Me._conNumNR21 @@ -1993,7 +1993,7 @@ Namespace CC328A_v10_0 Private Shared _serializerXml As XmlSerializer #End Region - + Public Property DocTypDC21() As String Get Return Me._docTypDC21 @@ -2003,7 +2003,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property DocRefDC23() As String Get Return Me._docRefDC23 @@ -2013,7 +2013,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property DocRefDCLNG() As String Get Return Me._docRefDCLNG @@ -2206,7 +2206,7 @@ Namespace CC328A_v10_0 Me._pRODOCDC2 = New List(Of PRODOCDC2Type)() End Sub - + Public Property IteNumGDS7() As String Get Return Me._iteNumGDS7 @@ -2216,7 +2216,7 @@ Namespace CC328A_v10_0 End Set End Property - + Public Property ComRefNumGIM1() As String Get Return Me._comRefNumGIM1 diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/cHMRC.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/cHMRC.vb new file mode 100644 index 00000000..a46dc5ae --- /dev/null +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/cHMRC.vb @@ -0,0 +1,1715 @@ +Imports System.Net.Http +Imports System.Web +Imports System +Imports Microsoft.AspNetCore.Authentication.Cookies +Imports Microsoft.AspNetCore.Builder +Imports Microsoft.AspNetCore.Hosting +Imports Microsoft.AspNetCore.Http +Imports Microsoft.Extensions.Configuration +Imports Microsoft.Extensions.DependencyInjection +Imports Microsoft.Extensions.Hosting +Imports System.Collections.Specialized +Imports System.Text +Imports System.IO +Imports VERAG_PROG_ALLGEMEIN +Imports System.Windows.Forms +Imports System.Drawing + + +Public Class cHMRC + + 'TEST + 'Shared API_STRING As String = "https://test-api.service.hmrc.gov.uk" + 'Shared CLIENT_ID As String = "xybTOMaQWcuifeW5xnGggojlACWC" + 'Shared CLIENT_SECRET As String = "bf1cfb6e-1bcb-4282-b7a0-3d3ccb2b1dc1" + + 'PROD + Shared API_STRING As String = "https://api.service.hmrc.gov.uk" + Shared CLIENT_ID As String = "qO1kqyMtFnvHi9XpRVJBGTCrNpno" + Shared CLIENT_SECRET As String = "3169852a-afa5-4adb-837c-fbd4d0cd4c7e" + + + Public Class cHMRCCredentials + Public CLIENT_ID As String = "" + Public CLIENT_SECRET As String = "" + Public API_STRING As String = "" + End Class + + Shared Function getCredentials(HMRC_APPLICATION) As cHMRCCredentials + Dim cHMRCCredentials = New cHMRCCredentials + Select Case HMRC_APPLICATION + Case "AVISO" + If VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM Then + cHMRCCredentials.API_STRING = "https://test-api.service.hmrc.gov.uk" + cHMRCCredentials.CLIENT_ID = "xybTOMaQWcuifeW5xnGggojlACWC" + cHMRCCredentials.CLIENT_SECRET = "bf1cfb6e-1bcb-4282-b7a0-3d3ccb2b1dc1" + Else + cHMRCCredentials.API_STRING = "https://api.service.hmrc.gov.uk" + cHMRCCredentials.CLIENT_ID = "qO1kqyMtFnvHi9XpRVJBGTCrNpno" + cHMRCCredentials.CLIENT_SECRET = "3169852a-afa5-4adb-837c-fbd4d0cd4c7e" + End If + Case "AVISO_ENS" + + If cHMRC_ENS.TEST Or VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM Then + cHMRCCredentials.API_STRING = "https://test-api.service.hmrc.gov.uk" + cHMRCCredentials.CLIENT_ID = cHMRC_ENS.Client_ID + cHMRCCredentials.CLIENT_SECRET = cHMRC_ENS.Client_Secret + + Else + cHMRCCredentials.API_STRING = "https://api.service.hmrc.gov.uk" + cHMRCCredentials.CLIENT_ID = cHMRC_ENS.Client_ID + cHMRCCredentials.CLIENT_SECRET = cHMRC_ENS.Client_Secret + End If + End Select + Return cHMRCCredentials + End Function + + Shared Function SEND_GVMS(GVMS As VERAG_PROG_ALLGEMEIN.cGVMS, Optional updateGMR As String = "") + + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + 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 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 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_GMR(GMR, TOKEN.token_BEARER_TOKEN) Then + MsgBox("GMR: " & Now.ToShortDateString & " " & Now.ToShortTimeString) + End If + End If + End If + + End Function + + + Shared Function DELETE_GMR(GVMS As VERAG_PROG_ALLGEMEIN.cGVMS) + + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + Dim TOKEN = cHMRC.getTOKEN("GVMS") + + 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 + + End Function + + Shared Function GET_NOTIFICATIONS(Notification_Box_Id As String) As Boolean + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + 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() + 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 + + Shared Sub hmrcTEST2() + 'Dim rClient As RestClient = New RestClient() + 'rClient.endPoint = "https://test-api.service.hmrc.gov.uk/hello/user" + 'Dim strResponse As String = String.Empty + 'strResponse = rClient.makeRequest(_accessToken) + + Dim rest As New Chilkat.Rest + + ' Connect to the REST server. + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + Dim success As Boolean = rest.Connect("https://test-api.service.hmrc.gov.uk", port, bTls, bAutoReconnect) + '389356931 -> VERAG-UNISPED + 'Dim responseJson As String = rest.FullRequestNoBody("GET", "/organisations/vat/check-vat-number/lookup/553557881") + 'Dim responseJson As String = rest.FullRequestNoBody("GET", "/organisations/vat/check-vat-number/lookup/553552881") 'falsch + Dim responseJson As String = rest.FullRequestNoBody("GET", "/organisations/vat/check-vat-number/lookup/5535532881") 'falsch + If (rest.LastMethodSuccess <> True) Then + Console.WriteLine(rest.LastErrorText) + Exit Sub + End If + + Try + + Dim read = Newtonsoft.Json.Linq.JObject.Parse(responseJson) + + If read.Item("code") IsNot Nothing Then + Dim VAT_Message = read.Item("message").ToString + Dim VAT_code = read.Item("code").ToString + MsgBox("ERROR: " & VAT_Message, MsgBoxStyle.OkOnly, VAT_code) + Else + ' Dim json As String = "{""name"":""Rap God"",""statistics"":{""likeCount"":""122255"",""dislikeCount"":""4472""}}" + Dim VAT_Name = read.Item("target")("name").ToString + Dim VAT_processingDate = read.Item("processingDate").ToString + Dim VAT_Strasse = read.Item("target")("address")("line1").ToString + Dim VAT_PLZ = read.Item("target")("address")("postcode").ToString + Dim VAT_countryCode = read.Item("target")("address")("countryCode").ToString + + MsgBox(VAT_Name) + MsgBox(VAT_processingDate) + End If + Catch ex As Exception + MsgBox(ex.Message & ex.StackTrace) + End Try + + + 'Console.WriteLine(responseJson) + 'Console.WriteLine("----") + + '' We can alternatively do this: + 'rest.ClearAllQueryParams() + '' rest.AddQueryParam("consumer_key", "YOUR_CONSUMER_KEY") + '' rest.AddQueryParam("consumer_secret", "YOUR_CONSUMER_SECRET") + 'responseJson = rest.FullRequestNoBody("GET", "/wp-json/wc/v1/products") + 'If (rest.LastMethodSuccess <> True) Then + ' Console.WriteLine(rest.LastErrorText) + ' Exit Sub + 'End If + + + Console.WriteLine(responseJson) + + End Sub + + + Shared Sub hmrcTEST() + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + '---------------------------REF DATA--------------------------- + + getGVMS_RefData() + + '-------------------------------------------------------------- + + + Exit Sub + + + '---------------------------NOTIFICATIONS--------------------------- + + 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 = "" + 'grantAccess(AccessToken, "write:goods-movement-system") + ' grantAccess(AccessToken, "write:goods-movement-system+read:pull-notifications", "AVISO") + 'getHMRC_Token(AccessToken, "write:goods-movement-system") + + ' MsgBox(AccessToken) + 'If AccessToken <> "" Then + + ' Dim Notification_Box_Id = "" + ' Dim Notification_Message_Id = "" + ' If genGVMS_GMR(AccessToken, Notification_Box_Id, Notification_Message_Id) Then + + ' Dim AccessTokenNotTEST = grantAccessApplication("", "read:pull-notifications") + + ' ' getHMRC_Token(AccessTokenNotTEST, "read:pull-notifications") + ' ' grantAccess(AccessTokenNotTEST, "read:pull-notifications") + ' If AccessTokenNotTEST <> "" Then + ' getGVMS_Notifications(AccessTokenNotTEST, Notification_Box_Id) + ' End If + ' 'If AccessToken <> "" Then + ' ' getGVMS_Notifications(AccessToken, Notification_Box_Id) + ' 'End If + ' End If + 'End If + + Exit Sub + 'UnlockCilkat() + + 'Dim AccessTokenNotTEST = "" + 'grantAccess(AccessTokenNotTEST, "read:pull-notifications") + 'If AccessTokenNotTEST <> "" Then + ' getGVMS_Notifications(AccessTokenNotTEST, "877b619c-33c1-4ab6-a34f-8bd7542e0596") + + 'End If + Exit Sub + + 'Dim AccessToken = "" + 'grantAccess(AccessToken, "write:goods-movement-system") + 'If AccessToken <> "" Then + + ' Dim Notification_Box_Id = "" + ' Dim Notification_Message_Id = "" + ' genGVMS_GMR(AccessToken, Notification_Box_Id, Notification_Message_Id) + + ' Dim AccessTokenNot = "" + ' grantAccess(AccessTokenNot, "read:pull-notifications") + ' If AccessTokenNot <> "" Then + ' getGVMS_Notifications(AccessTokenNot, Notification_Box_Id) + + ' End If + 'End If + + + + Exit Sub + getGVMS_RefData() + + Exit Sub + + + + Exit Sub + 'genGVMS_GMR("TEST") + + 'Exit Sub + 'Dim AccessToken = "" + 'grantAccess(AccessToken) + 'If AccessToken <> "" Then + ' genGVMS_GMR(AccessToken) + 'End If + End Sub + Public Shared Sub grantAccess(ByRef AccessToken, ByRef RefreshToken, scope, HMRC_APPLICATION) + Try + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + Dim CREDENTIALS = getCredentials(HMRC_APPLICATION) + + Debug.WriteLine("HMRC Start") + Dim oauth2 As Chilkat.OAuth2 = New Chilkat.OAuth2() + Dim success As Boolean + + oauth2.ListenPort = 3017 + oauth2.AuthorizationEndpoint = CREDENTIALS.API_STRING & "/oauth/authorize" + oauth2.TokenEndpoint = CREDENTIALS.API_STRING & "/oauth/token" + oauth2.ClientId = CREDENTIALS.CLIENT_ID '"xybTOMaQWcuifeW5xnGggojlACWC" + oauth2.ClientSecret = CREDENTIALS.CLIENT_SECRET '"bf1cfb6e-1bcb-4282-b7a0-3d3ccb2b1dc1" + oauth2.Scope = scope '"write:goods-movement-system" + + 'oauth2.RedirectAllowHtml = "http://www.verag.ag/AVISO/Success.html" + 'oauth2.RedirectDenyHtml = "http://www.verag.ag/AVISO/Sussess.html" + + + Dim url As String = oauth2.StartAuth() + MsgBox(url) + + + + 'oauth2.AuthorizationEndpoint = "https://test-api.service.hmrc.gov.uk/oauth/authorize" + 'oauth2.TokenEndpoint = "https://test-api.service.hmrc.gov.uk/oauth/token" + + + + If oauth2.LastMethodSuccess <> True Then + Debug.WriteLine(oauth2.LastErrorText) + Exit Sub + End If + + Dim http As Chilkat.Http = New Chilkat.Http() + + Dim useBrowser = False + If Not useBrowser Then + System.Diagnostics.Process.Start(url) + Dim numMsWaited As Integer = 0 + + + While (numMsWaited < 120000) AndAlso (oauth2.AuthFlowState < 3) + oauth2.SleepMs(100) + numMsWaited = numMsWaited + 100 + End While + ' If there was no response from the browser within 30 seconds, then + ' the AuthFlowState will be equal to 1 Or 2. + ' 1: Waiting for Redirect. The OAuth2 background thread Is waiting to receive the redirect HTTP request from the browser. + ' 2: Waiting for Final Response. The OAuth2 background thread Is waiting for the final access token response. + ' In that case, cancel the background task started in the call to StartAuth. + + Else + + ' System.Diagnostics.Process.Start(url) + + Dim f As New Form + f.Size = New Size(800, 1400) + Dim wb As New WebBrowser + f.Controls.Add(wb) + f.StartPosition = FormStartPosition.CenterScreen + wb.Dock = DockStyle.Fill + wb.Navigate(url) + Dim done = False + + + 'AddHandler wb.DocumentCompleted, Sub() + ' If Not done Then + + ' If wb.Url.AbsolutePath = "/api-test-login/sign-in" Then + ' Try + ' Dim txtInput As HtmlElement = wb.Document.Forms(0).GetElementsByTagName("input").GetElementsByName("userId")(0) + ' txtInput.InnerText = "224015321897" + ' Dim txtInputPwd As HtmlElement = wb.Document.Forms(0).GetElementsByTagName("input").GetElementsByName("password")(0) + ' txtInputPwd.InnerText = "ry1cspz0nsvj" + ' done = True + ' Catch + ' End Try + ' End If + ' End If + ' MsgBox(wb.Url.AbsolutePath) + ' End Sub + + f.ShowDialog() + End If + + + + If oauth2.AuthFlowState < 3 Then + oauth2.Cancel() + Debug.WriteLine("No response from the browser!") + Exit Sub + End If + + Debug.WriteLine("HMRC here") + + + ' Check the AuthFlowState to see if authorization was granted, denied, Or if some error occurred + ' The possible AuthFlowState values are: + ' 3 Completed with Success. The OAuth2 flow has completed, the background thread exited, And the successful JSON response Is available in AccessTokenResponse property. + ' 4: Completed with Access Denied. The OAuth2 flow has completed, the background thread exited, And the error JSON Is available in AccessTokenResponse property. + ' 5: Failed Prior To Completion. The OAuth2 flow failed To complete, the background thread exited, And the error information Is available in the FailureInfo property. + + If oauth2.AuthFlowState = 5 Then + Debug.WriteLine("OAuth2 failed to complete.") + Debug.WriteLine(oauth2.FailureInfo) + Exit Sub + End If + + If oauth2.AuthFlowState = 4 Then + Debug.WriteLine("OAuth2 authorization was denied.") + Debug.WriteLine(oauth2.AccessTokenResponse) + Exit Sub + End If + + If oauth2.AuthFlowState <> 3 Then + Debug.WriteLine("Unexpected AuthFlowState:" & Convert.ToString(oauth2.AuthFlowState)) + Exit Sub + End If + + ' MsgBox("OAuth2 authorization granted!") + Debug.WriteLine("OAuth2 authorization granted!") + Debug.WriteLine("Access Token = " & oauth2.AccessToken) + Debug.WriteLine("Refresh Token = " & oauth2.RefreshToken) + Dim json As Chilkat.JsonObject = New Chilkat.JsonObject() + json.Load(oauth2.AccessTokenResponse) + json.EmitCompact = False + Debug.WriteLine(json.Emit()) + ' MsgBox(json.Emit()) + + ' The JSON response looks Like this + + ' { + ' "token_type": "Bearer", + ' "scope": "user_impersonation", + ' "expires_in": "3599", + ' "ext_expires_in": "0", + ' "expires_on": "1524783438", + ' "not_before": "1524779538", + ' "resource": "https://mydomain.api.crm.dynamics.com", + ' "access_token": "...", + ' "refresh_token": "...", + ' "id_token": "..." + ' } + + ' If an "expires_on" member does Not exist, then add the JSON member by + ' getting the current system date/time And adding the "expires_in" seconds. + ' This way we'll know when the token expires. + + If json.HasMember("expires_on") <> True Then + Dim dtExpire As Chilkat.CkDateTime = New Chilkat.CkDateTime() + dtExpire.SetFromCurrentSystemTime() + dtExpire.AddSeconds(json.IntOf("expires_in")) + json.AppendString("expires_on", dtExpire.GetAsUnixTimeStr(False)) + End If + + Debug.WriteLine(json.Emit()) + Dim fac As Chilkat.FileAccess = New Chilkat.FileAccess() + 'fac.WriteEntireTextFile("qa_data/tokens/hmrc.json", json.Emit(), "utf-8", False) + ' fac.WriteEntireTextFile("C:\Users\DEVELOPER1\Desktop\hmrc.json", json.Emit(), "utf-8", False) + AccessToken = oauth2.AccessToken + RefreshToken = oauth2.RefreshToken + + + + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + End Sub + + + Shared Sub HMRC_RefreshToken(ByRef TOKEN As cHMRCToken, HMRC_APPLICATION As String) + + If DateDiff(DateInterval.Minute, TOKEN.token_accestoken_datetime, Now) < 60 Then 'bis 240 MIN / 4hr + 'Token ist noch frisch + Exit Sub + End If + + ' Chilkat Lizenz aktivieren (falls benötigt) + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + ' HTTP-Objekt für API-Request erstellen + Dim http As New Chilkat.Http() + + ' URL für HMRC Token Refresh + ' Dim url As String = "/oauth/token" + + ' HTTP-Request-Objekt für POST-Anfrage + Dim req As New Chilkat.HttpRequest() + req.HttpVerb = "POST" + req.Path = "/oauth/token" + req.ContentType = "application/x-www-form-urlencoded" + + ' OAuth2 Credentials einfügen + Dim CREDENTIALS = getCredentials(HMRC_APPLICATION) + + + req.AddParam("client_secret", CREDENTIALS.CLIENT_SECRET) + req.AddParam("client_id", CREDENTIALS.CLIENT_ID) + req.AddParam("grant_type", "client_credentials") + req.AddParam("refresh_token", TOKEN.token_REFRESH_TOKEN) + + + + ' rest.AddQueryParam("scope", scope) + + ' MsgBox(CREDENTIALS.API_STRING) + ' Anfrage senden + Dim resp As Chilkat.HttpResponse = http.PostUrlEncoded(CREDENTIALS.API_STRING & "/oauth/token", req) + + ' Fehlerprüfung + If resp Is Nothing Then + Console.WriteLine("Fehler: " & http.LastErrorText) + Exit Sub + End If + + ' API-Antwort ausgeben + Dim json As New Chilkat.JsonObject() + json.Load(resp.BodyStr) + + ' Neuer Access Token + Dim accessToken As String = json.StringOf("access_token") + Dim newRefreshToken As String = json.StringOf("refresh_token") + Dim expiresIn As String = json.StringOf("expires_in") + + Console.WriteLine("Neuer Access Token: " & accessToken) + Console.WriteLine("Neuer Refresh Token: " & newRefreshToken) + Console.WriteLine("Gültigkeit (Sekunden): " & expiresIn) + + ' Optional: Tokens in einer Datei speichern + 'Dim tokenFile As String = "token.json" + 'json.EmitCompact = False + 'json.WriteFile(tokenFile) + + TOKEN.token_REFRESH_TOKEN = newRefreshToken + TOKEN.token_BEARER_TOKEN = accessToken + TOKEN.token_accestoken_datetime = Now + TOKEN.SAVE() + + Console.WriteLine("Tokens wurden in TokenDB gespeichert.") + + End Sub + + + Shared Function grantAccessApplication(ByRef AccessToken, scope) As String + Try + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + Dim rest As New Chilkat.Rest + Dim success As Boolean + + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + MsgBox(rest.LastErrorText) + Return "" + End If + + + rest.AddHeader("Content-Type", "application/x-www-form-urlencoded") + + rest.AddQueryParam("client_secret", CLIENT_SECRET) + rest.AddQueryParam("client_id", CLIENT_ID) + rest.AddQueryParam("grant_type", "client_credentials") + rest.AddQueryParam("scope", scope) + + + Dim ResponseStr = rest.FullRequestFormUrlEncoded("POST", "/oauth/token") + + Dim respStatusCode As Integer = rest.ResponseStatusCode + + + If (respStatusCode <> 200) Then + Debug.WriteLine(rest.LastErrorText) + Return "" + End If + + Dim jsonResp = New Chilkat.JsonObject() + jsonResp.Load(ResponseStr) + + AccessToken = jsonResp.StringOf("access_token") + ' MsgBox("AccessToken: " & AccessToken) + 'jsonResp.StringOf("expires_in") + + Return AccessToken + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + Return "" + + End Function + + + Shared Sub VATTEST(hmrc_app_server_token) + + Dim rest As New Chilkat.Rest + Dim success As Boolean + + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + Exit Sub + End If + + + ' See the Online Tool for Generating JSON Creation Code + Dim json As New Chilkat.JsonObject + json.UpdateString("periodKey", "#001") + json.UpdateNumber("vatDueSales", "100.00") + json.UpdateNumber("vatDueAcquisitions", "100.00") + json.UpdateNumber("totalVatDue", "200") + json.UpdateNumber("vatReclaimedCurrPeriod", "100.00") + json.UpdateNumber("netVatDue", "100") + json.UpdateNumber("totalValueSalesExVAT", "500") + json.UpdateNumber("totalValuePurchasesExVAT", "500") + json.UpdateNumber("totalValueGoodsSuppliedExVAT", "500") + json.UpdateNumber("totalAcquisitionsExVAT", "500") + json.UpdateBool("finalised", True) + + + rest.AddHeader("Content-Type", "application/json") + rest.AddHeader("Authorization", "Bearer " & hmrc_app_server_token) + rest.AddHeader("Accept", "application/vnd.hmrc.1.0+json") + + Dim sbRequestBody As New Chilkat.StringBuilder + json.EmitSb(sbRequestBody) + Dim sbResponseBody As New Chilkat.StringBuilder + success = rest.FullRequestSb("POST", "/organisations/vat/123456789/returns", sbRequestBody, sbResponseBody) + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + Exit Sub + End If + + Dim respStatusCode As Integer = rest.ResponseStatusCode + If (respStatusCode >= 400) Then + Debug.WriteLine("Response Status Code = " & respStatusCode) + Debug.WriteLine("Response Header:") + Debug.WriteLine(rest.ResponseHeader) + Debug.WriteLine("Response Body:") + Debug.WriteLine(sbResponseBody.GetAsString()) + Exit Sub + End If + + + End Sub + + Shared Sub getGVMS_RefData() + + Dim rest As New Chilkat.Rest + Dim success As Boolean + + Dim bTls As Boolean = True + Dim portSSL As Integer = 443 + Dim bAutoReconnect As Boolean = True + + success = rest.Connect(API_STRING, portSSL, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + + Exit Sub + End If + + rest.AddHeader("Accept", "application/vnd.hmrc.1.0+json") + + Dim sbRequestBody As New Chilkat.StringBuilder + + Dim sbResponseBody As New Chilkat.StringBuilder + success = rest.FullRequestSb("GET", "/customs/goods-movement-system/reference-data", sbRequestBody, sbResponseBody) + + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + MsgBox(rest.LastErrorText) + Exit Sub + End If + + Dim respStatusCode As Integer = rest.ResponseStatusCode + If (respStatusCode <> 200) Then + MsgBox("respStatusCode: " & respStatusCode) + Debug.WriteLine("Response Status Code = " & respStatusCode) + Debug.WriteLine("Response Header:") + Debug.WriteLine(rest.ResponseHeader) + Debug.WriteLine("Response Body:") + Debug.WriteLine(sbResponseBody.GetAsString()) + + Exit Sub + End If + + MsgBox("OK " & respStatusCode) + + Dim jsonResp = New Chilkat.JsonObject() + jsonResp.LoadSb(sbResponseBody) + + VERAG_PROG_ALLGEMEIN.cGVMS_Routes.DELETE_ALL() + For i = 0 To jsonResp.SizeOfArray("routes") - 1 + + Dim ROUTE As New VERAG_PROG_ALLGEMEIN.cGVMS_Routes + + ROUTE.routeId = jsonResp.StringOf("routes[" & i & "].routeId") + ROUTE.routeDirection = jsonResp.StringOf("routes[" & i & "].routeDirection") + + ROUTE.routeEffectiveFrom = jsonResp.StringOf("routes[" & i & "].routeEffectiveFrom") + ROUTE.departurePortId = jsonResp.StringOf("routes[" & i & "].departurePortId") + ROUTE.arrivalPortId = jsonResp.StringOf("routes[" & i & "].arrivalPortId") + ROUTE.carrierId = jsonResp.StringOf("routes[" & i & "].carrierId") + ROUTE.routeEffectiveTo = jsonResp.StringOf("routes[" & i & "].routeEffectiveTo") + ROUTE.SAVE() + + Next + + + VERAG_PROG_ALLGEMEIN.cGVMS_Ports.DELETE_ALL() + For i = 0 To jsonResp.SizeOfArray("ports") - 1 + + Dim PORT As New VERAG_PROG_ALLGEMEIN.cGVMS_Ports + PORT.portId = jsonResp.StringOf("ports[" & i & "].portId") + PORT.portDescription = jsonResp.StringOf("ports[" & i & "].portDescription") + PORT.portRegion = jsonResp.StringOf("ports[" & i & "].portRegion") + PORT.portEffectiveFrom = jsonResp.StringOf("ports[" & i & "].portEffectiveFrom") + PORT.portDescription = jsonResp.StringOf("ports[" & i & "].portDescription") + PORT.chiefPortCode = jsonResp.StringOf("ports[" & i & "].chiefPortCode") + PORT.cdsPortCode = jsonResp.StringOf("ports[" & i & "].cdsPortCode") + PORT.officeOfTransitCustomsOfficeCode = jsonResp.StringOf("ports[" & i & "].officeOfTransitCustomsOfficeCode") + PORT.portEffectiveTo = jsonResp.StringOf("ports[" & i & "].portEffectiveTo") + PORT.portCountryCode = jsonResp.StringOf("ports[" & i & "].portCountryCode") + PORT.isOperatingArrivedExportsProcess = jsonResp.StringOf("ports[" & i & "].isOperatingArrivedExportsProcess") + PORT.SAVE() + Next + + VERAG_PROG_ALLGEMEIN.cGVMS_Carriers.DELETE_ALL() + For i = 0 To jsonResp.SizeOfArray("carriers") - 1 + + Dim CARRIER As New VERAG_PROG_ALLGEMEIN.cGVMS_Carriers + CARRIER.carrierId = jsonResp.StringOf("carriers[" & i & "].carrierId") + CARRIER.carrierName = jsonResp.StringOf("carriers[" & i & "].carrierName") + CARRIER.countryCode = jsonResp.StringOf("carriers[" & i & "].countryCode") + CARRIER.SAVE() + Next + + 'For i = 0 To jsonResp.SizeOfArray("locations") - 1 + + ' MsgBox(jsonResp.StringOf("locations[" & i & "].locationId")) + ' MsgBox(jsonResp.StringOf("locations[" & i & "].locationDescription")) + ' MsgBox(jsonResp.StringOf("locations[" & i & "].locationType")) + + 'Next + 'For i = 0 To jsonResp.SizeOfArray("inspectionTypes") - 1 + + ' MsgBox(jsonResp.StringOf("inspectionTypes[" & i & "].inspectionTypeId")) + ' MsgBox(jsonResp.StringOf("inspectionTypes[" & i & "].description")) + + 'Next + 'For i = 0 To jsonResp.SizeOfArray("ruleFailures") - 1 + + ' MsgBox(jsonResp.StringOf("ruleFailures[" & i & "].ruleId")) + ' MsgBox(jsonResp.StringOf("ruleFailures[" & i & "].ruleDescription")) + + 'Next + + MsgBox("FERTIG: " & Now.ToShortDateString & " " & Now.ToShortTimeString) + + End Sub + Private Shared Function genGVMS_GMR(ByRef GVMS As VERAG_PROG_ALLGEMEIN.cGVMS, hmrc_app_server_token As String, ByRef Notification_Box_Id As String, ByRef Notification_Message_Id As String, Optional updateGMR As String = "") As Boolean + Try + Dim rest As New Chilkat.Rest + Dim success As Boolean + + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + MsgBox(rest.LastErrorText) + Return False + End If + + ' See the Online Tool for Generating JSON Creation Code + Dim json As New Chilkat.JsonObject + json.UpdateString("direction", GVMS.gvms_direction) + json.UpdateBool("isUnaccompanied", GVMS.gvms_isUnaccompanied) + json.UpdateString("vehicleRegNum", GVMS.gvms_vehicleRegNum) 'LKW + If If(GVMS.gvms_trailorRegNum, "") <> "" Then json.UpdateString("trailerRegistrationNums", GVMS.gvms_trailorRegNum) 'Anhänger + + + json.UpdateString("plannedCrossing.routeId", GVMS.gvms_routeId) '--> Calais - Dover - DFDS + json.UpdateString("plannedCrossing.localDateTimeOfDeparture", Format(CDate(GVMS.gvms_locateDateTimeOfDeparture), "yyyy-MM-ddTHH:mm")) '"2021-08-11T10:58") + + + + If GVMS.gvms_empty Then + json.UpdateBool("emptyVehicle.isOwnVehicle", GVMS.gvms_emptyisOwn) + ' json.UpdateBool("emptyVehicle.sAndSMasterRefNum", GVMS.gvms_emptyisOwn) + Else + Dim cnt = 0 + '---------customsDeclarations---------------- + cnt = 0 + For Each POS In GVMS.GVMS_POSITIONEN + If POS.gvms_art = VERAG_PROG_ALLGEMEIN.cGVMS_POS_DecArt.IMPORT Or POS.gvms_art = VERAG_PROG_ALLGEMEIN.cGVMS_POS_DecArt.EXPORT Then + json.UpdateString("customsDeclarations[" & cnt & "].customsDeclarationId", POS.gvms_RefNum) + ' json.UpdateString("customsDeclarations[" & cnt & "].customsDeclarationPartId", "20GB01I0XLM976S001") + If If(POS.gvms_SS, "") <> "" Then json.UpdateString("customsDeclarations[" & cnt & "].sAndSMasterRefNum", POS.gvms_SS) + End If + cnt += 1 + Next + + '---------transitDeclarations TSAD---------------- + cnt = 0 + For Each POS In GVMS.GVMS_POSITIONEN + If POS.gvms_art = VERAG_PROG_ALLGEMEIN.cGVMS_POS_DecArt.TSAD Then + json.UpdateString("transitDeclarations[" & cnt & "].transitDeclarationId", POS.gvms_RefNum) + json.UpdateBool("transitDeclarations[" & cnt & "].isTSAD", True) + If If(POS.gvms_SS, "") <> "" Then json.UpdateString("transitDeclarations[" & cnt & "].sAndSMasterRefNum", POS.gvms_SS) + End If + cnt += 1 + Next + + '---------transitDeclarations TAD---------------- + cnt = 0 + For Each POS In GVMS.GVMS_POSITIONEN + If POS.gvms_art = VERAG_PROG_ALLGEMEIN.cGVMS_POS_DecArt.TAD Then + json.UpdateString("transitDeclarations[" & cnt & "].transitDeclarationId", POS.gvms_RefNum) + json.UpdateBool("transitDeclarations[" & cnt & "].isTSAD", False) + If If(POS.gvms_SS, "") <> "" Then json.UpdateString("transitDeclarations[" & cnt & "].sAndSMasterRefNum", POS.gvms_SS) + End If + cnt += 1 + Next + + '---------tirDeclarations---------------- + cnt = 0 + For Each POS In GVMS.GVMS_POSITIONEN + If POS.gvms_art = VERAG_PROG_ALLGEMEIN.cGVMS_POS_DecArt.TIR Then + json.UpdateString("tirDeclarations[" & cnt & "].tirCarnetId", POS.gvms_RefNum) + If If(POS.gvms_SS, "") <> "" Then json.UpdateString("tirDeclarations[" & cnt & "].sAndSMasterRefNum", POS.gvms_SS) + End If + cnt += 1 + Next + + '---------ataDeclarations---------------- + cnt = 0 + For Each POS In GVMS.GVMS_POSITIONEN + If POS.gvms_art = VERAG_PROG_ALLGEMEIN.cGVMS_POS_DecArt.ATA Then + json.UpdateString("ataDeclarations[" & cnt & "].ataCarnetId", POS.gvms_RefNum) + If If(POS.gvms_SS, "") <> "" Then json.UpdateString("ataDeclarations[" & cnt & "].sAndSMasterRefNum", POS.gvms_SS) + End If + cnt += 1 + Next + + + '---------eidrDeclarations---------------- + cnt = 0 + For Each POS In GVMS.GVMS_POSITIONEN + If POS.gvms_art = VERAG_PROG_ALLGEMEIN.cGVMS_POS_DecArt.EIDR Then + json.UpdateString("eidrDeclarations[" & cnt & "].traderEORI", POS.gvms_RefNum) + If If(POS.gvms_SS, "") <> "" Then json.UpdateString("eidrDeclarations[" & cnt & "].sAndSMasterRefNum", POS.gvms_SS) + End If + cnt += 1 + Next + + + '---------indirectExportDeclarations---------------- + cnt = 0 + For Each POS In GVMS.GVMS_POSITIONEN + If POS.gvms_art = VERAG_PROG_ALLGEMEIN.cGVMS_POS_DecArt.INDIRECT Then + json.UpdateString("indirectExportDeclarations[" & cnt & "].eadMasterRefNum", POS.gvms_RefNum) + End If + cnt += 1 + Next + + End If + + + rest.AddHeader("Content-Type", "application/json") + rest.AddHeader("Authorization", "Bearer " & hmrc_app_server_token) + rest.AddHeader("Accept", "application/vnd.hmrc.1.0+json") + + Dim sbRequestBody As New Chilkat.StringBuilder + json.EmitSb(sbRequestBody) + + + Dim sbResponseBody As New Chilkat.StringBuilder + + If updateGMR <> "" Then 'UPDATE! + success = rest.FullRequestSb("PUT", "/customs/goods-movement-system/movements/" & updateGMR, sbRequestBody, sbResponseBody) + Dim respStatusCode As Integer = rest.ResponseStatusCode + + If (respStatusCode = 404) Then 'update + MsgBox("GMR wurde nicht gefunden.") + Return False + End If + '403 + If (respStatusCode = 202) Then + MsgBox("UPDATE: " & Now.ToShortDateString & " " & Now.ToShortTimeString) + + Return True 'OK + Else + MsgBox("HMRC ERROR: " & respStatusCode & rest.ResponseHeader.ToString) + MsgBox("HMRC ERROR: " & sbResponseBody.ToString) + Return False + End If + + Else + success = rest.FullRequestSb("POST", "/customs/goods-movement-system/movements", sbRequestBody, sbResponseBody) + + + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + Return False + End If + Dim respStatusCode As Integer = rest.ResponseStatusCode + + If (respStatusCode = 404) Then 'update + MsgBox("GMR wurde nicht gefunden.") + Return False + End If + + If (respStatusCode <> 202) Then + MsgBox("HMRC ERROR: " & respStatusCode & rest.ResponseHeader.ToString) + MsgBox("HMRC ERROR: " & sbResponseBody.ToString) + Return False + End If + + + + 'Dim jsonResp = New Chilkat.JsonObject() + 'jsonResp.Load(rest.ResponseHeader) + + + 'MsgBox(rest.ResponseHeader) + + 'MsgBox(jsonResp.StringOf("Notification-Box-Id")) + 'MsgBox(jsonResp.StringOf("Notification-Message-Id")) + + 'Notification_Box_Id = (jsonResp.StringOf("Notification-Box-Id")) + 'Notification_Message_Id = (jsonResp.StringOf("Notification-Message-Id")) + + For Each rh In rest.ResponseHeader.Split(vbNewLine) + If (rh.Contains("Notification-Box-Id: ")) Then + Notification_Box_Id = rh.Replace("Notification-Box-Id: ", "").Replace(vbNewLine, "").Replace(" ", "").Trim + ' MsgBox(Notification_Box_Id) + End If + If (rh.Contains("Notification-Message-Id: ")) Then + Notification_Message_Id = rh.Replace("Notification-Message-Id: ", "").Replace(vbNewLine, "").Replace(" ", "").Trim + ' MsgBox(Notification_Message_Id) + End If + Next + + GVMS.gvms_notification_id = Notification_Message_Id + GVMS.gvms_notification_boxid = Notification_Box_Id + + Return True + End If + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + Return False + End Function + + + Private Shared Function delGVMS_GMR(ByRef GVMS As VERAG_PROG_ALLGEMEIN.cGVMS, hmrc_app_server_token As String, ByRef Notification_Box_Id As String, ByRef Notification_Message_Id As String) As Boolean + Try + Dim rest As New Chilkat.Rest + Dim success As Boolean + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + MsgBox(rest.LastErrorText) + Return False + End If + + ' See the Online Tool for Generating JSON Creation Code + Dim json As New Chilkat.JsonObject + + ' rest.AddHeader("Content-Type", "application/json") + rest.AddHeader("Authorization", "Bearer " & hmrc_app_server_token) + rest.AddHeader("Accept", "application/vnd.hmrc.1.0+json") + + Dim sbRequestBody As New Chilkat.StringBuilder + json.EmitSb(sbRequestBody) + + + Dim sbResponseBody As New Chilkat.StringBuilder + success = rest.FullRequestSb("DELETE", "/customs/goods-movement-system/movements/" & GVMS.gvms_GMR, sbRequestBody, sbResponseBody) + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + Return False + End If + Dim respStatusCode As Integer = rest.ResponseStatusCode + + If (respStatusCode = 404) Then + MsgBox("GMR wurde nicht gefunden.") + Return False + End If + If (respStatusCode <> 202) Then + MsgBox("HMRC ERROR: " & respStatusCode & rest.ResponseHeader.ToString) + Return False + End If + + + For Each rh In rest.ResponseHeader.Split(vbNewLine) + If (rh.Contains("Notification-Box-Id: ")) Then + Notification_Box_Id = rh.Replace("Notification-Box-Id: ", "").Replace(vbNewLine, "").Replace(" ", "").Trim + ' MsgBox(Notification_Box_Id) + End If + If (rh.Contains("Notification-Message-Id: ")) Then + Notification_Message_Id = rh.Replace("Notification-Message-Id: ", "").Replace(vbNewLine, "").Replace(" ", "").Trim + ' MsgBox(Notification_Message_Id) + End If + Next + + GVMS.gvms_notification_id = Notification_Message_Id + GVMS.gvms_notification_boxid = Notification_Box_Id + + Return True + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + Return False + End Function + + + Private Shared Function getGVMS_LIST(hmrc_app_server_token As String) As Boolean + Try + Dim rest As New Chilkat.Rest + Dim success As Boolean + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + MsgBox(rest.LastErrorText) + Return False + End If + + ' See the Online Tool for Generating JSON Creation Code + Dim json As New Chilkat.JsonObject + + ' rest.AddHeader("Content-Type", "application/json") + rest.AddHeader("Authorization", "Bearer " & hmrc_app_server_token) + rest.AddHeader("Accept", "application/vnd.hmrc.1.0+json") + + Dim sbRequestBody As New Chilkat.StringBuilder + 'json.EmitSb(sbRequestBody) + + + Dim sbResponseBody As New Chilkat.StringBuilder + success = rest.FullRequestSb("GET", "/customs/goods-movement-system/movements", sbRequestBody, sbResponseBody) + + MsgBox("GO " & success) + + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + Return False + End If + Dim respStatusCode As Integer = rest.ResponseStatusCode + + + If (respStatusCode = 200) Then + MsgBox(sbResponseBody.ToString) + Return True + Else + MsgBox(sbResponseBody.ToString) + MsgBox(rest.ResponseHeader.ToString) + MsgBox("HMRC ERROR: " & respStatusCode & rest.ResponseHeader.ToString) + Return False + End If + + + Return True + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + Return False + End Function + + + Private Shared Function getGVMS_GMR(GMR As String, hmrc_app_server_token As String) As Boolean + Try + Dim rest As New Chilkat.Rest + Dim success As Boolean + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + MsgBox(rest.LastErrorText) + Return False + End If + + ' See the Online Tool for Generating JSON Creation Code + Dim json As New Chilkat.JsonObject + + ' rest.AddHeader("Content-Type", "application/json") + rest.AddHeader("Authorization", "Bearer " & hmrc_app_server_token) + rest.AddHeader("Accept", "application/vnd.hmrc.1.0+json") + + Dim sbRequestBody As New Chilkat.StringBuilder + + + Dim sbResponseBody As New Chilkat.StringBuilder + success = rest.FullRequestSb("GET", "/customs/goods-movement-system/movements/" & GMR, sbRequestBody, sbResponseBody) + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + Return False + End If + Dim respStatusCode As Integer = rest.ResponseStatusCode + + + If (respStatusCode = 200) Then + MsgBox(sbResponseBody.ToString) + Return True + Else + MsgBox("HMRC ERROR: " & respStatusCode & rest.ResponseHeader.ToString) + Return False + End If + + + Return True + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + Return False + End Function + + + Private Shared Sub getGVMS_Notifications(hmrc_app_server_token As String, Notification_Box_Id As String) + Try + + + Dim rest As New Chilkat.Rest + Dim success As Boolean + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + + Exit Sub + End If + '37d1feab8776c006f7fb7c9cc2f93172 + + + '"UK_INBOUND", + ' "UK_OUTBOUND", + ' "GB_TO_NI", + ' "NI_TO_GB" + + ' See the Online Tool for Generating JSON Creation Code + 'Dim json As New Chilkat.JsonObject + 'json.UpdateString("boxId", Notification_Box_Id) + ' json.UpdateString("status", "PENDING") + 'json.UpdateString("fromDate", "2020-06-03T14:20:54.987") + 'json.UpdateString("toDate", "2020-06-03T14:20:54.987") + + + ' rest.AddHeader("Content-Type", "application/json") + rest.AddHeader("Authorization", "Bearer " & hmrc_app_server_token) + rest.AddHeader("Accept", "application/vnd.hmrc.1.0+json") + + + Dim sbRequestBody As New Chilkat.StringBuilder + ' json.EmitSb(sbRequestBody) + + + Dim sbResponseBody As New Chilkat.StringBuilder + success = rest.FullRequestSb("GET", "/misc/push-pull-notification/box/" & Notification_Box_Id & "/notifications", sbRequestBody, sbResponseBody) + + Dim respStatusCode As Integer = rest.ResponseStatusCode + + + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + Exit Sub + End If + If (respStatusCode <> 200) Then + System.IO.File.WriteAllText("C:\Users\DEVELOPER1\Desktop\hmrc3.json", rest.ResponseHeader.ToString()) + + Debug.WriteLine("Response Status Code = " & respStatusCode) + Debug.WriteLine("Response Header:") + Debug.WriteLine(rest.ResponseHeader) + Debug.WriteLine("Response Body:") + Debug.WriteLine(sbResponseBody.GetAsString()) + Exit Sub + End If + + Dim strJson = sbResponseBody.ToString + + If strJson.StartsWith("[") Then + strJson = "{""arrNotification"":" & strJson & "}" + End If + + Dim jsonResp = New Chilkat.JsonObject() + jsonResp.Load(strJson) + + + + For i = 0 To jsonResp.SizeOfArray("arrNotification") - 1 + + 'MsgBox(jsonResp.StringOf("arrNotification[" & i & "].status")) + 'Dim notificationId = jsonResp.StringOf("arrNotification[" & i & "].notificationId") + 'If notificationId = "notificationId" Then + ' MsgBox("OOOO") + 'End If + + Dim jsonRespMsg = New Chilkat.JsonObject() + If jsonRespMsg.Load(jsonResp.StringOf("arrNotification[" & i & "].message")) Then + If jsonRespMsg.StringOf("gmrId") <> "" Then + Dim notificationId = jsonRespMsg.StringOf("messageId") + Dim GVMS = VERAG_PROG_ALLGEMEIN.cGVMS.LOAD_ByNotification(Notification_Box_Id, notificationId) + If GVMS IsNot Nothing Then + If jsonRespMsg.StringOf("gmrId") <> "" Then GVMS.gvms_GMR = jsonRespMsg.StringOf("gmrId") + If jsonRespMsg.StringOf("gmrState") <> "" Then GVMS.gvms_status = jsonRespMsg.StringOf("gmrState") + GVMS.SAVE() + End If + End If + End If + + ' MsgBox(jsonRespMsg.StringOf("messageId") & " / " & jsonRespMsg.StringOf("gmrId") & " / " & jsonRespMsg.StringOf("gmrState")) + + + Next + + 'i = 0; + 'count_i = json.SizeOfArray("product.variants"); + 'while (i < count_i) { + ' json.I = i; + ' id = json.IntOf("product.variants[i].id"); + ' product_id = json.IntOf("product.variants[i].product_id"); + ' title = json.StringOf("product.variants[i].title"); + ' price = json.StringOf("product.variants[i].price"); + ' sku = json.StringOf("product.variants[i].sku"); + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + End Sub + + Private Shared Sub getGVMS_AcknolageNotifications(hmrc_app_server_token As String, Notification_Box_Id As String, Notification_Message_Id As String) + Try + + + Dim rest As New Chilkat.Rest + Dim success As Boolean + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + + Exit Sub + End If + + ' rest.AddHeader("Content-Type", "application/json") + rest.AddHeader("Authorization", "Bearer " & hmrc_app_server_token) + rest.AddHeader("Accept", "application/vnd.hmrc.1.0+json") + + + + Dim json As New Chilkat.JsonObject + json.Load("{ + ""notificationIds"": [ + """ & Notification_Message_Id & """ + ] + }") + + Dim sbRequestBody As New Chilkat.StringBuilder + json.EmitSb(sbRequestBody) + + + Dim sbResponseBody As New Chilkat.StringBuilder + success = rest.FullRequestSb("PUT", "/misc/push-pull-notification/box/" & Notification_Box_Id & "/notifications/acknowledge", sbRequestBody, sbResponseBody) + + Dim respStatusCode As Integer = rest.ResponseStatusCode + + MsgBox("OK: " & success) + If (success <> True) Then + Debug.WriteLine(rest.LastErrorText) + Exit Sub + End If + If (respStatusCode = 204) Then + MsgBox("ACKNOLAGED " & Now.ToShortDateString & " " & Now.ToShortTimeString) + Exit Sub + Else + System.IO.File.WriteAllText("C:\Users\DEVELOPER1\Desktop\hmrc3.json", rest.ResponseHeader.ToString()) + + Debug.WriteLine("Response Status Code = " & respStatusCode) + Debug.WriteLine("Response Header:") + Debug.WriteLine(rest.ResponseHeader) + Debug.WriteLine("Response Body:") + Debug.WriteLine(sbResponseBody.GetAsString()) + Exit Sub + End If + + + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + End Sub + + + '''''''''''''''''''''''''''''''''''''''''''''''''''''''' + ''' + 'Shared Sub testToken2() + ' Dim refresh_token As String + ' Dim token As String + + ' ' construct the request for access token + ' Dim client = New RestClient(API_STRING & "/oauth/token") + ' Dim request = New RestRequest("dfe/application-info", Method.POST) + ' request.AddHeader("content-type", "application/x-www-form-urlencoded") + ' request.AddParameter("grant_type", "client_credentials") + ' request.AddParameter("client_id", "") + ' request.AddParameter("client_secret", "") + + ' ' make call to get token + ' Dim response As IRestResponse = client.Execute(request) + + ' ' Extract token + ' token = JObject.Parse(response.Content).SelectToken("$..access_token").ToString() + ' refresh_token = JObject.Parse(response.Content).SelectToken("$..refresh_token").ToString() + 'End Sub + Shared Sub getHMRC_Token(ByRef AccessToken, scope) + 'oauth2.ListenPort = 3017 + ''oauth2.AuthorizationEndpoint = "https://test-api.service.hmrc.gov.uk/oauth/authorize" + ''oauth2.TokenEndpoint = "https://test-api.service.hmrc.gov.uk/oauth/token" + 'oauth2.AuthorizationEndpoint = API_STRING & "/oauth/authorize" + 'oauth2.TokenEndpoint = API_STRING & "/oauth/token" + 'oauth2.ClientId = "xybTOMaQWcuifeW5xnGggojlACWC" + 'oauth2.ClientSecret = "bf1cfb6e-1bcb-4282-b7a0-3d3ccb2b1dc1" + ''oauth2.Scope = "read:vat write:vat" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + 'oauth2.Scope = scope '"write:goods-movement-system" + 'Dim url As String = oauth2.StartAuth() + + + ' Refer to the documentation for more information on how to get the client id/secret + 'Dim clientId As String = "xybTOMaQWcuifeW5xnGggojlACWC" + ' Dim clientSecret As String = "bf1cfb6e-1bcb-4282-b7a0-3d3ccb2b1dc1" + ' Refer to the documentation for more information on how to get the tokens + 'Dim accessToken As String = "" '"OaOXXXXTaSucp8XXcgXXH" + ' Dim refreshToken As String = "kE4HXXXXXXXhxvtUHlboSF" + + ' -- Refresh the access token + Dim request As System.Net.WebRequest = System.Net.HttpWebRequest.Create(API_STRING & "/oauth/token") + 'oauth2.AuthorizationEndpoint = API_STRING & "/oauth/authorize" + ' oauth2.TokenEndpoint = API_STRING & "/oauth/token" + request.Method = "POST" + request.ContentType = "application/x-www-form-urlencoded" + 'request.ContentType = "application/json" + + Dim outgoingQueryString As NameValueCollection = HttpUtility.ParseQueryString(String.Empty) + outgoingQueryString.Add("grant_type", "client_credentials") + ' outgoingQueryString.Add("refresh_token", refreshToken) + outgoingQueryString.Add("client_id", CLIENT_ID) + outgoingQueryString.Add("client_secret", CLIENT_SECRET) + outgoingQueryString.Add("scope", scope) '"write:goods-movement-system") + Dim postBytes As Byte() = New ASCIIEncoding().GetBytes(outgoingQueryString.ToString()) + + Dim postStream As Stream = request.GetRequestStream() + postStream.Write(postBytes, 0, postBytes.Length) + postStream.Flush() + postStream.Close() + Try + + Using response As System.Net.WebResponse = request.GetResponse() + Using streamReader As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) + ' Parse the JSON the way you prefer + 'FFFFFFFFFFFFFFFFFFALSE:::::::::::::::::::::::: Dim jsonResult As RefreshTokenResultJSON = New System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(streamReader.ReadToEnd(), GetType(RefreshTokenResultJSON)) + 'FFFFFFFFFFFFFFFFFFALSE:::::::::::::::::::::::: AccessToken = jsonResult.access_token + + + ' For more information, refer to the documentation + End Using + End Using + + Catch ex As Exception + MsgBox(ex.Message & ex.StackTrace) + End Try + '' -- Get current user profile + 'request = System.Net.HttpWebRequest.Create("https://api.clicdata.com/profile/user") + 'request.Method = "GET" + 'request.Headers.Add("Authorization", "Bearer " & accessToken) + 'Using response As System.Net.WebResponse = request.GetResponse() + ' Using streamReader As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) + ' Dim jsonResponseText = streamReader.ReadToEnd() + ' ' Parse the JSON the way you prefer + ' ' In this example the JSON will be something Like: + ' ' {"email_address" "john.smith@clicdata.com", "first_name": "John", "last_login_date": "2016−04−26T14:24:58+00:00", "last_name": "Smith", ... + ' ' For more information, refer to the documentation + ' End Using + 'End Using + + '' -- List the current data + 'request = System.Net.HttpWebRequest.Create("https://api.clicdata.com/data/") + 'request.Method = "GET" + 'request.Headers.Add("Authorization", "Bearer " & accessToken) + 'Using response As System.Net.WebResponse = request.GetResponse() + ' Using streamReader As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) + ' Dim jsonResponseText = streamReader.ReadToEnd() + ' ' Parse the JSON the way you prefer + ' ' In this example the JSON will be something Like: + ' ' { "count" 265, "data": [{ "description": "","source": "merge", "creation_date": "2015−06−10T12:47:32+02:00", "last_data_update_date": "2015−06−10T12:47:49+02:00", ... + ' ' For more information, refer to the documentation + ' End Using + 'End Using + + '' -- Create some new data + 'Dim dataId As Integer = 0 + 'request = System.Net.HttpWebRequest.Create("https://api.clicdata.com/data/") + 'request.Method = "POST" + 'request.ContentType = "application/json" + 'request.Headers.Add("Authorization", "Bearer " & accessToken) + 'Using tStreamWriter As System.IO.StreamWriter = New System.IO.StreamWriter(request.GetRequestStream()) + ' tStreamWriter.Write(New System.Web.Script.Serialization.JavaScriptSerializer().Serialize(New With {Key .name = "my test data " & Guid.NewGuid().ToString(), Key .description = "some description for my test data", Key .columns = {New With {Key .name = "column 1", Key .data_type = "text"}, New With {Key .name = "column 2", Key .data_type = "number"}}})) + 'End Using + + 'Using response As System.Net.WebResponse = request.GetResponse() + ' Using streamReader As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) + ' Dim jsonResponseText = streamReader.ReadToEnd() + ' ' The JSON returned in this example is the ID of our newly created data + ' dataId = Integer.Parse(jsonResponseText) + ' ' For more information, refer to the documentation + ' End Using + 'End Using + + '' -- Add a few rows of data + 'request = System.Net.HttpWebRequest.Create("https://api.clicdata.com/data/" & dataId & "/rows") + 'request.Method = "POST" + 'request.ContentType = "application/json" + 'request.Headers.Add("Authorization", "Bearer " & accessToken) + 'Using tStreamWriter As System.IO.StreamWriter = New System.IO.StreamWriter(request.GetRequestStream()) + ' tStreamWriter.Write(New System.Web.Script.Serialization.JavaScriptSerializer().Serialize(New With {Key .data = New Object() {New Object() {"one", 1}, New Object() {"two", 2}}})) + 'End Using + + 'Using response As System.Net.WebResponse = request.GetResponse() + ' Using streamReader As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) + ' Dim jsonResponseText = streamReader.ReadToEnd() + ' ' The JSON returned in this example tells us if the rows were inserted successfully: + ' ' { "success" true } + ' ' For more information, refer to the documentation + ' End Using + 'End Using + + + + + + End Sub + + + + Public Shared Function getTOKEN(APPLICATION, Optional forceNewToken = False) As cHMRCToken + + Dim TOKEN = New cHMRCToken(VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA, APPLICATION) + Try + Dim appl = "" + Dim HMRC_APPLICATION = "AVISO" + Select Case APPLICATION + Case "HELLOWORLD" '"EORI_CHECK" + 'appl = "write:import-control-system+read:import-control-system" + appl = "applicationRestricted" + HMRC_APPLICATION = "AVISO" + Case "GVMS" + appl = "write:goods-movement-system+read:pull-notifications" + HMRC_APPLICATION = "AVISO" + Case "VAT_CHECK" '"EORI_CHECK" + appl = "read:vat write:vat" + HMRC_APPLICATION = "AVISO" + Case "ENS" '"EORI_CHECK" + 'appl = "write:import-control-system+read:import-control-system" + appl = "write:import-control-system" + HMRC_APPLICATION = "AVISO_ENS" + Case "ENS_HELLOWORLD" '"EORI_CHECK" + 'appl = "write:import-control-system+read:import-control-system" + appl = "hello" + HMRC_APPLICATION = "AVISO_ENS" + End Select + + + + If forceNewToken OrElse TOKEN.hasEntry = False OrElse TOKEN.token_BEARER_TOKEN Is Nothing OrElse TOKEN.token_BEARER_TOKEN = "" Then + 'Neuer Token + Dim AccessToken = "" + Dim RefreshToken = "" + grantAccess(AccessToken, RefreshToken, appl, HMRC_APPLICATION) + TOKEN.token_Application = APPLICATION + TOKEN.token_BEARER_TOKEN = AccessToken + TOKEN.token_REFRESH_TOKEN = RefreshToken + TOKEN.token_refresh_datetime = Now + TOKEN.token_accestoken_datetime = Now + TOKEN.SAVE() + Else + 'Refresh + HMRC_RefreshToken(TOKEN, HMRC_APPLICATION) + End If + + Catch ex As Exception + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + Return TOKEN + End Function + + + Shared Function checkEORI_UK(eoriNumber As String, ByVal response As String) As Boolean + ' Chilkat-Objekt initialisieren + Dim http As New Chilkat.Http + + http.SetRequestHeader("Accept", "application/x-www-form-urlencoded") + + ' EORI-Nummer für die Überprüfung + 'Dim eoriNumber As String = "GB123456789000" + Dim url As String = "https://api.service.hmrc.gov.uk/customs/eori/lookup/check-multiple-eori" + + + Dim requestBody As New Chilkat.JsonObject + requestBody.AppendArray("eoris").AddStringAt(-1, eoriNumber) + requestBody.AppendArray("eoris").AddStringAt(-1, "GB8392848394939") + + + + ' HTTP GET-Anfrage senden + Dim responseHttp = http.PostJson2(url, "application/json", requestBody.Emit()) + + ' Fehlerprüfung + If http.LastMethodSuccess <> True Then + Console.WriteLine("Fehler: " & http.LastErrorText) + Return False + End If + response = responseHttp.BodyStr + ' Antwort ausgeben + Console.WriteLine("API Antwort: " & responseHttp.BodyStr) + Return True + End Function + + Shared Function checkVAT_UK(VATNumber As String, ByVal response As String) As Boolean + ' Chilkat-Objekt initialisieren + Dim http As New Chilkat.Http + + ' Falls API-Schlüssel oder Authentifizierung erforderlich ist, hinzufügen + ' Beispiel: http.SetRequestHeader("Authorization", "Bearer YOUR_ACCESS_TOKEN") + + VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() + + Dim TOKEN = getTOKEN("VAT_CHECK") + + If TOKEN.hasEntry Then + http.SetRequestHeader("Authorization", "Bearer " & TOKEN.token_BEARER_TOKEN) + http.SetRequestHeader("Accept", "application/x-www-form-urlencoded") + + ' EORI-Nummer für die Überprüfung + Dim url As String = "https://api.service.hmrc.gov.uk/organisations/vat/check-vat-number/lookup/" & VATNumber + + response = http.QuickGetStr(url) + + If http.LastMethodSuccess <> True Then + Console.WriteLine("Fehler: " & http.LastErrorText) + Return False + End If + + ' Antwort ausgeben + Console.WriteLine("API Antwort: " & response) + Return True + End If + Return False + End Function + + Public Class RefreshTokenResultJSON + Public Property access_token As String + End Class +End Class + +'Public Class Startup +' Public Sub New(ByVal configuration As IConfiguration) +' configuration = configuration +' End Sub + +' Public ReadOnly Property Configuration As IConfiguration + +' Public Sub ConfigureServices(ByVal services As IServiceCollection) +' services.Configure(Configuration) + +' services.Configure(Of CookiePolicyOptions)(Function(options) +' options.CheckConsentNeeded = Function(context) True +' options.MinimumSameSitePolicy = SameSiteMode.None +' End Function) +' services.AddSession(Function(options) +' options.IdleTimeout = TimeSpan.FromSeconds(10) +' options.Cookie.HttpOnly = True +' options.Cookie.IsEssential = True +' End Function) +' services.AddAuthentication(Function(options) +' options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme +' options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme +' options.DefaultChallengeScheme = "HMRC" +' End Function).AddCookie().AddOAuth("HMRC", Function(options) +' options.ClientId = Configuration("clientId") +' options.ClientSecret = Configuration("clientSecret") +' options.CallbackPath = New PathString(Configuration("oauthCallbackUri")) +' options.Scope.Add("hello") +' options.SaveTokens = True +' options.AuthorizationEndpoint = Configuration("uri") & "/oauth/authorize" +' options.TokenEndpoint = Configuration("uri") & "/oauth/token" +' End Function) +' services.AddRazorPages(Function(options) +' options.Conventions.AddPageRoute("/HelloWorld/Index", "") +' End Function) +' End Sub + +' Public Sub Configure(ByVal app As IApplicationBuilder, ByVal env As IWebHostEnvironment) +' If env.IsDevelopment() Then +' app.UseDeveloperExceptionPage() +' Else +' app.UseExceptionHandler("/Error") +' app.UseHsts() +' End If + +' app.UseHttpsRedirection() +' app.UseStaticFiles() +' app.UseRouting() +' app.UseAuthorization() +' app.UseAuthentication() +' app.UseSession() +' app.UseCookiePolicy() +' app.UseEndpoints(Function(endpoints) +' endpoints.MapRazorPages() +' endpoints.MapControllerRoute(name:="default", pattern:="{controller=HelloWorld}/{action=Index}") +' End Function) +' End Sub +'End Class + + + +Public Class VATResponse + Public Class Address + Public Property line1 As String + Public Property postcode As String + Public Property countryCode As String + End Class + + Public Class Target + Public Property name As String + Public Property vatNumber As String + Public Property address As Address + End Class + + Public Class Root + Public Property target As Target + Public Property processingDate As DateTime + End Class + +End Class diff --git a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj index 59319a13..c0a3d25e 100644 --- a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj +++ b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj @@ -362,7 +362,7 @@ - +