Sub Process_Globals
Dim hc As HttpClient
Dim SEARCH_RESULTS = 1
End Sub
Sub ChooseQuery (param As String, str As String, fc As String, tc As String)
ProgressDialogShow2("Please wait", False)
If param = "Area" Then
ExecuteRemoteQuery("SELECT T.SID, Name, Cost FROM locations L INNER JOIN service_locations SL ON L.Code = SL.Loc_Code LEFT JOIN taxi_services T ON T.SID = SL.SID WHERE Location LIKE '%" & str.Trim & "%' AND Active = 1 GROUP BY T.SID ", SEARCH_RESULTS)
Else If param = "Cost" Then
ExecuteRemoteQuery("SELECT SID, Name, Cost FROM taxi_services WHERE Cost >= '" & fc & "' AND Cost <= '" & tc & "' AND Active = 1 ", SEARCH_RESULTS)
Else If param = "Service Name" Then
ExecuteRemoteQuery("SELECT SID, Name, Cost FROM taxi_services WHERE Name LIKE '%" & str.Trim & "%' AND Active = 1 ", SEARCH_RESULTS)
Else If param = "Hotline" Then
ExecuteRemoteQuery("SELECT S.SID, Name, Cost, Phone_No FROM hotlines H INNER JOIN taxi_services S ON H.SID = S.SID WHERE Phone_No LIKE '%" & str.Trim & "%' AND Active = 1 ", SEARCH_RESULTS)
End If
End Sub
Sub ExecuteRemoteQuery (Query As String, TaskId As Int)
Dim req As HttpRequest
req.InitializePost2("http://mysite.com/service.php", Query.GetBytes("UTF8"))
hc.Initialize("hc")
hc.Execute(req, TaskId)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim res As String
res = Response.GetString("UTF8")
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select TaskId
Case SEARCH_RESULTS
Dim ressulset As List
ressulset = parser.NextArray
If ressulset.Size = 0 Then
StartActivity(NoResults)
Else
StartActivity(Results)
End If
'ProgressDialogHide
End Select
Response.Release
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error: " & Reason & ", StatusCode: " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
ProgressDialogHide
End Sub