使用服务器端技术(UCMA或MSPL)检索Lync客户端的呼叫转发规则

本文关键字:Lync 检索 客户端 转发规则 呼叫 MSPL 服务器端 技术 UCMA | 更新日期: 2023-09-27 18:29:22

如何在托管SIP应用程序(服务器端技术,如MSPL或UCMA)中检索Lync客户端的呼叫转发规则(路由)?我发现的唯一一件事是一篇关于如何使用Lync SDK在客户端实现这一点的文章。

此外,这个答案、MSDN文章和这个问题似乎表明它确实有效,但我在特定时刻需要这个设置(如果用户是否在线),而不是在他登录到Lync帐户并发布其状态信息时,如链接#1所示。此外,有必要在不首先创建UserEndpoint的情况下为任何客户端获取此信息。因此,最好使用ApplicationEndpoint(或其他方法)实现这一点。

据我所知,应该可以从存在元数据中检索转发设置,但我没有得到这些信息。

 var categories = new string[] {
     "state",
     //"routing" // ?
 };
 var asyncresult = presenceSvc.BeginPresenceQuery(sips, categories, null, null, null);
 var result = presenceSvc.EndPresenceQuery(asyncresult).ToList();

使用服务器端技术(UCMA或MSPL)检索Lync客户端的呼叫转发规则

您不能使用ApplicationEndpoint执行此操作。您必须具有UserEndpoint。但是,您可以创建一个UserEndpoint,它只需要CollaborationPlatformSipUser而不需要任何密码。

对于我的应用程序,我通过ILSpy反编译了SEFAUtil.exe,以了解他们在程序中的表现。我建议你看一下。

这是我让它发挥作用的技术:

1/创建UserEndPoint

创建用户端点时,即使未连接,您也必须订阅此状态以获取信息

userEndpoint.LocalOwnerPresence.BeginSubscribe(null, null);

2/订阅PresenceNotificationReceived Event

userEndpoint.LocalOwnerPresence.PresenceNotificationReceived += OnCategoryNotificationReceived;
private static void OnCategoryNotificationReceived(object sender, LocalPresentityNotificationEventArgs e)
    {
        // Here you get the PresenceCategory and all the data of the user
        foreach (PresenceCategoryWithMetaData current in e.AllCategories)
        {
            if (current.Name == "routing" && current.ContainerId == 0 && current.InstanceId == 0L)
        // Creation of your Routing, I stock it in a Property 
                _routingCategory = new Routing(current);
        }
        // I set my event to continue my main thread
        _routingCategoryUpdated.Set(); 
    }

3/显示您想要的信息

 // Wait until you get the information of the user
 if (!_routingCategoryUpdated.WaitOne(10000))
        {
            Console.WriteLine("TimeOut Getting Informations");
            return;
        }
 // Just display all the data you can need
 else
        {
            Console.WriteLine($"User Aor: {userEndPointTarget.OwnerUri}");
            Console.WriteLine($"Display Name: {userEndPointTarget.OwnerDisplayName}");
            Console.WriteLine($"UM Enabled: {userEndPointTarget.UmEnabled}");
            Console.WriteLine($"Simulring enabled: {_routingCategory.SimultaneousRingEnabled}");
            if (_routingCategory.SimultaneousRingEnabled && _routingCategory.SimultaneousRing != null)
            {
                foreach (string time in _routingCategory.SimultaneousRing)
                {
                    Console.WriteLine($"Simul_Ringing to: {time}");
                }
            }
            if (_routingCategory.DelegateRingEnabled)
            {
                if (_routingCategory.SkipPrimaryEnabled)
                {
                    Console.Out.Write("Forwarding calls to Delegates: ");
                }
                else if (_routingCategory.UserWaitTimebeforeTeamOrDelegates.TotalSeconds > 0.0)
                {
                    Console.Out.Write($"Delay Ringing Delegates (delay:{ _routingCategory.UserWaitTimebeforeTeamOrDelegates.TotalSeconds} seconds): ");
                }
                else
                {
                    Console.Out.Write("Simultaneously Ringing Delegates: ");
                }
                foreach (string delegateCurrent in _routingCategory.Delegates)
                {
                    Console.Out.Write($"{delegateCurrent} ");
                }
                Console.Out.WriteLine();
            }
            else if (_routingCategory.TeamRingEnabled)
            {
                if (_routingCategory.UserWaitTimebeforeTeamOrDelegates.TotalSeconds > 0.0)
                {
                    Console.Out.Write($"Delay Ringing Team (delay:{_routingCategory.UserWaitTimebeforeTeamOrDelegates.TotalSeconds} seconds). Team: ");
                }
                else
                {
                    Console.Out.Write("Team ringing enabled. Team: ");
                }
                foreach (string currentTeam in _routingCategory.Team)
                {
                    Console.Out.Write($"{currentTeam} ");
                }
                Console.Out.WriteLine();
            }
            else if (_routingCategory.CallForwardToTargetsEnabled)
            {
                if (_routingCategory.CallForwardingEnabled)
                {
                    Console.Out.WriteLine($"Forward immediate to: {_routingCategory.CallForwardTo}");
                }
                else
                {
                    Console.Out.WriteLine($"User Ring time: {_routingCategory.UserOnlyWaitTime}");
                    Console.Out.WriteLine($"Call Forward No Answer to: {_routingCategory.CallForwardTo[0]}");
                }
            }
            else if (userEndPointTarget.UmEnabled)
            {
                Console.Out.WriteLine($"User Ring time: {_routingCategory.UserOnlyWaitTime}");
                Console.Out.WriteLine("Call Forward No Answer to: voicemail");
            }
            else
            {
                Console.Out.WriteLine("CallForwarding Enabled: false");
            }