timas API-Prüfung bei Programmeinstieg
This commit is contained in:
@@ -109,7 +109,7 @@ Public Class cTimasAPI
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub getTimeEntries(ByVal maid As Integer, ByRef info As String, Optional ByRef requestDone As Boolean = False)
|
||||
Public Sub getTimeEntries(ByVal maid As Integer, ByRef info As String, Optional ByRef entryExistingToday As Boolean = True, Optional ByRef requestDone As Boolean = False)
|
||||
Try
|
||||
|
||||
Dim returnText As String = ""
|
||||
@@ -125,11 +125,10 @@ Public Class cTimasAPI
|
||||
End If
|
||||
|
||||
Dim success As Boolean
|
||||
Dim yesterdayMidnight As DateTime
|
||||
yesterdayMidnight = Today().AddDays(-1)
|
||||
|
||||
rest.AddQueryParam("id", maid)
|
||||
rest.AddQueryParam("from", yesterdayMidnight.ToString("yyyy-MM-ddThh:mm:ss"))
|
||||
rest.AddQueryParam("to", Now().ToString("yyyy-MM-ddThh:mm:ss"))
|
||||
rest.AddQueryParam("from", Today().AddDays(-1).ToString("yyyy-MM-ddTHH:mm:ss"))
|
||||
rest.AddQueryParam("to", Now().ToString("yyyy-MM-ddTHH:mm:ss"))
|
||||
|
||||
|
||||
|
||||
@@ -159,29 +158,29 @@ Public Class cTimasAPI
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
'Dim dt As New DataTable
|
||||
'dt.Columns.Add("statusid", GetType(Integer))
|
||||
'dt.Columns.Add("stamp", GetType(DateTime))
|
||||
'dt.Columns.Add("type", GetType(String))
|
||||
|
||||
Dim dt As New DataTable
|
||||
dt.Columns.Add("statusid", GetType(Integer))
|
||||
dt.Columns.Add("stamp", GetType(DateTime))
|
||||
dt.Columns.Add("type", GetType(String))
|
||||
|
||||
|
||||
entryExistingToday = False
|
||||
Dim j As Integer = 0
|
||||
While j < jsonArray.Size
|
||||
|
||||
Dim timeEntry As Chilkat.JsonObject = jsonArray.ObjectAt(j)
|
||||
|
||||
If IsDate(timeEntry.StringOf("stamp")) Then
|
||||
If CDate(timeEntry.StringOf("stamp")) >= Today() Then
|
||||
If CDate(timeEntry.StringOf("stamp")) >= CDate(Today()) Then
|
||||
|
||||
|
||||
'Dim R As DataRow = dt.NewRow
|
||||
'R("statusid") = timeEntry.StringOf("statusid")
|
||||
'R("stamp") = timeEntry.StringOf("stamp")
|
||||
'R("type") = timeEntry.StringOf("type")
|
||||
'dt.Rows.Add(R)
|
||||
|
||||
info &= " " & IIf(timeEntry.StringOf("type") = "in", "+", " - ") & CDate(timeEntry.StringOf("stamp")).ToString("hh:mm:ss")
|
||||
Dim R As DataRow = dt.NewRow
|
||||
R("statusid") = timeEntry.StringOf("statusid")
|
||||
R("stamp") = timeEntry.StringOf("stamp")
|
||||
R("type") = timeEntry.StringOf("type")
|
||||
dt.Rows.Add(R)
|
||||
entryExistingToday = True
|
||||
info &= " " & IIf(timeEntry.StringOf("type") = "in", "+", " - ") & CDate(timeEntry.StringOf("stamp")).ToString("HH:mm:ss")
|
||||
If jsonArray.Size - 1 = j Then
|
||||
info &= " Status: " & IIf(timeEntry.StringOf("type") = "in", "Anwesend", "Abwesend")
|
||||
End If
|
||||
@@ -192,7 +191,6 @@ Public Class cTimasAPI
|
||||
End While
|
||||
|
||||
|
||||
|
||||
requestDone = True
|
||||
rest.ClearAllQueryParams()
|
||||
|
||||
@@ -203,7 +201,7 @@ Public Class cTimasAPI
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function createMA(ByVal mitarbeiter As cMitarbeiter, ByVal txtPersonalnr As Integer, ByRef info As String, ByRef dgvData As MyDatagridview, Optional ByRef requestDone As Boolean = False)
|
||||
Public Function createMA(ByVal mitarbeiter As cMitarbeiter, ByRef info As String, ByRef dgvData As MyDatagridview, Optional ByRef requestDone As Boolean = False)
|
||||
Try
|
||||
|
||||
rest.ClearAllHeaders()
|
||||
@@ -225,7 +223,7 @@ Public Class cTimasAPI
|
||||
Dim json As New Chilkat.JsonObject
|
||||
success = json.UpdateString("externid", mitarbeiter.mit_id)
|
||||
success = json.UpdateString("markingColor", "#3acc2d")
|
||||
success = json.UpdateString("pnr1", txtPersonalnr)
|
||||
success = json.UpdateString("pnr1", mitarbeiter.mit_PersonalNr)
|
||||
'success = json.UpdateString("pnr2", "ZZ-3A-Q")
|
||||
success = json.UpdateString("firstname", mitarbeiter.mit_vname)
|
||||
success = json.UpdateString("lastname", mitarbeiter.mit_nname)
|
||||
@@ -312,7 +310,7 @@ Public Class cTimasAPI
|
||||
|
||||
|
||||
|
||||
Public Sub getInfo(ByVal mitarbeiter As cMitarbeiter, ByVal txtPersonalnr As Integer, ByRef info As String)
|
||||
Public Sub getInfo(ByVal mitarbeiter As cMitarbeiter, ByRef info As String)
|
||||
|
||||
Dim failureText As String = ""
|
||||
|
||||
@@ -349,14 +347,16 @@ Public Class cTimasAPI
|
||||
End If
|
||||
|
||||
Debug.WriteLine(json)
|
||||
info &= "Startdatum: " & json.StringOf("entry") & vbNewLine
|
||||
info &= "MA-ID: " & json.StringOf("externid") & vbNewLine
|
||||
info &= "PersonalNr: " & json.StringOf("pnr1") & vbNewLine
|
||||
info &= "Name: " & json.StringOf("firstname") & " " & json.StringOf("lastname") & vbNewLine
|
||||
info &= "Info: " & json.StringOf("info") & vbNewLine
|
||||
info = "Timas-ID: " & json.StringOf("id") & vbNewLine
|
||||
info &= IIf(json.StringOf("entry") <> "", "Startdatum: " & json.StringOf("entry") & vbNewLine, "")
|
||||
info &= IIf(json.StringOf("externid") <> "", "MA-ID: " & json.StringOf("externid") & vbNewLine, "")
|
||||
info &= IIf(json.StringOf("pnr1") <> "", "PersonalNr: " & json.StringOf("pnr1") & vbNewLine, "")
|
||||
info &= IIf(json.StringOf("firstname") <> "", "Vorame: " & json.StringOf("firstname") & vbNewLine, "")
|
||||
info &= IIf(json.StringOf("lastname") <> "", "Nachname: " & json.StringOf("lastname") & vbNewLine, "")
|
||||
info &= IIf(json.StringOf("info") <> "", "Info: " & json.StringOf("info") & vbNewLine, "")
|
||||
info &= IIf(json.StringOf("id") <> "", "Timas-ID: " & json.StringOf("id") & vbNewLine, "")
|
||||
If json.BoolOf("loginActive") Then
|
||||
info &= "Login: " & json.StringOf("login")
|
||||
info &= IIf(json.StringOf("login") <> "", "Login: " & vbNewLine & json.StringOf("login") & vbNewLine, "")
|
||||
info &= IIf(json.StringOf("password") <> "", "PW: " & json.StringOf("password"), "")
|
||||
End If
|
||||
|
||||
|
||||
@@ -370,6 +370,17 @@ Public Class cTimasAPI
|
||||
|
||||
Try
|
||||
|
||||
Dim failureText As String = ""
|
||||
If Not checkConnectionTImas(failureText) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
dt.Columns.Add("id", GetType(Integer))
|
||||
dt.Columns.Add("name", GetType(String))
|
||||
dt.Columns.Add("info", GetType(String))
|
||||
dt.Columns.Add("set", GetType(Boolean))
|
||||
|
||||
Dim responseBody As String = rest.FullRequestNoBody("GET", API_STRING & "/rest/web-api/groups3")
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
@@ -404,7 +415,11 @@ Public Class cTimasAPI
|
||||
R("id") = groups.IntOf("id")
|
||||
R("name") = groups.StringOf("name")
|
||||
R("info") = groups.StringOf("info")
|
||||
R("set") = IIf(R("id") = "19", True, False)
|
||||
If R("id") = "19" Or R("id") = "129" Then 'Typ Mitarbeiter und Standardgruppe für Mitarbeiter Default true
|
||||
R("set") = True
|
||||
Else
|
||||
R("set") = False
|
||||
End If
|
||||
dt.Rows.Add(R)
|
||||
j = j + 1
|
||||
End While
|
||||
@@ -416,5 +431,80 @@ Public Class cTimasAPI
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function setTimeEntry(ByVal mitarbeiter As cMitarbeiter, ByVal timeEntry As DateTime, ByRef info As String, ByRef inout As String)
|
||||
Dim failureText As String = ""
|
||||
Dim timeEntryCreated As Boolean = False
|
||||
|
||||
If Not checkConnectionTImas(failureText) Then
|
||||
Return timeEntryCreated
|
||||
End If
|
||||
|
||||
If Not mitarbeiter.mit_timasId > 0 Then
|
||||
info = "Mitarbeiter besitzt keine TImas-Zuordnung"
|
||||
Return timeEntryCreated
|
||||
End If
|
||||
|
||||
Dim entryType As String
|
||||
|
||||
Select Case inout
|
||||
Case "in"
|
||||
entryType = "KOMMT"
|
||||
|
||||
Case "out"
|
||||
entryType = "GEHT"
|
||||
|
||||
Case Else
|
||||
entryType = "falscher ErfassgsTyp: " & inout
|
||||
info = entryType
|
||||
Return timeEntryCreated
|
||||
End Select
|
||||
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
json.UpdateString("stamp", timeEntry.ToString("yyyy-MM-ddTHH:mm:ss"))
|
||||
json.UpdateInt("statusnumber", 0) '
|
||||
json.UpdateString("type", inout)
|
||||
json.UpdateString("employeeid", mitarbeiter.mit_timasId)
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
json.EmitSb(sbRequestBody)
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
Dim success = rest.FullRequestSb("POST", "/rest/web-api/bookings", sbRequestBody, sbResponseBody)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
Return timeEntryCreated
|
||||
End If
|
||||
|
||||
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
info = rest.LastErrorText
|
||||
Return timeEntryCreated
|
||||
End If
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
Debug.WriteLine(rest.ResponseHeader)
|
||||
info = rest.ResponseStatusCode & " " & rest.ResponseStatusText
|
||||
If sbResponseBody.GetAsString <> "" Then
|
||||
info &= vbNewLine & sbResponseBody.GetAsString
|
||||
End If
|
||||
Return timeEntryCreated
|
||||
Else
|
||||
|
||||
info = "Zeiteintrag " & entryType & " angelegt!"
|
||||
|
||||
'Dim jsonResult As New Chilkat.JsonObject
|
||||
'success = jsonResult.LoadSb(sbResponseBody)
|
||||
'jsonResult.Emit()
|
||||
timeEntryCreated = True
|
||||
|
||||
End If
|
||||
|
||||
Return timeEntryCreated
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user