'Handler class
Sub Class_Globals
Private mreq As ServletRequest 'ignore
Private mresp As ServletResponse 'ignore
Public connected As Boolean
'
Private const rdcLink As String = "http://localhost:17178/rdc"
'Private const rdcLink As String = "http://localhost:17178/rdc"
Type DBResult1 (Tag As Object, Columns As Map, Rows As List)
Private start As Long = DateTime.Now
End Sub
Public Sub Initialize
End Sub
Sub Handle(req As ServletRequest, resp As ServletResponse)
mresp=resp
mreq=req
If req.ContentType.StartsWith("multipart/form-data") Then ' this you have to add to the from genrated
'parse the multipart data
Dim parts As Map = req.GetMultipartData(File.DirApp & "/www", 10000000)
Dim Value(parts.Size) As String
For i = 0 To parts.Size - 1
Dim name As String = parts.GetKeyAt(i)
Dim p As Part = parts.GetValueAt(i)
Value(i)=p.GetValue(req.CharacterEncoding)
Next
End If
Dim reqType As String = Value(1) 'This are inputs from user
Dim reqCR As String = Value(2)
GetCustomer(reqCR)
End Sub
Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = Name
If Parameters <> Null Then cmd.Parameters = Parameters
Return cmd
End Sub
Sub CreateRequest As DBRequestManager
Dim req As DBRequestManager
req.Initialize(Me, rdcLink)
Return req
End Sub
Sub GetCustomer (CR As String)
Dim rowlist As String
Dim collist As List
Dim req As DBRequestManager = CreateRequest
collist.Initialize
Log("this CR "&CR)
Dim cmd As DBCommand = CreateCommand("SelectCustomer", Array(CR))
Wait For (req.ExecuteQuery(cmd,0, Null)) JobDone(j As HttpJob)
If j.Success Then
req.HandleJobAsync(j,"req")
Wait For (req) req_Result(res As DBResult1)
For Each row() As Object In res.Rows
For i=0 To row.Length -1 ' this will get one row
rowlist=rowlist&row(i)&" "
Next
collist.Add(rowlist)
'mresp.Write(CRLF).Write(CRLF)' this for new line
rowlist=""
Next' will get new new raw
For i=0 To collist.Size-1
mresp.Write(collist.Get(i)).Write(CRLF)
Next
req.PrintTable(res)
Else
Log("ERROR: " & j.ErrorMessage)
mresp.Write("There no data "&"ERROR: " & j.ErrorMessage)
End If
End Sub