Timas, Fremdwährungen, Vorauskasse
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
Imports System.Net
|
||||
Imports System.Diagnostics.Tracing
|
||||
Imports System.Net
|
||||
Imports System.Threading
|
||||
Imports System.Windows.Forms
|
||||
|
||||
Public Class cTimasAPI
|
||||
|
||||
@@ -15,26 +18,26 @@ Public Class cTimasAPI
|
||||
Try
|
||||
Dim success As Boolean
|
||||
|
||||
rest.VerboseLogging = False
|
||||
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)
|
||||
failureText = rest.LastErrorText
|
||||
Return False
|
||||
End If
|
||||
rest.VerboseLogging = False
|
||||
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)
|
||||
failureText = rest.LastErrorText
|
||||
Return False
|
||||
End If
|
||||
|
||||
success = rest.SetAuthBasic("admin", "BmWr501956")
|
||||
success = rest.SetAuthBasic("admin", "BmWr501956")
|
||||
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine("BAFailReason: " & rest.ConnectFailReason)
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
failureText = rest.LastErrorText
|
||||
Return False
|
||||
End If
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine("BAFailReason: " & rest.ConnectFailReason)
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
failureText = rest.LastErrorText
|
||||
Return False
|
||||
End If
|
||||
|
||||
Return True
|
||||
|
||||
@@ -200,7 +203,7 @@ Public Class cTimasAPI
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function createMA(ByVal mitarbeiter As cMitarbeiter, ByRef info As String, ByRef datatableTimas As DataTable, Optional ByRef requestDone As Boolean = False)
|
||||
Public Function createEmployee(ByVal mitarbeiter As cMitarbeiter, ByRef info As String, ByRef datatableTimas As DataTable, Optional ByRef requestDone As Boolean = False)
|
||||
Try
|
||||
|
||||
rest.ClearAllHeaders()
|
||||
@@ -229,8 +232,6 @@ Public Class cTimasAPI
|
||||
success = json.UpdateString("gender", IIf(mitarbeiter.mit_geschlecht = "m", "male", "female"))
|
||||
success = json.UpdateInt("card", mitarbeiter.mit_id)
|
||||
success = json.UpdateString("info", mitarbeiter.mit_firma & " - " & mitarbeiter.mit_abteilung)
|
||||
'success = json.UpdateString("clientNumber", "5600-02")
|
||||
'success = json.UpdateInt("rfid", 178230359)
|
||||
If mitarbeiter.mit_gebdat <> "" And IsDate(mitarbeiter.mit_gebdat) Then
|
||||
success = json.UpdateString("birthday", CDate(mitarbeiter.mit_gebdat).ToString("yyyy-MM-dd"))
|
||||
End If
|
||||
@@ -349,7 +350,6 @@ Public Class cTimasAPI
|
||||
Debug.WriteLine(json.LastErrorText)
|
||||
End If
|
||||
|
||||
Debug.WriteLine(json)
|
||||
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, "")
|
||||
@@ -362,14 +362,265 @@ Public Class cTimasAPI
|
||||
info &= IIf(json.StringOf("password") <> "", "PW: " & json.StringOf("password"), "")
|
||||
End If
|
||||
|
||||
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub getGroups(ByRef dt As DataTable)
|
||||
Public Function getEmployee(mitarbeiterID As String) As cTimasEmployee
|
||||
|
||||
Try
|
||||
|
||||
If Not checkConnectionTImas("") Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim responseJson As String = rest.FullRequestNoBody("GET", "/rest/web-api/employees/" & mitarbeiterID)
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
If (rest.ResponseStatusCode <> 200) Then
|
||||
Debug.WriteLine(rest.ResponseHeader)
|
||||
MsgBox(rest.ResponseStatusCode & " " & rest.ResponseStatusText)
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Debug.WriteLine(responseJson)
|
||||
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
Dim success = json.Load(responseJson)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine(json.LastErrorText)
|
||||
End If
|
||||
|
||||
|
||||
Dim emp As New cTimasEmployee()
|
||||
|
||||
emp.ID = json.StringOf("id")
|
||||
emp.externid = json.StringOf("externid")
|
||||
emp.pnr1 = json.StringOf("pnr1")
|
||||
emp.pnr2 = json.StringOf("pnr2")
|
||||
emp.firstname = json.StringOf("firstname")
|
||||
emp.lastname = json.StringOf("lastname")
|
||||
emp.gender = json.StringOf("gender")
|
||||
emp.clientNumber = json.StringOf("clientNumber")
|
||||
emp.card = json.StringOf("card")
|
||||
emp.info = json.StringOf("info")
|
||||
emp.rfid = json.StringOf("rfid")
|
||||
emp.login = json.StringOf("login")
|
||||
emp.email = json.StringOf("email")
|
||||
emp.loginActive = json.BoolOf("loginActive")
|
||||
emp.password = json.StringOf("password")
|
||||
|
||||
emp.street = json.StringOf("street")
|
||||
emp.zipcode = json.StringOf("zipcode")
|
||||
emp.city = json.StringOf("city")
|
||||
emp.phone1 = json.StringOf("phone1")
|
||||
emp.phone2 = json.StringOf("phone2")
|
||||
|
||||
emp.birthdayDate = json.StringOf("birthday")
|
||||
emp.entryDate = json.StringOf("entry")
|
||||
emp.exitDate = json.StringOf("exit")
|
||||
|
||||
|
||||
|
||||
Dim groups As Chilkat.JsonArray = json.ArrayOf("groups")
|
||||
If (json.LastMethodSuccess = False) Then
|
||||
Debug.WriteLine("groups member not found.")
|
||||
End If
|
||||
|
||||
emp.Gruppen = New List(Of cTimasGruppe)
|
||||
Dim numGroups As Integer = groups.Size
|
||||
Dim i As Integer = 0
|
||||
While i < numGroups
|
||||
Dim TIMASGroups As New cTimasGruppe(emp.ID)
|
||||
TIMASGroups.Id = groups.IntAt(i)
|
||||
emp.Gruppen.Add(TIMASGroups)
|
||||
i = i + 1
|
||||
End While
|
||||
|
||||
|
||||
Debug.WriteLine(json)
|
||||
|
||||
Return emp
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
|
||||
Public Function updateEmployee(emp As cTimasEmployee, dgv As DataGridView) As Boolean
|
||||
|
||||
Try
|
||||
|
||||
Dim success As Boolean
|
||||
|
||||
If True Then
|
||||
|
||||
|
||||
If Not checkConnectionTImas("") Then
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Dim json As New Chilkat.JsonObject
|
||||
|
||||
|
||||
success = json.UpdateString("externid", emp.externid)
|
||||
success = json.UpdateString("pnr1", emp.pnr1)
|
||||
success = json.UpdateString("pnr2", emp.pnr2)
|
||||
success = json.UpdateString("firstname", emp.firstname)
|
||||
success = json.UpdateString("lastname", emp.lastname)
|
||||
success = json.UpdateString("gender", emp.gender)
|
||||
|
||||
success = json.UpdateString("card", emp.card)
|
||||
success = json.UpdateString("info", emp.info)
|
||||
success = json.UpdateString("rfid", emp.rfid)
|
||||
success = json.UpdateString("login", emp.login)
|
||||
success = json.UpdateString("email", emp.email)
|
||||
success = json.UpdateBool("loginActive", emp.loginActive)
|
||||
success = json.UpdateString("password", emp.password)
|
||||
|
||||
success = json.UpdateString("street", emp.street)
|
||||
success = json.UpdateString("city", emp.city)
|
||||
success = json.UpdateString("phone1", emp.phone1)
|
||||
success = json.UpdateString("phone2", emp.phone2)
|
||||
|
||||
success = json.UpdateString("birthday", emp.birthdayDate)
|
||||
success = json.UpdateString("entry", emp.entryDate)
|
||||
success = json.UpdateString("exit", emp.exitDate)
|
||||
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
json.EmitSb(sbRequestBody)
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
success = rest.FullRequestSb("PUT", "/rest/web-api/employees/" & emp.ID, sbRequestBody, sbResponseBody)
|
||||
|
||||
If (rest.LastMethodSuccess <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
If (rest.ResponseStatusCode <> 201) Then
|
||||
Debug.WriteLine(rest.ResponseHeader)
|
||||
MsgBox(rest.ResponseStatusCode & " " & rest.ResponseStatusText)
|
||||
Return Nothing
|
||||
End If
|
||||
|
||||
Debug.WriteLine(sbResponseBody)
|
||||
End If
|
||||
|
||||
If dgv IsNot Nothing AndAlso dgv.RowCount > 0 AndAlso emp.Gruppen IsNot Nothing Then
|
||||
|
||||
|
||||
|
||||
For Each r As DataGridViewRow In dgv.Rows
|
||||
For Each i As cTimasGruppe In emp.Gruppen
|
||||
If r.Cells("set").Value = False AndAlso r.Cells("id").Value = i.Id Then
|
||||
deleteGroupmembers(i.Id, emp.ID)
|
||||
Exit For
|
||||
ElseIf r.Cells("set").Value = True AndAlso r.Cells("id").Value <> i.Id Then
|
||||
addGroupmembers(r.Cells("id").Value, emp.ID)
|
||||
Exit For
|
||||
|
||||
End If
|
||||
|
||||
Next
|
||||
Next
|
||||
|
||||
End If
|
||||
|
||||
Return success
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Function
|
||||
|
||||
Public Sub getAllGroups(ByRef dt As DataTable, Optional initialGroup As Boolean = True)
|
||||
|
||||
Try
|
||||
|
||||
Dim failureText As String = ""
|
||||
If Not checkConnectionTImas(failureText) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
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
|
||||
|
||||
If dt IsNot Nothing And Not dt.Columns.Contains("id") Then
|
||||
|
||||
dt.Columns.Add("id", GetType(Integer))
|
||||
dt.Columns.Add("name", GetType(String))
|
||||
dt.Columns.Add("groupType", GetType(String))
|
||||
dt.Columns.Add("info", GetType(String))
|
||||
dt.Columns.Add("set", GetType(Boolean))
|
||||
|
||||
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("groupType") = groups.StringOf("groupType")
|
||||
R("info") = groups.StringOf("info")
|
||||
If initialGroup = True Then
|
||||
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
|
||||
End If
|
||||
dt.Rows.Add(R)
|
||||
j = j + 1
|
||||
End While
|
||||
|
||||
dt.DefaultView.Sort = " groupType asc, name asc"
|
||||
dt = dt.DefaultView.ToTable()
|
||||
|
||||
End If
|
||||
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub getGroupsFromEmployee(ByRef dt As DataTable)
|
||||
|
||||
Try
|
||||
|
||||
@@ -444,6 +695,59 @@ Public Class cTimasAPI
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Public Sub addGroupmembers(ByVal groupID As Integer, ByVal maId As Integer)
|
||||
|
||||
Try
|
||||
|
||||
Dim success As Boolean
|
||||
Dim jarr As New Chilkat.JsonArray
|
||||
jarr.AddIntAt(-1, maId)
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
jarr.EmitSb(sbRequestBody)
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
|
||||
success = rest.FullRequestSb("POST", "/rest/web-api/groups/" & groupID & "/addmembers", sbRequestBody, sbResponseBody)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
|
||||
End If
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub deleteGroupmembers(ByVal groupID As Integer, ByVal maId As Integer)
|
||||
|
||||
Try
|
||||
|
||||
Dim success As Boolean
|
||||
Dim jarr As New Chilkat.JsonArray
|
||||
jarr.AddIntAt(-1, maId)
|
||||
|
||||
Dim sbRequestBody As New Chilkat.StringBuilder
|
||||
jarr.EmitSb(sbRequestBody)
|
||||
|
||||
Dim sbResponseBody As New Chilkat.StringBuilder
|
||||
|
||||
success = rest.FullRequestSb("POST", "/rest/web-api/groups/" & groupID & "/removemembers", sbRequestBody, sbResponseBody)
|
||||
If (success <> True) Then
|
||||
Debug.WriteLine(rest.LastErrorText)
|
||||
|
||||
End If
|
||||
|
||||
Catch ex As WebException
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||
End Try
|
||||
|
||||
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
|
||||
@@ -557,7 +861,7 @@ Public Class cTimasAPI
|
||||
Return "Array Failure"
|
||||
End If
|
||||
|
||||
If dt IsNot Nothing And Not dt.Columns.Contains("Id") Then
|
||||
If dt IsNot Nothing AndAlso Not dt.Columns.Contains("Id") Then
|
||||
dt.Columns.Add("Id", GetType(Integer))
|
||||
'dt.Columns.Add("externid", GetType(String))
|
||||
dt.Columns.Add("Personal-Nr (Lohn)", GetType(String))
|
||||
@@ -595,3 +899,55 @@ Public Class cTimasAPI
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
Public Class cTimasEmployee
|
||||
|
||||
Public ID As Integer
|
||||
Public externid As String
|
||||
Public pnr1 As String
|
||||
Public pnr2 As String
|
||||
Public firstname As String
|
||||
Public lastname As String
|
||||
Public gender As String
|
||||
Public clientNumber As String
|
||||
Public rfid As String
|
||||
Public card As Integer
|
||||
Public info As String
|
||||
Public login As String
|
||||
Public email As String
|
||||
Public loginActive As Boolean
|
||||
Public password As String
|
||||
|
||||
Public street As String
|
||||
Public city As String
|
||||
Public zipcode As String
|
||||
Public phone1 As String
|
||||
Public phone2 As String
|
||||
|
||||
Public birthdayDate As String
|
||||
Public entryDate As String
|
||||
Public exitDate As String
|
||||
|
||||
Public Gruppen As List(Of cTimasGruppe)
|
||||
|
||||
Sub New()
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Public Class cTimasGruppe
|
||||
|
||||
Public empID As Integer
|
||||
Public Id As Integer
|
||||
Public name As String
|
||||
Public groupType As String
|
||||
Public info As String
|
||||
|
||||
Sub New(empId)
|
||||
Me.empID = empId
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user