【问题标题】:Lync 2013 user availabilityLync 2013 用户可用性
【发布时间】:2015-03-22 03:24:13
【问题描述】:

我想编写一个应用程序来检查 lync 2013 用户列表的可用性。那么有没有办法让 lync 与我的应用程序交换这些信息。

我想与在特定时间在线的用户交流。由于列表将有数百个用户,我很难手动检查哪个用户在线。因此我想开发一个外部应用程序为我做这个。

【问题讨论】:

    标签: c# lync-2013 ucma lync-client-sdk lync-server-2013


    【解决方案1】:

    您应该能够通过 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 + ".");
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-25
      • 1970-01-01
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多