Lync 2013 用户可用性

Lync 2013 user availability

我想编写一个应用程序来检查 lync 2013 列表的可用性users.So有没有办法让 lync 与我的应用程序交换此信息。

我想与在 time.As 的特定实例中在线的用户进行通信该列表将有数百个用户,我很难手动检查哪个用户是我想要的 online.Hence开发一个为我做这件事的外部应用程序。

您应该可以通过 UCMA 订阅 Lync 用户在线状态来做到这一点。参考下面的示例代码:

// Set Persistent view in class constructor
var persistentSettings = new RemotePresenceViewSettings();
persistentSettings.SubscriptionMode = RemotePresenceViewSubscriptionMode.Persistent;                
this.PersistentPresenceView = new RemotePresenceView(this.AppEndpoint, persistentSettings);

// Listen to SubscriptionStateChanged  and PresenceNotificationReceived  events
this.PersistentPresenceView.SubscriptionStateChanged += this.RemotePresenceView_SubscriptionStateChanged;
this.PersistentPresenceView.PresenceNotificationReceived += this.RemotePresenceView_NotificationReceived;

// Call below public method to subscribe to user Lync Presence
public void SubscribeToPresences(List<string> emailAddressList)
{
    var subscriptionTargets = new List<RemotePresentitySubscriptionTarget>();
    var subscribedPresentities = this.PersistentPresenceView.GetPresentities();

    if (emailAddressList != null && emailAddressList.Count > 0)
    {
        foreach (var email in emailAddressList)
        {
            try
            {
                var target = new RemotePresentitySubscriptionTarget("sip:"+email);
                if (!subscribedPresentities.Contains(presence.EmailAddress))
                {
                    subscriptionTargets.Add(target);
                }
            }
            catch (ArgumentException argumentException)
            {                                
                // ToDO: Handle exception
            }
            catch (RealTimeException realTimeException)
            {                             
                // ToDO: Handle exception
            }

        }
    }
}

// Subscription changed event
private void RemotePresenceView_SubscriptionStateChanged(object sender, RemoteSubscriptionStateChangedEventArgs e)
{  
    foreach (KeyValuePair<RealTimeAddress, RemotePresentityStateChange> stateChanged in e.SubscriptionStateChanges)
    {
        if (view != null)
        {
            Console.WriteLine("\nView: " + view.ApplicationContext
                              + "; Subscription State for user: "
                              + stateChanged.Key /* uri of subscription target */
                              + " has changed from: " + stateChanged.Value.PreviousState
                              + " to: " + stateChanged.Value.State + ".");
        }
    }
}

// Notification received event
private void RemotePresenceView_NotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e)
{
    foreach (RemotePresentityNotification notification in e.Notifications)
    {
        //// 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("Email Address: " + notification.PresentityUri.Split(':')[1]+ " Aggregate State = " + notification.AggregatedPresenceState.Availability + ".");
        }
    }
}