OkHttp V1.20
OkHttpUtils2 V2.70
DateUtils V1.05
JSON V1.10
Phone V2.50
SQL V1.50
Sub Send() As Boolean
Dim D As String
DateTime.DateFormat = "yyyy/MM/dd"
DateTime.TimeFormat = "HH:mm:ss"
D = DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now)
'1971-12-31 00:00:00.0000000
Dim Map1 As Map
Map1.Initialize
Map1.Clear
Map1.Put("FailureId",0)
Map1.Put("FailureDateTime",D)
Map1.Put("CompanyId",0)
Map1.Put("UserId",0)
Map1.Put("UserName",AutoCompleteEditTextUserName.Text)
Map1.Put("Trouble",EditTextTrouble.Text)
Map1.Put("Note",EditTextNote.Text)
Map1.Put("Location",AutoCompleteEditTextLocation.Text)
Map1.Put("GPS_ALTITUDE_METER",0.0)
Map1.Put("GPS_LATITUDE_DEGREE",0.0)
Map1.Put("GPS_LONGITUDE_DEGREE",0.0)
'------------ Prüfen
If Map1.Get("UserName")="" Then
ToastMessageShow("Name eingeben ..",False)
Return False
End If
If Map1.Get("Trouble")="" Then
ToastMessageShow("Problem eingeben ..",False)
Return False
End If
If Map1.Get("Location")="" Then
ToastMessageShow("Ort eingeben ..",False)
Return False
End If
'------------
Dim JSON As JSONGenerator
JSON.Initialize(Map1)
Dim data As String = JSON.ToPrettyString(1)
Log(data)
Dim Job As HttpJob
Job.Initialize("Job1",Me)
Job.Username=Main.API_User
Job.Password=Main.API_Password
Job.PostString("https://abc.name.com/failure" , data )
Job.GetRequest.SetContentType("application/json") 'need okhttp lib
Return True
End Sub
Sub JobDone(Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job1"
Log(Job.GetString)
If Job.GetString.StartsWith(Chr(34) & "OK" & Chr(34) ) Then 'das ist ja mal Panne^^
ToastMessageShow(Job.GetString,True)
StartActivity(ActivityThanks)
Activity.Finish
Else
ButtonSend.Enabled=True
ToastMessageShow("Error: " & Job.GetString, True)
End If
Case "JobTemplate"
Log(Job.GetString)
End Select
Else
ButtonSend.Enabled=True
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub