Überstundenauszahlung, TimasAPI, etc.
This commit is contained in:
@@ -4,6 +4,7 @@ Imports System.Runtime.Remoting
|
||||
Imports System.Text
|
||||
Imports System.Threading
|
||||
Imports System.Windows.Forms
|
||||
Imports Microsoft.Office.Interop.Outlook
|
||||
|
||||
Public Class cTimasAPI
|
||||
|
||||
@@ -49,18 +50,19 @@ Public Class cTimasAPI
|
||||
|
||||
End Function
|
||||
|
||||
Public Sub getTimeSaldo(maid As Integer, ByRef info As String, ByRef Optional isEndpointRunning As Boolean = True)
|
||||
Public Function getTimeSaldo(maid As Integer, ByRef info As String, kindofbalance As String, ByRef Optional isEndpointRunning As Boolean = True) As Double
|
||||
Try
|
||||
Dim returnText As String = ""
|
||||
Dim failureText As String = ""
|
||||
Dim timesaldo As Double = -1
|
||||
|
||||
|
||||
If maid < 1 Then
|
||||
Exit Sub
|
||||
Return timesaldo
|
||||
End If
|
||||
|
||||
If Not checkConnectionTImas(failureText) Then
|
||||
Exit Sub
|
||||
Return timesaldo
|
||||
End If
|
||||
|
||||
|
||||
@@ -72,13 +74,13 @@ Public Class cTimasAPI
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
isEndpointRunning = rest.LastMethodSuccess
|
||||
rest.IdleTimeoutMs = 30000 'defualt
|
||||
Exit Sub
|
||||
Return timesaldo
|
||||
End If
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
Debug.WriteLine(rest.ResponseHeader)
|
||||
'lblTimas.Text = rest.ResponseStatusCode & " " & rest.ResponseStatusText
|
||||
Exit Sub
|
||||
Return timesaldo
|
||||
End If
|
||||
|
||||
Debug.WriteLine(responseJson)
|
||||
@@ -97,27 +99,30 @@ Public Class cTimasAPI
|
||||
'"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)
|
||||
Dim infoBuilder As New StringBuilder
|
||||
'infoBuilder.Append("Vortag ")
|
||||
infoBuilder.Append(saldoAsDouble)
|
||||
infoBuilder.Append(" h")
|
||||
info = infoBuilder.ToString()
|
||||
If kindofbalance = "" Then
|
||||
info = "kindOfBalance nicht definiert! "
|
||||
Return timesaldo
|
||||
Else
|
||||
Dim saldo = json.StringOf(kindofbalance) 'Tagessaldo (gestern) in Sekunden
|
||||
If saldo IsNot Nothing Then
|
||||
Dim saldoAsDouble = CDbl(saldo)
|
||||
saldoAsDouble = Math.Round(saldoAsDouble / 3600, 2)
|
||||
Dim infoBuilder As New StringBuilder
|
||||
'infoBuilder.Append("Vortag ")
|
||||
infoBuilder.Append(saldoAsDouble)
|
||||
infoBuilder.Append(" h")
|
||||
info = infoBuilder.ToString()
|
||||
timesaldo = saldoAsDouble
|
||||
Return timesaldo
|
||||
End If
|
||||
Return timesaldo
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
End Function
|
||||
|
||||
Public Function getTimeEntries(ByVal maid As Integer, ByRef dtZeiten As DataTable, Optional ByRef entryExistingToday As Boolean = True, Optional ByRef requestDone As Boolean = False, Optional ByRef isEndpointRunning As Boolean = True) As Boolean
|
||||
Try
|
||||
@@ -186,7 +191,7 @@ Public Class cTimasAPI
|
||||
Dim timeEntry As Chilkat.JsonObject = jsonArray.ObjectAt(j)
|
||||
|
||||
If IsDate(timeEntry.StringOf("stamp")) Then
|
||||
If CDate(timeEntry.StringOf("stamp")) >= CDate(Today()) Then
|
||||
If CDate(timeEntry.StringOf("stamp")) >= CDate(Today()) Or CDate(timeEntry.StringOf("stamp")) >= CDate(Today().AddDays(-1)) AndAlso CDate(timeEntry.StringOf("stamp")).Hour >= 16 Then 'entweder heute keine Stempelung oder gestern > 16 Uhr (wegen Nachtschicht!)
|
||||
|
||||
|
||||
Dim R As DataRow = dt.NewRow
|
||||
@@ -910,24 +915,22 @@ Public Class cTimasAPI
|
||||
dt.Columns.Add("Ausweis-Nr", GetType(Integer))
|
||||
dt.Columns.Add("Info", GetType(String))
|
||||
End If
|
||||
|
||||
dt.Clear()
|
||||
|
||||
Dim j As Integer = 0
|
||||
While j < num
|
||||
Dim j As Integer = 0
|
||||
While j < num
|
||||
|
||||
Dim employee As Chilkat.JsonObject = jsonArray.ObjectAt(j)
|
||||
|
||||
Dim R As DataRow = dt.NewRow
|
||||
R("Id") = employee.IntOf("id")
|
||||
'("externid") = employee.StringOf("externid")
|
||||
R("Personal-Nr (Lohn)") = employee.StringOf("pnr1")
|
||||
R("Vorname") = employee.StringOf("firstname")
|
||||
R("Nachname") = employee.StringOf("lastname")
|
||||
R("Geschlecht") = employee.StringOf("gender")
|
||||
R("Ausweis-Nr") = employee.IntOf("card")
|
||||
R("Info") = employee.StringOf("info")
|
||||
dt.Rows.Add(R)
|
||||
Dim employee As Chilkat.JsonObject = jsonArray.ObjectAt(j)
|
||||
Dim R As DataRow = dt.NewRow
|
||||
R("Id") = employee.IntOf("id")
|
||||
'("externid") = employee.StringOf("externid")
|
||||
R("Personal-Nr (Lohn)") = employee.StringOf("pnr1")
|
||||
R("Vorname") = employee.StringOf("firstname")
|
||||
R("Nachname") = employee.StringOf("lastname")
|
||||
R("Geschlecht") = employee.StringOf("gender")
|
||||
R("Ausweis-Nr") = employee.IntOf("card")
|
||||
R("Info") = employee.StringOf("info")
|
||||
dt.Rows.Add(R)
|
||||
j = j + 1
|
||||
End While
|
||||
|
||||
@@ -937,6 +940,274 @@ Public Class cTimasAPI
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Sub getTimeAccounts(ByRef from As Date, ByRef toDate As Date, ByRef employeeNr As Integer, ByRef accountsdt As DataTable, ByRef dt As DataTable)
|
||||
|
||||
Try
|
||||
|
||||
Dim failureText As String = ""
|
||||
If Not checkConnectionTImas(failureText) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim success As Boolean
|
||||
|
||||
rest.ClearAllQueryParams()
|
||||
rest.AddQueryParam("from", from.Date.ToString("yyyy-MM-dd"))
|
||||
rest.AddQueryParam("to", toDate.Date.ToString("yyyy-MM-dd"))
|
||||
|
||||
Dim id As String = ""
|
||||
For Each row As DataRow In accountsdt.Rows
|
||||
id &= row("accountid") & ","
|
||||
Next
|
||||
rest.AddQueryParam("accounts", id)
|
||||
rest.AddQueryParam("employees", employeeNr)
|
||||
|
||||
Dim sbResponseBody As String
|
||||
|
||||
sbResponseBody = rest.FullRequestNoBody("GET", API_STRING & "/rest/web-api/accounts/values")
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
Debug.WriteLine(rest.ResponseStatusCode & " " & rest.ResponseStatusText & sbResponseBody.ToString)
|
||||
End If
|
||||
|
||||
Debug.WriteLine(sbResponseBody)
|
||||
|
||||
Dim jsonArray As New Chilkat.JsonArray
|
||||
success = jsonArray.Load(sbResponseBody)
|
||||
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
|
||||
|
||||
If dt IsNot Nothing And Not dt.Columns.Contains("accountid") Then
|
||||
|
||||
dt.Columns.Add("accountid", GetType(Integer))
|
||||
dt.Columns.Add("date", GetType(String))
|
||||
dt.Columns.Add("value", GetType(Double))
|
||||
dt.Columns.Add("multiplier", GetType(String))
|
||||
Else
|
||||
dt.Clear()
|
||||
|
||||
End If
|
||||
|
||||
Dim j As Integer = 0
|
||||
While j < num
|
||||
|
||||
|
||||
Dim accounts As Chilkat.JsonObject = jsonArray.ObjectAt(j)
|
||||
If accounts.StringOf("value") <> "" Then
|
||||
Dim R As DataRow = dt.NewRow
|
||||
R("accountid") = accounts.IntOf("accountid")
|
||||
R("date") = accounts.StringOf("date")
|
||||
Dim timeToDouble = accounts.StringOf("value").Replace("-", "")
|
||||
Dim ts As TimeSpan = New TimeSpan(Integer.Parse(timeToDouble.Split(":"c)(0)), Integer.Parse(timeToDouble.Split(":"c)(1)), 0)
|
||||
R("value") = Math.Round(ts.TotalHours, 2)
|
||||
R("multiplier") = IIf(accounts.StringOf("value").Contains("-"), "-", "+")
|
||||
dt.Rows.Add(R)
|
||||
End If
|
||||
j = j + 1
|
||||
|
||||
End While
|
||||
|
||||
dt.DefaultView.Sort = " accountid asc, date asc"
|
||||
dt = dt.DefaultView.ToTable()
|
||||
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function getTimeaccountList(ByRef dt As DataTable) As String
|
||||
|
||||
Dim failureText As String = ""
|
||||
|
||||
Try
|
||||
|
||||
If Not checkConnectionTImas(failureText) Then
|
||||
Return failureText
|
||||
|
||||
End If
|
||||
|
||||
Dim responseJson As String = rest.FullRequestNoBody("GET", "/rest/web-api/accounts/")
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
Return rest.LastErrorText
|
||||
End If
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
Debug.WriteLine(rest.ResponseHeader)
|
||||
failureText = rest.ResponseStatusCode & " " & rest.ResponseStatusText
|
||||
Return rest.ResponseStatusCode & " " & rest.ResponseStatusText
|
||||
End If
|
||||
|
||||
Debug.WriteLine(responseJson)
|
||||
|
||||
Dim jsonArray As New Chilkat.JsonArray
|
||||
Dim success As Boolean = jsonArray.Load(responseJson)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine(jsonArray.LastErrorText)
|
||||
Return jsonArray.LastErrorText
|
||||
End If
|
||||
|
||||
|
||||
Dim num As Integer = jsonArray.Size
|
||||
If num = -1 Then
|
||||
Return "Array Failure"
|
||||
End If
|
||||
|
||||
If dt IsNot Nothing AndAlso Not dt.Columns.Contains("accountid") Then
|
||||
dt.Columns.Add("accountid", GetType(Integer))
|
||||
dt.Columns.Add("name", GetType(String))
|
||||
dt.Columns.Add("accountType", GetType(String))
|
||||
dt.Columns.Add("info", GetType(String))
|
||||
dt.Columns.Add("number", GetType(Integer))
|
||||
End If
|
||||
|
||||
dt.Clear()
|
||||
|
||||
Dim j As Integer = 0
|
||||
While j < num
|
||||
|
||||
Dim R As DataRow = dt.NewRow
|
||||
R("accountid") = jsonArray.ObjectAt(j).IntOf("id")
|
||||
R("name") = jsonArray.ObjectAt(j).StringOf("name")
|
||||
R("accountType") = jsonArray.ObjectAt(j).StringOf("accountType")
|
||||
R("info") = jsonArray.ObjectAt(j).StringOf("info")
|
||||
R("number") = jsonArray.ObjectAt(j).IntOf("number")
|
||||
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 Function
|
||||
|
||||
|
||||
|
||||
|
||||
Public Function setTimeAccountEntries(ByVal mitarbeiter As cMitarbeiter, ByVal accountEntrys As DataTable, ByVal accountdate As Date, ByRef info 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 jsonArr As New Chilkat.JsonArray
|
||||
|
||||
For Each ae As DataRow In accountEntrys.Rows
|
||||
|
||||
jsonArr.AddObjectAt(-1)
|
||||
Dim Json As Chilkat.JsonObject = jsonArr.ObjectAt(jsonArr.Size - 1)
|
||||
Json.UpdateInt("accountid", ae.Item("accountid"))
|
||||
json.UpdateInt("employeeid", mitarbeiter.mit_timasId)
|
||||
json.UpdateString("date", accountdate.ToString("yyyy-MM-dd"))
|
||||
json.UpdateString("value", ae.Item("value"))
|
||||
|
||||
Next
|
||||
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
jsonArr.EmitSb(sbRequestBody)
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
Dim success = rest.FullRequestSb("POST", "/rest/web-api/accounts/values", 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
|
||||
|
||||
timeEntryCreated = True
|
||||
|
||||
End If
|
||||
|
||||
Return timeEntryCreated
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
Public Function deleteTimeAccounts(ByRef from As Date, ByRef toDate As Date, ByRef employeeNr As Integer, ByRef accountsdt As DataTable) As Boolean
|
||||
Dim timeEntryDeleted As Boolean = False
|
||||
Try
|
||||
|
||||
Dim failureText As String = ""
|
||||
If Not checkConnectionTImas(failureText) Then
|
||||
Return timeEntryDeleted
|
||||
End If
|
||||
|
||||
Dim success As Boolean
|
||||
|
||||
rest.ClearAllQueryParams()
|
||||
rest.AddQueryParam("from", from.Date.ToString("yyyy-MM-dd"))
|
||||
rest.AddQueryParam("to", toDate.Date.ToString("yyyy-MM-dd"))
|
||||
|
||||
Dim id As String = ""
|
||||
For Each row As DataRow In accountsdt.Rows
|
||||
id &= row("accountid") & ","
|
||||
Next
|
||||
rest.AddQueryParam("accounts", id)
|
||||
rest.AddQueryParam("employees", employeeNr)
|
||||
|
||||
Dim sbResponseBody As String
|
||||
|
||||
sbResponseBody = rest.FullRequestNoBody("DELETE", API_STRING & "/rest/web-api/accounts/values")
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
Return timeEntryDeleted
|
||||
End If
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
Debug.WriteLine(rest.ResponseStatusCode & " " & rest.ResponseStatusText & sbResponseBody.ToString)
|
||||
Return timeEntryDeleted
|
||||
Else
|
||||
timeEntryDeleted = True
|
||||
End If
|
||||
|
||||
Return timeEntryDeleted
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
@@ -988,6 +1259,4 @@ Public Class cTimasGruppe
|
||||
Me.empID = empId
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user