【问题标题】:ContactEndpoint phone, Lync 2013联系人端点电话,Lync 2013
【发布时间】:2017-11-21 09:34:03
【问题描述】:

我的应用程序使用 Lync 2013,通过 websocket 与服务器通信,并接收通知。 这些通知采用 Json 格式,因此我将其转换为提取字符串。 该字符串是一个电话号码,我想测试我的一个联系人是否是同一个电话号码以显示他的姓名。

我的 If 总是“假”。 我想使用 > 并提取 DisplayName 的值(电话号码作为字符串),但我不知道该怎么做。 这是我的代码。

foreach (var group in client.ContactManager.Groups)
                {
                    foreach (Contact contact in group)
                    {

                        List<object> endpoints = (List<object>)contact.GetContactInformation(ContactInformationType.ContactEndpoints);
                        List<object> phoneNumbers = endpoints.Cast<object>().Where<object>(N => ((ContactEndpoint)N).Type == ContactEndpointType.HomePhone ||
                                                               ((ContactEndpoint)N).Type == ContactEndpointType.MobilePhone ||
                                                               ((ContactEndpoint)N).Type == ContactEndpointType.WorkPhone ||
                                                               ((ContactEndpoint)N).Type == ContactEndpointType.OtherPhone).ToList();

                        if (phoneNumbers.ToList().Contains(call.caller))
                        {
                            MessageBox.Show(contact.GetContactInformation(ContactInformationType.DisplayName).ToString());
                        }
                    }
                }

【问题讨论】:

  • 我认为如果找到了解决方案。 foreach(var phoneNumber in phoneNumbers) { if (((ContactEndpoint)phoneNumber).DisplayName.ToString() == "我的电话号码收到") { MessageBox.Show(contact.GetContactInformation(ContactInformationType.DisplayName).ToString()); } }

标签: contact phone-number endpoint lync


【解决方案1】:

您可以通过格式化为电话 URL 的 number 直接向联系人管理员询问联系人。例如"el:12345678"

例如

var contact = client.ContactManager.GetContactByUri("tel:" + call.caller);

【讨论】:

  • 哦,这很简单,而且效果很好。 PS:我认为“GetContactByUri”方法用于搜索联系人,但只能通过其uri(地址),而不是电话。非常感谢
  • 关于电话号码格式还有其他问题。在我的情况下,call.caller 始终采用这种格式“33123456789”,但如果号码的联系人格式为“+33123456789”或“0033123456789”,那么我找不到我的联系人。我有一个 dll,它采用第一种格式的数字并返回一个像这样 {"caller":"33172387760","callers":["+33123456789","0033123456789", ]} 的 Json,但 GetContactByUri 将字符串作为争论。你知道我该怎么做吗?
  • Skype 的本机号码格式是 E164,因此实际上最好使用 E164 号码创建电话,例如“电话:+123456789”。如果您通过任何其他“号码”,它将尝试将其转换为 E164,这假定您已在系统中正确设置拨号计划。所以根据经验,如果你有 E164 号码,请使用它,否则使用其他号码。
  • 您可以测试 Skype 对 SfB natvie 客户端的作用,并尝试在“查找某人或拨打一个号码”搜索框中输入一个数字,然后查看您得到的结果。
  • 如果您可以处理多个结果,那么您可以使用联系人搜索方法。例如客户端.ContactManager.BeginSearch。不过,您可能必须处理多个结果。我会将您的系统编号转换为 E164 格式。不过,这需要本地拨号计划知识。如果您的 phoen 系统可以为您提供 E164 中的数字,那将是首选。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-01
  • 2011-07-11
  • 1970-01-01
  • 1970-01-01
  • 2015-12-16
  • 1970-01-01
相关资源
最近更新 更多