Success. I have 4 queues to watch: green,yellow,red,claims. I actually stick my data in a table for other processes to use, but this will give you a string output. Just comment out what you don't want to see. The other thing is this really helps you figure out what is actualy coming back from the switch.
Golden code I tell you....
Here you go including the digest connection:
- Code: Select all
Dim myXML As String = "<request method='switchvox.currentCalls.getList'><parameters></parameters></request>"
Dim myURL As String = "https://myBox/xml"
Dim myCred As New NetworkCredential("admin", "adminPassword", "myDomain.com")
Dim MyURI As New Uri(myURL)
Dim myReq As HttpWebRequest = WebRequest.Create(MyURI)
Dim credCache As CredentialCache = New CredentialCache
credCache.Add(MyURI, "Digest", myCred)
myReq.Credentials = credCache
Dim myWriter As StreamWriter = Nothing
myReq.Method = "POST"
myReq.ContentLength = myXML.Length
'myReq.ContentType = "application/x-www-form-urlencoded"
myReq.ContentType = "text/xml"
myWriter = New StreamWriter(myReq.GetRequestStream())
myWriter.Write(myXML)
myWriter.Close()
Dim myRes As HttpWebResponse = myReq.GetResponse
Dim sr As StreamReader
sr = New StreamReader(myRes.GetResponseStream())
Dim ReadMe As XmlTextReader = New XmlTextReader(sr)
Dim CallStatus As String = ""
Dim CallQueue As String = ""
Dim GreenQueueCalls As Integer = 0
Dim YellowQueueCalls As Integer = 0
Dim RedQueueCalls As Integer = 0
Dim ClaimsQueueCalls As Integer = 0
Do While (ReadMe.Read())
' Do some work here on the data.
CallQueue = ""
CallStatus = ""
If ReadMe.Name = "current_call" Then
l_msg.Text &= "<br>=============================="
l_msg.Text &= "<br>Name:" & ReadMe.Name
l_msg.Text &= "<br>Value:" & ReadMe.Value
l_msg.Text &= "<br>Encoding:" & ReadMe.Encoding.ToString
l_msg.Text &= "<br>LineNumber:" & ReadMe.LineNumber.ToString
l_msg.Text &= "<br>attribute count:" & ReadMe.AttributeCount.ToString
Dim z As Integer
For z = 0 To ReadMe.AttributeCount - 1
Dim aStr As String = ReadMe.GetAttribute(z).ToString()
'turn this on to see all values
l_msg.Text &= "<br>attribute " & z.ToString & ":" & aStr
Select Case z
Case 3 ' who is getting the call
CallQueue = aStr
l_msg.Text &= "<br>attribute " & z.ToString & ":" & aStr
Case 7 ' this is the status: talking, ivr, queued
CallStatus = aStr
l_msg.Text &= "<br>attribute " & z.ToString & ":" & aStr
End Select
Next
If CallStatus = "queued" Then
Select Case LCase(CallQueue)
Case "green"
GreenQueueCalls += 1
Case "red"
RedQueueCalls += 1
Case "yellow"
YellowQueueCalls += 1
Case "claims"
ClaimsQueueCalls += 1
End Select
End If
End If
Loop
sr.Close()
l_msg.Text &= "<br>================================"
l_msg.Text &= "<br>Green Queued Calls:" & GreenQueueCalls.ToString
l_msg.Text &= "<br>Yellow Queued Calls:" & YellowQueueCalls.ToString
l_msg.Text &= "<br>Red Queued Calls:" & RedQueueCalls.ToString
l_msg.Text &= "<br>Claims Queued Calls:" & ClaimsQueueCalls.ToString