예제 #1
0
        // The public method to initiate an outgoing call
        public void makeCall(string callee)
        {
            // Define the mandatory (unused) private data buffer
            Csta.PrivateData_t privData = new Csta.PrivateData_t();
            privData.vendor = "MERLIN                          ".ToCharArray();
            privData.length = 4;
            privData.data   = "N".ToCharArray();

            char[] calledDevice = callee.ToCharArray();

            try
            {
                int makeCall = Csta.cstaMakeCall(acsHandle, numInvokeId, chExtension, calledDevice, ref privData);
            }
            catch (System.Exception eMakeCall)
            {
                // If we can't get back a confirmation record the error and inform the user
                MessageBox.Show("There was a TServer error. Logging the incident and continuing the application.", "TServer Error");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, eMakeCall.Message.ToString(), EventLogEntryType.Warning, 234);
                return;
            }
        }
예제 #2
0
        // The public method to check the message waiting indicator (MWI) status
        public void checkMwi()
        {
            // Define the mandatory (unused) private data buffer
            Csta.PrivateData_t privData = new Csta.PrivateData_t();
            privData.vendor = "MERLIN                          ".ToCharArray();
            privData.length = 4;
            privData.data   = "N".ToCharArray();

            int pollMwi = Csta.cstaQueryMsgWaitingInd(acsHandle, numInvokeId, chExtension, ref privData);
        }
예제 #3
0
        // The public method to clear an active call
        public void hangupCall(uint callId, char[] device, uint deviceType)
        {
            // Define the mandatory (unused) private data buffer
            Csta.PrivateData_t privData = new Csta.PrivateData_t();
            privData.vendor = "MERLIN                          ".ToCharArray();
            privData.length = 4;
            privData.data   = "N".ToCharArray();

            // Populate a ConnectionID_t struct with the active call elements
            Csta.ConnectionID_t activeCall = new Csta.ConnectionID_t();
            activeCall.callID          = callId;
            activeCall.deviceID.device = device;
            activeCall.devIDType       = (Csta.ConnectionID_Device_t)deviceType;

            int clearConnection = Csta.cstaClearConnection(acsHandle, numInvokeId, ref activeCall, ref privData);
        }
예제 #4
0
        // Check the TServer event buffer
        public void checkTServer()
        {
            // Define the mandatory (unused) private data buffer
            Csta.PrivateData_t privData = new Csta.PrivateData_t();
            privData.vendor = "MERLIN                          ".ToCharArray();
            privData.length = 4;
            privData.data   = "N".ToCharArray();

            // Define the event buffer that contains data passed back from TServer
            eventBuf = new Csta.EventBuf_t();
            ushort numEvents    = 0;
            ushort eventBufSize = (ushort)Csta.CSTA_MAX_HEAP;

            // Poll the event queue to see if any call events are occurring
            try
            {
                int polledEvent = Csta.acsGetEventPoll(acsHandle, ref eventBuf, ref eventBufSize, ref privData, ref numEvents);
            }
            catch (System.Exception eEventPoll)
            {
                // If we can't get back a confirmation record the error and inform the user
                MessageBox.Show("There was a TServer error. Logging the incident and continuing the application.", "TServer Error");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, eEventPoll.Message.ToString(), EventLogEntryType.Warning, 234);
                return;
            }

            // Parse out the data elements in the event buffer...

            // The event header
            UInt32 numAcsHandle  = BitConverter.ToUInt32(eventBuf.data, 0);
            ushort numEventClass = BitConverter.ToUInt16(eventBuf.data, 4);
            ushort numEventType  = BitConverter.ToUInt16(eventBuf.data, 6);

            TServerBufferEventArgs args = new TServerBufferEventArgs(numEventClass, numEventType);

            this.TServerBufferPoll(this, args);
        }
예제 #5
0
        // The public method to open the ACS stream
        public bool open(string strLoginId, string strPasswd, string strServerId)
        {
            // Convert the parameters to character arrays
            char[] serverId = strServerId.ToCharArray();
            char[] loginId  = strLoginId.ToCharArray();
            char[] passwd   = strPasswd.ToCharArray();

            // Define the initial set of variables used for opening the ACS Stream
            int    invokeIdType = 1;
            UInt32 invokeId     = 0;
            int    streamType   = 1;

            char[] appName     = "Mojo".ToCharArray();
            int    acsLevelReq = 1;

            char[] apiVer        = "TS1-2".ToCharArray();
            ushort sendQSize     = 0;
            ushort sendExtraBufs = 0;
            ushort recvQSize     = 0;
            ushort recvExtraBufs = 0;

            // Define the mandatory (but unused) private data structure
            Csta.PrivateData_t privData = new Csta.PrivateData_t();
            privData.vendor = "MERLIN                          ".ToCharArray();
            privData.length = 4;
            privData.data   = "N".ToCharArray();

            // Define the event buffer pointer that gets data back from the TServer
            ushort numEvents = 0;

            Csta.EventBuf_t eventBuf     = new Csta.EventBuf_t();
            ushort          eventBufSize = (ushort)Csta.CSTA_MAX_HEAP;

            // Open the ACS stream
            try
            {
                int openStream = Csta.acsOpenStream(ref acsHandle, invokeIdType, invokeId, streamType, serverId, loginId, passwd, appName, acsLevelReq, apiVer, sendQSize, sendExtraBufs, recvQSize, recvExtraBufs, ref privData);
            }
            catch (System.Exception eOpenStream)
            {
                // If we can't open the stream record the error and inform the user
                MessageBox.Show("There was a TServer error. Closing the application and logging the incident.", "TServer Error");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, eOpenStream.Message.ToString(), EventLogEntryType.Warning, 234);
                return(false);
            }

            // Wait a second to poll the event buffer
            System.Threading.Thread.Sleep(1000);

            // Poll the event buffer
            try
            {
                int openStreamConf = Csta.acsGetEventPoll(acsHandle, ref eventBuf, ref eventBufSize, ref privData, ref numEvents);
            }
            catch (System.Exception eOpenStreamConf)
            {
                // If we can't get back a confirmation record the error and inform the user
                MessageBox.Show("There was a TServer error. Closing the application and logging the incident.", "TServer Error");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, eOpenStreamConf.Message.ToString(), EventLogEntryType.Warning, 234);
                return(false);
            }

            // Parse out the data elements in the event buffer...

            // The event header
            UInt32 numAcsHandle  = BitConverter.ToUInt32(eventBuf.data, 0);
            ushort numEventClass = BitConverter.ToUInt16(eventBuf.data, 4);
            ushort numEventType  = BitConverter.ToUInt16(eventBuf.data, 6);

            // The remainder of the open stream conf structure
            numInvokeId = BitConverter.ToUInt32(eventBuf.data, 8);
            string strApiVer  = System.Text.ASCIIEncoding.ASCII.GetString(eventBuf.data, 12, 21);
            string strLibVer  = System.Text.ASCIIEncoding.ASCII.GetString(eventBuf.data, 33, 21);
            string strTsrvVer = System.Text.ASCIIEncoding.ASCII.GetString(eventBuf.data, 54, 21);
            string strDrvrVer = System.Text.ASCIIEncoding.ASCII.GetString(eventBuf.data, 75, 21);

            if (numEventClass == Csta.ACSCONFIRMATION && numEventType == Csta.ACS_OPEN_STREAM_CONF)
            {
                // The stream has been successfully opened
                return(true);
            }
            else
            {
                // If we can't get back the open stream confirmation record the error and inform the user
                string strStreamOpenFailed = "The stream was not opened. The Event Class code returned was " + numEventClass + " and the Event Type returned was " + numEventType + ".";
                MessageBox.Show("The stream was not opened.", "Open Stream Failed");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, strStreamOpenFailed, EventLogEntryType.Warning, 234);
                return(false);
            }
        }
예제 #6
0
        // The public method to monitor the provided extension
        public bool monitor(string strExtension)
        {
            // Convert the extension string to a character array
            chExtension = strExtension.ToCharArray();

            // Define the mandatory (unused) private data structure
            Csta.PrivateData_t privData = new Csta.PrivateData_t();
            privData.vendor = "MERLIN                          ".ToCharArray();
            privData.length = 4;
            privData.data   = "N".ToCharArray();

            // Define the various event monitor filters...

            // Any filters NOT added will allow those events to be monitored
            Csta.CSTAMonitorFilter_t monitorFilter = new Csta.CSTAMonitorFilter_t();
            monitorFilter.call          = 0xFFFF - Csta.CF_DELIVERED - Csta.CF_CONNECTION_CLEARED - Csta.CF_ESTABLISHED - Csta.CF_NETWORK_REACHED; // Monitor these call events
            monitorFilter.feature       = 0;                                                                                                       // Monitor everything feature-wise
            monitorFilter.agent         = 0;                                                                                                       // Monitor everything agent-wise
            monitorFilter.maintenance   = 0;                                                                                                       // Monitor everything maintenance-wise
            monitorFilter.privateFilter = 1;                                                                                                       // Mandatory but unused

            try
            {
                int monitorDevice = Csta.cstaMonitorDevice(acsHandle, numInvokeId, chExtension, ref monitorFilter, ref privData);
            }
            catch (System.Exception eMonitor)
            {
                // If we can't get back a confirmation record the error and inform the user
                MessageBox.Show("There was a TServer error. Closing the application and logging the incident.", "TServer Error");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, eMonitor.Message.ToString(), EventLogEntryType.Warning, 234);
                return(false);
            }

            // Wait a second before polling the event queue
            System.Threading.Thread.Sleep(1000);

            // Define the event buffer that contains data passed back from TServer
            ushort numEvents2 = 0;

            Csta.EventBuf_t eventBuf2     = new Csta.EventBuf_t();
            ushort          eventBufSize2 = (ushort)Csta.CSTA_MAX_HEAP;

            try
            {
                int monitorDeviceConf = Csta.acsGetEventPoll(acsHandle, ref eventBuf2, ref eventBufSize2, ref privData, ref numEvents2);
            }
            catch (System.Exception eMonitorConf)
            {
                // If we can't get back a confirmation record the error and inform the user
                MessageBox.Show("There was a TServer error. Closing the application and logging the incident.", "TServer Error");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, eMonitorConf.Message.ToString(), EventLogEntryType.Warning, 234);
                return(false);
            }

            // Parse out the data elements in the event buffer...

            // The event header
            UInt32 numAcsHandle3  = BitConverter.ToUInt32(eventBuf2.data, 0);
            ushort numEventClass3 = BitConverter.ToUInt16(eventBuf2.data, 4);
            ushort numEventType3  = BitConverter.ToUInt16(eventBuf2.data, 6);

            // The various elements contained in the rest of the event buffer
            UInt32 numInvokeId3;
            UInt32 numMonitorCrossRefId3;
            ushort numCallFilter3;
            byte   numFeatureFilter3;
            byte   numAgentFilter3;
            byte   numMaintenanceFilter3;
            UInt32 numPrivateFilter3;

            // If the device monitor was successful...
            if (numEventClass3 == Csta.CSTACONFIRMATION && numEventType3 == Csta.CSTA_MONITOR_CONF)
            {
                // Parse the elements in the event buffer
                numInvokeId3          = BitConverter.ToUInt32(eventBuf2.data, 8);
                numMonitorCrossRefId3 = BitConverter.ToUInt32(eventBuf2.data, 12);
                numCallFilter3        = BitConverter.ToUInt16(eventBuf2.data, 16);
                numFeatureFilter3     = (byte)eventBuf2.data.GetValue(18);
                numAgentFilter3       = (byte)eventBuf2.data.GetValue(20);
                numMaintenanceFilter3 = (byte)eventBuf2.data.GetValue(22);
                numPrivateFilter3     = BitConverter.ToUInt32(eventBuf2.data, 24);
                return(true);
            }
            else
            {
                string strMonitorDeviceFailed = "The device was not monitored. The Event Class code returned was " + numEventClass3 + " and the Event Type returned was " + numEventType3 + ".";
                MessageBox.Show("The device was not monitored.", "Monitor Device Failed");
                if (!EventLog.SourceExists(strSource))
                {
                    EventLog.CreateEventSource(strSource, strLog);
                }
                EventLog.WriteEntry(strSource, strMonitorDeviceFailed, EventLogEntryType.Warning, 234);
                return(false);
            }
        }