I'm a noob to C#, so please sorry me for bad coding. I'm trying to make this application that while a call is happening, it gets the phone number of the caller and it will use it to take information from a CRM, and after that, it creates a Balloon from NotifyIcon that shows the information about the caller. The CRM connection and the search-by telephone number is working fine, same for the NotifyIcon, but all the TAPI part is not working. No events are raised when I try with my telephone to call my office Zoiper5 number.
Here is the class where TAPI:
using System;
using System.Windows.Forms;
using TAPI3Lib;
namespace CallHelper
{
class TapiApplication : ApplicationContext
{
private static NLog.Logger logger =
NLog.LogManager.GetCurrentClassLogger();
private TAPIClass tapi;
private string number;
private Notification notification;
private ITAddress address;
public TapiApplication()
{
try
{
tapi = new TAPIClass();
tapi.Initialize();
//Notification.cs : handle the NotifyIcon
notification = new Notification();
tapi.ITTAPIEventNotification_Event_Event += new
ITTAPIEventNotification_EventEventHandler(callNotificationHandler);
tapi.EventFilter = (int) (TAPI_EVENT.TE_CALLNOTIFICATION);
}
catch (Exception ex)
{
logger.Error(ex.Message);
}
}
private void callNotificationHandler(TAPI_EVENT TapiEvent, object
pEvent)
{
try
{
ITCallNotificationEvent cne = pEvent as ITCallNotificationEvent;
number = cne.Call.get_CallInfoString(CALLINFO_STRING.CIS_CALLEDIDNUMBER);
//creates the balloon containing the information of the caller
notification.showBalloon(number);
}
catch (Exception ex)
{
logger.Error(ex.Message);
tapi.Shutdown();
}
}
}
}
I really don't know where to search anymore; I've read many articles here on SOF, and other site talking about almost the same thing, but still, I haven't resolved.
Thanks for any help.
Problem solved. I was missing part of the initialization. On incoming calls event, you must have initialized the lines on wich you want to receive the notification, as written here ITTAPI::RegisterCallNotifications method You do that using
You can either select one single
ITAddress
, or cicle all Address in yourtapi.Address as ITCollection
and do RegisterCallNotifications for each one of them. In first case you will receive the notification only if the incoming call is directed in the address line you specified, in the second case you will receive notification any time there is a call in any of the address.This sample project helped me a lot: TAPI 3.0 Application development using C#.NET