2014-12-04 95 views
3

我开发了一个使用Lync API的Windows应用程序。我的客户想要禁止来电到这个应用程序。所以我添加了一些这样的东西。我能够切断电话,但也有能够做到这一点不允许传入呼叫Lync Api或禁用传入呼叫的​​声音

private void ClientInitialized(IAsyncResult result) 
     { 
      try 
      { 
       //registers for conversation related events 
       //these events will occur when new conversations are created (incoming/outgoing) and removed 
       client.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded; 
       client.ConversationManager.ConversationRemoved += ConversationManager_ConversationRemoved; 
      } 
      catch (Exception ex) 
      { 
       MessageBox.Show("Problem in adding/removing conversation", "Bella IVIS", MessageBoxButtons.OK, MessageBoxIcon.Error); 
      } 
     } 

void ConversationManager_ConversationAdded(object sender, ConversationManagerEventArgs e) 
     { 
    try 
    {  
    var _client = client; 
    if (e.Conversation.State == ConversationState.Active) 
    { 
    for (int intLoop = 0; intLoop < _client.ConversationManager.Conversations.Count; intLoop++) 
    { 
     _client.ConversationManager.Conversations[intLoop].End(); 
    } 
    _client = null; 
     return; 
    } 
    } 
    } 
+1

ConversationAdded是在对话添加后。您想在添加对话之前查看以确定在完成添加之前将其完全阻止/静音 – user3036342 2014-12-04 12:19:49

+0

是否有任何要查找的事件名称 – Vivekh 2014-12-04 12:24:13

+1

这是特定于此客户端(端点)还是用户?如果是用户,您可以关闭服务器端用户的audiovideo功能。旧文章可能仍然是相关的:http://jackiechen.org/2012/02/13/disable-audiovideo-features-in-lync-client/ – 2014-12-04 19:13:08

回答

0

我不知道是否有前Conversation_Added事件捕捉谈话的方式IM前几环。但是,如果Lync状态与您没有任何关联,那么您将Lync状态更改为“请勿打扰”。这种方式你永远不会得到任何传入的请求(除非用户Lync设置允许这样做)

var newInformation =new Dictionary<PublishableContactInformationType, object>(); 
     newInformation.Add(PublishableContactInformationType.Availability, ContactAvailability.DoNotDisturb); 

try 
{ 
    this.lyncClient.Self.BeginPublishContactInformation(newInformation,(result) => this.lyncClient.Self.EndPublishContactInformation(result) , null); 
} catch {}