From 09da4c122e9c3247fb1c6a09ff3c11e8c414f36a Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Mon, 10 Jul 2023 13:49:47 +0200 Subject: [PATCH] Groups --- .../Schnittstellen/cTimasAPI.vb | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/cTimasAPI.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/cTimasAPI.vb index b7aad491..a701c746 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/cTimasAPI.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/cTimasAPI.vb @@ -366,5 +366,55 @@ Public Class cTimasAPI End Try End Sub + Public Sub getGroups(ByRef dt As DataTable) + + Try + + Dim responseBody As String = rest.FullRequestNoBody("GET", API_STRING & "/rest/web-api/groups3") + If (rest.LastMethodSuccess <> True) Then + Debug.WriteLine(rest.LastErrorText) + Exit Sub + End If + + If (rest.ResponseStatusCode <> 200) Then + Debug.WriteLine(rest.ResponseStatusCode & " " & rest.ResponseStatusText) + End If + + + Dim jsonArray As New Chilkat.JsonArray + Dim success As Boolean = jsonArray.Load(responseBody) + If (success <> True) Then + Debug.WriteLine(jsonArray.LastErrorText) + Exit Sub + End If + + + Dim num As Integer = jsonArray.Size + If num = -1 Then + Exit Sub + End If + + + Dim j As Integer = 0 + While j < num + + Dim groups As Chilkat.JsonObject = jsonArray.ObjectAt(j) + + Dim R As DataRow = dt.NewRow + R("id") = groups.IntOf("id") + R("name") = groups.StringOf("name") + R("info") = groups.StringOf("info") + R("set") = IIf(R("id") = "19", True, False) + dt.Rows.Add(R) + j = j + 1 + End While + + + Catch ex As WebException + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + + End Sub + End Class