我的要求是我需要创建一个Windows服务来检索Active目录中每个用户的Lync状态(可用,忙碌,请勿打扰....)。
我用Google搜索并发现SDK下方可以检索Lync Presence。 Lync Client 2010 SDK, 统一通信托管API, Lync Server 2010 SDK, 统一通信客户端API。
请建议其中最好的SDK以达到我的要求。
先谢谢。
答案 0 :(得分:2)
每个SDK都有很好的说明,您可以在这里使用它们:http://www.codelync.com/an-overview-of-the-lync-apis/
对于您想要实现的目标,我建议使用UCMA - Unified Communications Client API。它的工作方式是你给它一个你想监视状态的用户列表,然后每当它们的存在发生变化时它就会回调一个事件。一旦开始订阅,您就会收到在线状态事件,因此如果您不想持续通知,则可以取消订阅。
订阅大量用户的示例可能是:
var _remotePresenceView = new RemotePresenceView(_endpoint);
_remotePresenceView.PresenceNotificationReceived += _remotePresenceView_PresenceNotificationReceived;
List<RemotePresentitySubscriptionTarget> subscriptions = new List<RemotePresentitySubscriptionTarget>();
subscriptions.Add(new RemotePresentitySubscriptionTarget("sip:first_user@domain));
subscriptions.Add(new RemotePresentitySubscriptionTarget("sip:second_user@domain));
...
subscriptions.Add(new RemotePresentitySubscriptionTarget("sip:nth_user@domain));
_remotePresenceView.StartSubscribingToPresentities(subscriptions);
使用Remote Presence View时有一些提示,技巧和陷阱:查看MSDN here。
答案 1 :(得分:0)
我还试图找到用户的状态,并提供以下代码来实现此要求。
string _transferUserURI="pass your sipaddress";
RemotePresenceView _RemotePresence;
RemotePresenceViewSettings settings = new RemotePresenceViewSettings();
settings.SubscriptionMode = RemotePresenceViewSubscriptionMode.Default;
settings.PollingInterval = new TimeSpan(0, 0, 10);
_RemotePresence = new RemotePresenceView(_appEndpoint, settings);
_RemotePresence.PresenceNotificationReceived += new EventHandler<RemotePresentitiesNotificationEventArgs>(_RemotePresence_PresenceNotificationReceived);
//_RemotePresence.SubscriptionStateChanged += new EventHandler<RemoteSubscriptionStateChangedEventArgs>(_RemotePresence_SubscriptionStateChanged);
RemotePresentitySubscriptionTarget target = new RemotePresentitySubscriptionTarget(_transferUserURI);
List<RemotePresentitySubscriptionTarget> targets = new List<RemotePresentitySubscriptionTarget>() { target };
_RemotePresence.StartSubscribingToPresentities(targets);
和_RemotePresence_PresenceNotificationReceived事件
void _RemotePresence_PresenceNotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e)
{
try
{
// Extract the RemotePresenceView that received the notification.
RemotePresenceView view = sender as RemotePresenceView;
// A RemotePresentityNotification will contain all the
// categories for one user; Notifications can contain notifications
// for multiple users.
foreach (RemotePresentityNotification notification in e.Notifications)
{
Console.WriteLine("\nView: " + view.ApplicationContext
+ " Received a Notification for user "
+ notification.PresentityUri + ".");
// If a category on notification is null, the category
// was not present in the notification. This means there were no
// changes in that category.
if (notification.AggregatedPresenceState != null)
{
Console.WriteLine("Aggregate State = " + notification.AggregatedPresenceState.Availability + ".");
string Availblity = notification.AggregatedPresenceState.Availability.ToString();
}
if (notification.PersonalNote != null)
{
Console.WriteLine("PersonalNote: " + notification.PersonalNote.Message + ".");
}
if (notification.ContactCard != null)
{
// A ContactCard contains many properties; only display
// some.
ContactCard contactCard = notification.ContactCard;
Console.WriteLine("ContactCard Company: " + contactCard.Company + ".");
Console.WriteLine("ContactCard DisplayName: " + contactCard.DisplayName + ".");
Console.WriteLine("ContactCard EmailAddress: " + contactCard.EmailAddress + ".");
}
}
}
catch
{
}
}
我希望这是你正在寻找的答案,否则如果我错了就纠正我。