I was wondering if someone could talk me though converting this bit of VB.net code so it can function with Gambas
The following are loaded at start up of the module
PS_URL
TerminalIDNumber
PS_USER
PS_PASS
as these are unique to each client
Code: Select all
Private Sub GetTerminalStatus()
Try
Dim Request As HttpWebRequest = HttpWebRequest.Create(PS_URL & "/terminals/" & TerminalIDNumber)
Dim credentials As String = Convert.ToBase64String(Encoding.ASCII.GetBytes(PS_USER & ":" & PS_PASS))
txtResults.Text = vbNullString
With Request
.Proxy = Nothing
.Headers(HttpRequestHeader.Authorization) = String.Format("Basic {0}", credentials)
.UserAgent = PS_USER
End With
Dim response As HttpWebResponse = Request.GetResponse()
Dim dataStream As Stream = response.GetResponseStream
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
txtResults.Text = responseFromServer
If responseFromServer = "0" Then
MsgBox("Retreal of Status Failed")
addtoStatusList("Retreal of Status Failed")
If DebugActive = "Yes" Then AddToDebugList("Retreal of Status Failed Please try again")
SendToPoSterminal("RetrealFailed")
Else
Dim json As String = responseFromServer
Dim ser As JObject = JObject.Parse(json)
Dim data As List(Of JToken) = ser.Children().ToList
For Each item As JProperty In data
item.CreateReader()
Select Case item.Name
Case "status"
Select Case item.Value
Case "AVAILABLE"
GetStatus = 1
SendToPoSterminal("TerminalOnLine|")
addtoStatusList("Terminal Ready")
Case "BUSY"
SendToPoSterminal("TerminalBusy|")
addtoStatusList("Terminal busy please wait 10 seconds and try again")
Case "Offline", "OFFLINE", "offline"
SendToPoSterminal("offline|")
addtoStatusList("Terminal OFFLINE NO Card processing Possible")
End Select
End Select
Next
End If
Catch ex As Exception
addtoStatusList(ex.ToString)
If DebugActive = "Yes" Then AddToDebugList(ex.ToString)
SendToPoSterminal("ProcessingError")
FromPoSTCP.Stop()
FromPoSTCP.Start()
End Try
End Sub
If someone could guide me on this one (as it is one of the simple functions I can work out the rest of the other functions myself
The PoS Talks to the Module via TCP Connection at the moment but if someone knows a more quicker and stable way (that does not use files) then I am open to the idea of updating the communication method