This commit is contained in:
2023-09-27 12:57:29 +02:00
parent 842aee93f1
commit 47ad49ba44
5 changed files with 87 additions and 219 deletions

View File

@@ -64,7 +64,7 @@ Public Class frmMitarbeitersuche
Sub initMA()
btn.Visible = False
pnl.Visible = False
lblTimasZeiten.Visible = False
'lblTimasZeiten.Visible = False
lblTimasSaldo.Visible = False
Panel1.Visible = False
btnSettings.Visible = False
@@ -166,13 +166,24 @@ Public Class frmMitarbeitersuche
If VERAG_PROG_ALLGEMEIN.cAllgemein.USRID = MA.mit_id Then
btn.Visible = True
'Eintrag für Zeitübersicht
lblTimasZeiten.Visible = True
'lblTimasZeiten.Visible = True
lblTimasSaldo.Visible = True
If Not requestDone Then
Dim dtZeiten As New DataTable
If timas IsNot Nothing Then
timas.getTimeSaldo(MA.mit_timasId, lblTimasSaldo.Text)
timas.getTimeEntries(MA.mit_timasId, lblTimasZeiten.Text, requestDone)
If timas.getTimeEntries(MA.mit_timasId, dtZeiten, requestDone) Then
PictureBox9.Image = VERAG_PROG_ALLGEMEIN.My.Resources.Resources.uhr_green
Else
PictureBox9.Image = VERAG_PROG_ALLGEMEIN.My.Resources.Resources.uhr_red
End If
If dtZeiten.Rows.Count > 0 Then
pnlZeiten.Visible = True
Else
pnlZeiten.Visible = False
End If
End If
End If
@@ -233,171 +244,12 @@ Public Class frmMitarbeitersuche
initMA()
End Sub
Private Sub getTime(maid)
Try
Dim returnText As String = ""
lblTimasZeiten.Text = ""
If maid Is Nothing Then
Exit Sub
End If
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
Dim rest As New Chilkat.Rest
Dim API_STRING As String
API_STRING = "https://zeit.verag.ag"
Dim success As Boolean
rest.VerboseLogging = True
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)
'lblTimas.Text = rest.LastErrorText
End If
success = rest.SetAuthBasic("admin", "BmWr501956")
If (success <> True) Then
Debug.WriteLine("BAFailReason: " & rest.ConnectFailReason)
Debug.WriteLine(rest.LastErrorText)
'lblTimas.Text = rest.LastErrorText
End If
Dim responseJson As String = rest.FullRequestNoBody("GET", "/rest/web-api/employees/" & maid & "/balance")
If (rest.LastMethodSuccess <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
If (rest.ResponseStatusCode <> 200) Then
Debug.WriteLine(rest.ResponseHeader)
'lblTimas.Text = rest.ResponseStatusCode & " " & rest.ResponseStatusText
Exit Sub
End If
Debug.WriteLine(responseJson)
Dim json As New Chilkat.JsonObject
success = json.Load(responseJson)
If (success <> True) Then
Debug.WriteLine(json.LastErrorText)
End If
Debug.WriteLine(json)
'"overallBalance" 101580,
'"dailyBalance": -17340,
'"monthlyBalance": -328380,
'"actualTimeOfDay": 4260,
Dim saldo = json.StringOf("dailyBalanceYesterday") 'Tagessaldo (gestern) in Sekunden
If saldo IsNot Nothing Then
Dim saldoAsDouble = CDbl(saldo)
saldoAsDouble = Math.Round(saldoAsDouble / 3600, 2)
returnText = "Saldo Vortag: " & saldoAsDouble & "h"
End If
lblTimasSaldo.Text = returnText
Dim yesterdayMidnight As DateTime
yesterdayMidnight = Today().AddDays(-5)
rest.AddQueryParam("id", maid)
rest.AddQueryParam("from", yesterdayMidnight.ToString("yyyy-MM-ddThh:mm:ss"))
rest.AddQueryParam("to", Now().ToString("yyyy-MM-ddThh:mm:ss"))
Dim Response As String
Response = rest.FullRequestNoBody("GET", "/rest/web-api/employees/" & maid & "/bookings")
If (rest.LastMethodSuccess <> True) Then
Debug.WriteLine(rest.LastErrorText)
Exit Sub
End If
If (rest.ResponseStatusCode <> 200) Then
Debug.WriteLine(rest.ResponseHeader)
'rest.ResponseStatusCode & " " & rest.ResponseStatusText
Exit Sub
End If
Debug.WriteLine(Response)
Dim jsonArray As New Chilkat.JsonArray
success = jsonArray.Load(Response)
If (success <> True) Then
Debug.WriteLine(jsonArray.LastErrorText)
Exit Sub
End If
If jsonArray.Size = -1 Then
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 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
'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)
lblTimasZeiten.Text &= " " & IIf(timeEntry.StringOf("type") = "in", "+", " - ") & CDate(timeEntry.StringOf("stamp")).ToString("hh:mm:ss")
If jsonArray.Size - 1 = j Then
lblTimasZeiten.Text &= " Status: " & IIf(timeEntry.StringOf("type") = "in", "Anwesend", "Abwesend")
End If
End If
End If
j = j + 1
End While
requestDone = True
rest.ClearAllQueryParams()
Catch ex As WebException
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
Private Sub PictureBox9_Click(sender As Object, e As EventArgs) Handles PictureBox9.Click
Dim webAddress As String = "https://zeit.verag.ag/webterminal/"
Process.Start(webAddress)
End Sub
Sub setBGPic(art, MA)
HOVER_ART = art
If art = "" Or MA Is Nothing Then
@@ -456,5 +308,4 @@ Public Class frmMitarbeitersuche
End If
End Sub
End Class