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

时间:2014-11-05 08:35:00

标签: c# ucma lync-2013

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

同样this Answerthis MSDN Article以及this Question似乎表明它确实有效,但我需要在特定时刻设置此设置(如果用户在线或不在线)而不是尽快当他登录到他的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();

1 个答案:

答案 0 :(得分:1)

使用 ApplicationEndpoint 无法做到这一点。您必须拥有 UserEndpoint 。 但是,您可以创建只需要 CollaborationPlateform SipUser UserEndpoint ,而不是任何密码。

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

这是我的技巧:

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");
            }