private void CallStateEvent() { // here we should check to see call state and handle connects and disconnects try { switch (CallStateObject.State) { case CALL_STATE.CS_IDLE: break; case CALL_STATE.CS_INPROGRESS: //TAPI3Lib.ITCallInfo bi = CallStateObject.Call; //if (bi.CallState == TAPI3Lib.CALL_STATE.CS_INPROGRESS) //{ //} break; case CALL_STATE.CS_OFFERING: // break; // a call is offering so if you dont want it then pass it if (ReceiveNotificationOnConnected == false) { TAPI3Lib.ITCallInfo b = CallStateObject.Call; if (b.CallState == TAPI3Lib.CALL_STATE.CS_OFFERING) { System.Threading.Thread.Sleep(2000); string callerid = b.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER); string line = b.Address.AddressName; if (OnInComingCallNotification != null) { OnInComingCallNotification(callerid, line, false); } } } break; case CALL_STATE.CS_CONNECTED: //if (ReceiveNotificationOnConnected) //{ // try // { // //TAPI3Lib.ITCallInfo bi3 = CallStateObject.Call; // new TaxiDataContext().stp_AddLog("Last Call Connected on : " + CallStateObject.Call.Address.AddressName.ToString(),"",""); // //if (bi3.CallState == TAPI3Lib.CALL_STATE.CS_CONNECTED) // //{ // // System.Threading.Thread.Sleep(500); // // string callerid = bi3.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER); // // string line = bi3.Address.AddressName; // // if (OnInComingCallNotification != null) // // { // // OnInComingCallNotification(callerid, line, true); // // } // //} // } // catch (Exception ex) // { // } //} break; // call is connected case CALL_STATE.CS_QUEUED: break; // call is beeing queued case CALL_STATE.CS_HOLD: break; // call is on hold case CALL_STATE.CS_DISCONNECTED: if (ReceiveNotificationOnConnected) { try { TAPI3Lib.ITCallInfo bi4 = CallStateObject.Call; // System.Threading.Thread.Sleep(500); string callerid = bi4.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER); string line = bi4.Address.AddressName; if (OnInComingCallNotification != null) { OnInComingCallNotification(callerid, line, true); } } catch (Exception ex) { } } break; // call is disconnected } } catch (Exception ex) { // MessageBox.Show(ex.Message); // Application.Exit(); } }
private void CallStateEvent() { // here we should check to see call state and handle connects and disconnects try { switch (CallStateObject.State) { case CALL_STATE.CS_IDLE: break; case CALL_STATE.CS_INPROGRESS: break; case CALL_STATE.CS_OFFERING: TAPI3Lib.ITCallInfo b = CallStateObject.Call; if (b.CallState == TAPI3Lib.CALL_STATE.CS_OFFERING) { System.Threading.Thread.Sleep(2000); string callerid = b.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER); string line = b.Address.DialableAddress.ToStr().Trim(); string calledNumber = b.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNUMBER); // string calledNumber = string.Empty; if (OnInComingCallNotification != null) { OnInComingCallNotification(callerid, line, false, "ring", calledNumber); } } break; case CALL_STATE.CS_CONNECTED: if (ReceiveNotificationOnConnected) { try { TAPI3Lib.ITCallInfo bi4 = CallStateObject.Call; string callerid = bi4.get_CallInfoString(CALLINFO_STRING.CIS_CALLERIDNUMBER); string line = bi4.Address.DialableAddress.ToStr().Trim(); string calledNumber = bi4.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNUMBER); // string calledNumber = string.Empty; if (OnInComingCallNotification != null) { OnInComingCallNotification(callerid, line, true, "answer", calledNumber); } } catch (Exception ex) { } } break; // call is connected case CALL_STATE.CS_QUEUED: break; // call is beeing queued case CALL_STATE.CS_HOLD: break; // call is on hold case CALL_STATE.CS_DISCONNECTED: break; // call is disconnected } } catch (Exception ex) { // MessageBox.Show(ex.Message); // Application.Exit(); } }