2

我的要求是我需要创建一个 Windows 服务来检索 Active Directory 中每个用户的 Lync 在线状态(可用、忙碌、请勿打扰 ....)。

我用谷歌搜索,发现下面的 SDK 可以检索 Lync Presence。Lync 客户端 2010 SDK、统一通信托管 API、Lync Server 2010 SDK、统一通信客户端 API。

请建议其中最好的 SDK 来满足我的要求。

提前致谢。

4

2 回答 2

2

每个 SDK 都有很好的说明,您可以在这里使用它们:http: //www.codelync.com/an-overview-of-the-lync-apis/

对于您想要实现的目标,我建议使用 UCMA - 统一通信客户端 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

于 2013-05-28T10:23:53.883 回答
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
        {

        }
    }

我希望这是您正在寻找的答案,否则如果我错了,请纠正我。

于 2013-12-13T05:51:01.870 回答