我是C#的新手,所以请为我糟糕的编码道歉。我正在尝试制作这个应用程序,当呼叫发生时,它获取呼叫者的电话号码,并使用它从客户关系管理中获取信息,然后,它从NotifyIcon创建一个显示呼叫者信息的气球。客户关系管理连接和搜索电话号码工作正常,NotifyIcon也是如此,但所有的TAPI部分都不工作。当我尝试用我的电话呼叫我的办公室Zoiper5号码时,没有引发任何事件。
下面是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();
}
}
}
}我真的不知道到哪里去搜索了;我在SOF和其他网站上读了很多文章,都在谈论几乎相同的事情,但我仍然没有解决。
谢谢你的帮助。
发布于 2018-11-16 19:05:07
问题解决了。我错过了初始化的一部分。对于来电事件,您必须已初始化要接收通知的线路,如此处所述,您可以使用ITTAPI::RegisterCallNotifications method执行此操作
tapi.RegisterCallNotifications(address, true, true, TapiConstants.TAPIMEDIATYPE_AUDIO, 2);您可以选择一个单独的ITAddress,或者删除tapi.Address as ITCollection中的所有地址并为每个地址执行RegisterCallNotifications。在第一种情况下,只有当来电定向到您指定的地址行时,您才会收到通知;在第二种情况下,只要在任何地址上有呼叫,您都会收到通知。
这个示例项目对我帮助很大:TAPI 3.0 Application development using C#.NET
发布于 2018-11-16 06:27:13
我不确定您是否注册了您想要的活动。我建议使用这里提供的Julmar Tapi3.0 .Net包装器:https://github.com/markjulmar/itapi3。当您使用此包装器初始化Tapi时,它会注册所有事件,并查找所有可用的设备。
https://stackoverflow.com/questions/53300185
复制相似问题