是否可以通过Lync SDK(2013或其他版本)设置呼叫转移? [英] Is it possible to set call forwarding via the Lync SDK (2013 or other)?

查看:97
本文介绍了是否可以通过Lync SDK(2013或其他版本)设置呼叫转移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一家大型机构的IS部门工作.处理我们电话的Lync服务器由另一个部门处理,任何需要它们配合的解决方案都不可行.这排除了需要从Lync服务器,SEFAUtil等运行的任何需要额外特权的解决方案.

我的个人Lync 2013客户端具有一些可恶的GUI菜单,可以在其中将台式电话转发到另一个号码.因此,我知道从理论上讲是有可能的.

我有一些Powershell代码(已安装大量SDK)将使用我自己的个人凭据登录.我从中抓取的博客允许脚本发送一些任意的IM消息(对我来说不是很有用).看起来像这样:

if (-not (Get-Module -Name Microsoft.Lync.Model)) {     
    try {       
        Import-Module -Name (Join-Path -Path ${env:ProgramFiles} -ChildPath "Microsoft Office\Office15\LyncSDK\Assemblies\Desktop\Microsoft.Lync.Model.dll")
-ErrorAction Stop   
    }
    catch {
        Write-Warning "Microsoft.Lync.Model not available, download and install the Lync 2013 SDK http://www.microsoft.com/en-us/download/details.aspx?id=36824"        break   
    }
}

$client = [Microsoft.Lync.Model.LyncClient]::GetClient()

if ($client.State -ne [Microsoft.Lync.Model.ClientState]::SignedIn) {
    $client.EndSignIn(
        $client.BeginSignIn("x@x.com", "domain\johno", "youllNeverGuess", $null, $null)) 
}

if ($Client.State -eq "SignedIn") {
    Write-Host "DEBUG: We managed to sign in!" }
}

这似乎行得通,因为如果我输入了错误的密码,它就会发出响声.

是否可以在SDK中将呼叫转移设置为特定号码?微软糟糕的文档演示了如何转发脚本通过事件处理程序捕获的传入呼叫,这意味着它必须在轮询循环中运行...而我不能仅遍历要转发的帐户列表.从GUI客户端,如果将电话​​设置为转接到某个号码,即使关闭机器电源,它也将停留在该电话上,因此它将向半永久性服务器发送一些消息. Lync SDK可以完成相同的工作吗?

尽管不建议使用Lync 2010,但我对基于此的解决方案感到满意. Powershell是首选,但是如果您使用VB或C#语言编写代码,同样也可以.我不需要整个事情都放在一个银色的盘子上,只需一些提示即可使用.

解决方案

您需要将路由信息发布到Lync服务器.其中包括您的同时响铃和转发设置.

如果可以创建.Net解决方案,请尝试以下操作:

当您需要针对Lync服务器进行编程并且无法获得任何提升的特权时,请尝试使用UCMA并创建一个UserEndpoint.由于您知道Lync服务器地址并具有登录详细信息,因此您无需其他部门的合作即可创建和验证UserEndpoint.

示例(不是我的示例):

在您的UserEndpoint上,订阅LocalOwnerPresence.PresenceNotificationReceived MSDN .

使用端点登录后,此事件将触发并提供您当前的设置.在事件自变量LocalPresentityNotificationEventArgs中,获取AllCategories集合,然后查找名称为"routing"PresenceCategoryWithMetaData.使用此数据创建Routing容器的新实例. 路由容器是Microsoft.Rtc.Collaboration.dll中的类Microsoft.Rtc.Internal.Collaboration.Routing.

private void OnLocalPresenceNotificationReceived(
    object sender, 
    LocalPresentityNotificationEventArgs e) 
{
    var container = (from c in e.AllCategories
                     where string.Equals(c.Name, "routing", StringComparison.OrdinalIgnoreCase)
                     orderby c.PublishTime descending
                     select c).FirstOrDefault();

    if (container != null)
    {
        var routing = new Microsoft.Rtc.Internal.Collaboration.Routing(container);

        // You can access the routing data here...
    }
}

如果没有收到任何路由容器,则可以创建一个新实例.请注意,尽管发布新实例将覆盖您当前的所有路由设置,而不是允许您更新当前设置.

Routing类中,您可以写入以下属性:

routing.CallForwardToTargetsEnabled = true;
routing.CallForwardTo.Clear();
routing.CallForwardTo.Add("sip or tel number");
routing.UserOnlyWaitTime = TimeSpan.FromSeconds(...);

最后,发布新的路由设置:

endpoint.LocalOwnerPresence.PublishPresenceAsync(new PresenceCategory[] { 
    routing 
});


还可以通过使用Lync SDK中的GetClient()方法获取当前的Lync实例来发布状态.但是,我不确定这是否可以用于发布路由设置.您可以尝试一下,在与Lync一起玩时,我发现了许多未公开说明的选项.查看以下两个资源:

How to: Publish enhanced presence information Self.BeginPublishContactInformation

I work for an IS department in a large institution. The Lync servers that handle our telephones are handled by another department, and any solution that requires cooperation from them is not viable. This rules out any solutions that require extra privileges, running from the Lync servers, SEFAUtil, etc.

My personal Lync 2013 client has some abominable GUI menu where I can forward my desk phone to another number. I know therefor that it is possible, in theory.

I have powershell code that (with a ton of SDKs installed) will login with my own personal credentials. The blog I grabbed it from allowed the script to send some arbitrary IM message (not very useful to me). It looks like this:

if (-not (Get-Module -Name Microsoft.Lync.Model)) {     
    try {       
        Import-Module -Name (Join-Path -Path ${env:ProgramFiles} -ChildPath "Microsoft Office\Office15\LyncSDK\Assemblies\Desktop\Microsoft.Lync.Model.dll")
-ErrorAction Stop   
    }
    catch {
        Write-Warning "Microsoft.Lync.Model not available, download and install the Lync 2013 SDK http://www.microsoft.com/en-us/download/details.aspx?id=36824"        break   
    }
}

$client = [Microsoft.Lync.Model.LyncClient]::GetClient()

if ($client.State -ne [Microsoft.Lync.Model.ClientState]::SignedIn) {
    $client.EndSignIn(
        $client.BeginSignIn("x@x.com", "domain\johno", "youllNeverGuess", $null, $null)) 
}

if ($Client.State -eq "SignedIn") {
    Write-Host "DEBUG: We managed to sign in!" }
}

This seems to work, in that if I supply it the wrong password, it barfs.

From within the SDK, is it possible to set callfowarding to a particular number? Microsoft's horrible documentation demonstrates how to forward an incoming call that the script caught through an event handler, meaning that it'd have to run in a polling loop... and that I couldn't just iterate through a list of accounts to forward. From the GUI client, if you set your phone to forward to a number, it sticks even if you power down the machine, so it's sending something to the server that is semi-permanent. Can Lync SDK accomplish the same?

Though Lync 2010 is deprecated, I would be happy with a solution based upon that. Powershell is preferred, but if you have code in VB or C#, again that would be ok too. I don't need the whole thing served up on a silver platter, just a few clues to work with.

解决方案

You need to publish your routing information to the Lync server. This contains your simultaneous-ring and forwarding settings, amongst others.

If you're OK with creating a .Net solution, try the following:

When you need to program against the Lync server and cannot get any elevated privileges, try using UCMA and create a UserEndpoint. Since you know your Lync server address and have login details, you can create and authenticate a UserEndpoint without cooperation from the other department.

Example (not mine): Creating UCMA Applications with a UserApplication instance.

Once you get your endpoint set up, you're basically home free. With the ability to publish presence, you can publish routing settings. For Lync, "presence" is a container which contains everything like availability, routing, contact details, custom locations, etc.

On your UserEndpoint, subscribe to LocalOwnerPresence.PresenceNotificationReceived MSDN.

After you sign in with your endpoint, this event will fire and give you your current settings. In the event argument LocalPresentityNotificationEventArgs, grab the AllCategories collection, and look for the PresenceCategoryWithMetaData with the name "routing". Create a new instance of the Routing container with this data. The routing container is the class Microsoft.Rtc.Internal.Collaboration.Routing in Microsoft.Rtc.Collaboration.dll.

private void OnLocalPresenceNotificationReceived(
    object sender, 
    LocalPresentityNotificationEventArgs e) 
{
    var container = (from c in e.AllCategories
                     where string.Equals(c.Name, "routing", StringComparison.OrdinalIgnoreCase)
                     orderby c.PublishTime descending
                     select c).FirstOrDefault();

    if (container != null)
    {
        var routing = new Microsoft.Rtc.Internal.Collaboration.Routing(container);

        // You can access the routing data here...
    }
}

If you do not receive any routing container, you can create a new instance. Take care though that publishing a new instance will override all your current routing settings instead of allowing you to update the current settings.

In the Routing class you can write to the following property:

routing.CallForwardToTargetsEnabled = true;
routing.CallForwardTo.Clear();
routing.CallForwardTo.Add("sip or tel number");
routing.UserOnlyWaitTime = TimeSpan.FromSeconds(...);

And finally, publish the new routing settings:

endpoint.LocalOwnerPresence.PublishPresenceAsync(new PresenceCategory[] { 
    routing 
});


It is also possible to publish presence by getting your current Lync instance with the GetClient() method in the Lync SDK. I'm not sure however if this can be used to publish routing settings. You could try though, I found many undocumented options while playing around with Lync. Look at the following two resources:

How to: Publish enhanced presence information and Self.BeginPublishContactInformation

这篇关于是否可以通过Lync SDK(2013或其他版本)设置呼叫转移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆