2014-12-04 96 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 {}