我正在開發lync自動化服務,根據自己的可用性/ lync「存在」自動將人員添加到IM對話。它基本上是一個列表,檢查誰在線,並將第一個人添加到電話中。Lync 2013 SDK上的聯繫人狀態/狀態顯示「存在未知」,直到手動客戶端搜索
我得到的問題是,有時(通常當lync必須重新啓動時),它並不總是獲取聯繫人的存在。
首先,我剛抓住它的存在。然後,我添加了代碼來檢查ContactInformationChanged事件觸發,但這似乎並沒有發生,除非我進入應用程序並手動鍵入我正在尋找的別名。
是否有一個Refresh()方法我在某處失蹤?或者有什麼辦法強迫它找到這個?這裏是我的搜索方法:
public Contact GetContact(string emailAddress)
{
Contact user;
lock (ContactLookupCache)
{
while (!ContactLookupCache.TryGetValue(emailAddress.ToLower(), out user))
{
lock (Client)
{
Client.ContactManager.BeginSearch(emailAddress, this.HandleContactLookup, null);
}
Monitor.Wait(ContactLookupCache);
}
}
return user;
}
public string GetContactPresenceState(Contact contact)
{
string presenceStatus = contact.GetContactInformation(ContactInformationType.Activity).ToString();
// see if the status is either "Presence unknown" or "Updating..."
if (IsUnknownPresenceState(presenceStatus))
{
lock (contact)
{
//bug?? This event seems to only fire sometimes when you search on the app for contact details
contact.ContactInformationChanged += (object sender, ContactInformationChangedEventArgs e) =>
{
if (e.ChangedContactInformation.Contains(ContactInformationType.Activity))
{
lock (contact)
{
presenceStatus = contact.GetContactInformation(ContactInformationType.Activity).ToString();
if(!IsUnknownPresenceState(presenceStatus))
Monitor.PulseAll(contact);
}
}
};
Monitor.Wait(contact);
}
}
return presenceStatus;
}
另外,比較遺憾的是糟糕的代碼...我只是想獲得它的工作,並保持在希望的東西會幫助更多的扔垃圾代碼。
謝謝!你是對的,這個事件只是爲了列表中的聯繫人而提出的。我現在有代碼添加到聯繫人列表中,然後嘗試獲取狀態信息。另外,我正在考慮在UCMA SDK中重寫它(因爲它確實更有意義) – ChrisG