1

我们正在开发一个 Lync 客户端应用程序,在此我们需要拨打一个号码到外部号码,当我们不使用 UI Suppression 时,以下代码可以正常工作

LyncClient lyncClient = LyncClient.GetClient();
var automation = LyncClient.GetAutomation();
var conversationModes = AutomationModalities.Audio;
var conversationSettings = new Dictionary<AutomationModalitySettings, object>();
List<string> participants = new List<string>();
var contact = lyncClient.ContactManager.GetContactByUri("tel:" + _TelephoneNumber);
participants.Add(contact.Uri);
automation.BeginStartConversation(AutomationModalities.Audio, participants, null, null, automation);

当我们在 UI 抑制模式下运行应用程序时,相同的代码 LyncClient.GetAutomation() 引发错误“HRESULT 异常:0x80C8000B”。在论坛中发现 GetAutomation() 在 UISuppression 模式下不起作用。如果有人可以为我们提供示例代码,是否有任何替代方法可以实现此功能。

4

1 回答 1

2

没错 - 您根本不能在 UI 抑制模式下使用自动化 API,因为它需要一个正在运行的、可见的 Lync 实例才能与之交互。

您可以在 UI 抑制中启动呼叫,但需要做更多的工作。首先,使用以下命令获取 Lync 客户端:

var _client = LyncClient.GetClient();

然后使用 ConversationManager 添加一个新对话:

_client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;
_client.ConversationManager.AddConversation();

以下代码显示了如何处理因添加新对话而产生的事件和操作:

private void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e)
{
    _conversation = e.Conversation;
    _conversation.ParticipantAdded += Conversation_ParticipantAdded;

    var contact = _client.ContactManager.GetContactByUri("+441234567890");
    _conversation.AddParticipant(contact);
}

private void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e)
{
    if (!e.Participant.IsSelf)
    {
        _avModality = (AVModality)_conversation.Modalities[ModalityTypes.AudioVideo];

        if (_avModality.CanInvoke(ModalityAction.Connect))
        {
            _avModality.BeginConnect(AVModalityConnectCallback, _avModality);
        }
    }
}
private void AVModalityConnectCallback(IAsyncResult ar)
{
    _avModality.EndConnect(ar);
}

希望这能让你开始。

于 2014-03-18T13:05:59.217 回答