I'm using the VB version of the softphone and CTIOS version 7.2.1. In our call center our agents have another application that needs to trigger the agent making a call. To do this, the other application modifies a file, "c:\cache\dial.dat". The file contains the account number and the number to be dialed. The softphone is watching the file and when it sees that it has been modified, it reads the file and makes a call for the agent to the number in the file and sticks the account number into CallVariable1. At least that is what it is supposed to do.
To test the functionality, I placed a button on the softphone main form and then attached the following code to that button's OnClick event.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim args As New CTIOSCLIENTLib.Arguments
Dim temp As String
Dim path As String = "c:\cache\dial.dat"
Dim fs As FileStream
Dim sr As StreamReader
Dim flag As Boolean = True
Dim acctNum As New String("")
Dim dialNum As New String("")
Dim tempArray As Array
fs = File.OpenRead(path)
sr = New StreamReader(fs)
temp = sr.ReadLine()
If temp.IndexOf("ACCT_NUM") > -1 Then
tempArray = temp.Split(",")
acctNum = tempArray(2)
acctNum = acctNum.Replace("""", "")
acctNum = acctNum.Replace(" ", "")
ElseIf temp.IndexOf("_DIAL_OUT") > -1 Then
tempArray = temp.Split(",")
dialNum = tempArray(2)
dialNum = dialNum.Replace("""", "")
dialNum = dialNum.Replace(" ", "")
If dialNum.Substring(1, 3) = "615" Then
dialNum = dialNum.Substring(4)
dialNum = "9" + dialNum
If (acctNum.Length > 0 And dialNum.Length > 0) Or temp.Length = 0 Then
flag = False
' send makecall request
m_Agent = m_Session.GetCurrentAgent()
Catch ex As Cisco.CtiOs.Util.CtiOsException
This works fine. Clicking the button reads the file and then makes the call. No big deal. So, at this point I create a FileSystemWatcher object and give it the following properties.
watcher.Path = "c:\cache\"
watcher.Filter = "dial.dat"
watcher.NotifyFilter = NotifyFilters.LastWrite
watcher.EnableRaisingEvents = True
And then I copy/paste the exact code that was in the Buttons Click event into the FileSystemWatcher's OnChange event. I start the softphone and then modify the file to test the application. At this point the application throws the following CTIOS exception.
System.Runtime.InteropServices.COMException(0x800101050; The server threw an exception
at Cisco.CTIOSCLIENTLib.AgentClass.MakeCall(Arguments pIArguments)
at CTIOSSoftphone.frmCTIOSSoftphone.watcher_Changed(Object sender, FileSystemEventsArgs e) in C:\NotifyMD_Code_Working\OutboundDesktop\frmCTIOSSoftphone.vb:line 2412
I can still hit the button and the code executes fine. Does anyone have any idea what might be causing this error? Normally I might take this to the Microsoft VB.NET boards but this seems to be a CTIOS thing, so I figured I'd bring it up here. Any help at all would be greatly appreciated.