UCMA设置lync在线状态

摘要

UCMA全称Microsoft Unified Communications Managed API,主要用来构建工作在Microsoft Lync Server上的中间层应用程序。开发人员可以使用该平台构建应用程序,以提供对 Microsoft Lync Server增强状态信息、即时消息、电话、视频呼叫和音频/视频会议的访问和控制能力。

在线状态

通过UCMA方式,设置lync客户端的在线状态。设置在线状态为 UCMA Online的SDK方法如下:

  private static AutoResetEvent _PresencePublishComplete = new AutoResetEvent(false);
        private static String _noteXml = "<note xmlns=\"http://schemas.microsoft.com/2006/09/sip/note\" >"
    + "<body type=\"personal\" uri=\"\" >{0}</body></note>";
        private static string _noteValue = "Gone Fishing";
public void SetLyncOnline(UserEndpoint uep)
        {
            try
            {
                _localOwnerPresence = uep.LocalOwnerPresence;
                //tColl.Add(_localOwnerPresence.SubscriberEndpoint.OwnerDisplayName,_localOwnerPresence);
                // The CustomPresenceCategory class enables creation of a
                // category using XML. This allows precise crafting of a
                // category, but it is also possible to create a category
                // in other, more simple ways, shown below.
                CustomPresenceCategory _note = new CustomPresenceCategory("note", String.Format(_noteXml, _noteValue));

                // The PresenceState class has several static properties
                // and methods which will provide standard states such as
                // online, busy, and on-the-phone, for example.
                PresenceState _userState = PresenceState.UserAvailable;

                // It is possible to create and publish state with a
                // custom availablity string, shown below. "In a call" will
                // be shown in Microsoft Lync.
                LocalizedString localizedCallString = new LocalizedString(
                    "UCMA Online" /* The string to be displayed. */);

                // Create a PresenceActivity indicating the
                // "In a call" state.
                PresenceActivity inACall = new PresenceActivity(
                    localizedCallString);

                // Set the Availability of the "In a call" state to Busy.
                inACall.SetAvailabilityRange((int)PresenceAvailability.Online,
                    (int)PresenceAvailability.IdleOnline);

                // Microsoft Lync will also show the Busy presence icon.
                PresenceState _phoneState = new PresenceState(
                        (int)PresenceAvailability.Online,
                        inACall,
                        PhoneCallType.Voip,
                        "phone uri");

                // Machine or Endpoint states must always be published to
                // indicate the endpoint is actually online, otherwise it is
                // assumed the endpoint is offline, and no presence
                // published from that endpoint will be displayed.
                PresenceState _machineState = PresenceState.EndpointOnline;

                // It is also possible to create presence categories such
                // as ContactCard, Note, PresenceState, and Services with
                // their constructors.
                // Here we create a ContactCard and change the title.
                ContactCard _contactCard = new ContactCard(3);
                LocalizedString localizedTitleString = new LocalizedString(
                    "" /* The title string to be displayed. */);
                _contactCard.JobTitle = localizedTitleString.Value;

                // Publish a photo
                // If the supplied value for photo is null or empty, then set value of IsAllowedToShowPhoto to false
                _contactCard.IsAllowedToShowPhoto = false;
                _contactCard.PhotoUri = null;

                // Publish all presence categories with new values.
                _localOwnerPresence.BeginPublishPresence(
                        new PresenceCategory[]
                        {
                            _userState,
                            _phoneState,
                            _machineState,
                            _note,
                            _contactCard
                        },
                        PublishPresenceCompleted, /* async callback when publishing operation completes. */

                        true /* value TRUE indicates that presence to be published with new values. */);

                // _PresencePublishComplete.WaitOne();
            }
            catch (PublishSubscribeException pse)
            {
                // PublishSubscribeException is thrown when there were
                // exceptions during this presence operation such as badly
                // formed sip request, duplicate publications in the same
                // request etc.
                // TODO (Left to the reader): Include exception handling code
                // here.
                Console.WriteLine(pse.ToString());
            }
            catch (RealTimeException rte)
            {
                // RealTimeException is thrown when SIP Transport, SIP
                // Authentication, and credential-related errors are
                // encountered.
                // TODO (Left to the reader): Include exception handling code
                // here.
                Console.WriteLine(rte.ToString());
            }

        }
  private void PublishPresenceCompleted(IAsyncResult result)
        {
            try
            {
                // Since the same call back function is used to publish
                // presence categories and to delete presence categories,
                // retrieve the flag indicating which operation is desired.

                bool isPublishOperation;
                if (result.AsyncState == null)
                {
                    isPublishOperation = false;
                }
                else
                {
                    bool.TryParse(result.AsyncState.ToString(), out isPublishOperation);
                }

                if (isPublishOperation)
                {
                    // Complete the publishing of presence categories.
                    _localOwnerPresence.EndPublishPresence(result);
                    Console.WriteLine("Presence state has been published.");
                }
                else
                {
                    // Complete the deleting of presence categories.
                    _localOwnerPresence.EndDeletePresence(result);
                    Console.WriteLine("Presence state has been deleted.");
                }
            }
            catch (PublishSubscribeException pse)
            {
                // PublishSubscribeException is thrown when there were
                // exceptions during the publication of this category such as
                // badly formed sip request, duplicate publications in the same
                // request etc
                // TODO (Left to the reader): Include exception handling code
                // here
                Console.WriteLine(pse.ToString());
            }
            catch (RealTimeException rte)
            {
                // RealTimeException is thrown when SIP Transport, SIP
                // Authentication, and credential-related errors are
                // encountered.
                // TODO (Left to the reader): Include exception handling code
                // here.
                Console.WriteLine(rte.ToString());
            }
        }
时间: 2024-12-30 11:03:33

UCMA设置lync在线状态的相关文章

Lync 小技巧-39-批量-设置-AD-分机-手机-启用-Lync-设置-Lync-分机

环境: 1. 有AD用户,但是没分机号 2. 有Lync Server 2013环境,但是大量用户没有启用,没有设置分机号 3. 批量完成任务 目的: 1. 记录过程 2. 方便后续使用 过程: 1. 新建用户 LyncDemo081 Aa123456 2. 查询-Lync 3. 查看-脚本 EmpNO,PhoneNumber,MobileNumber LyncDemo081,8081,13811111111 #设置CSV文件的位置 $users=Get-Content 'D:\Set-ADUs

Office 365管理员指引 7 &mdash;&mdash;Lync 用户配置

使用 Lync Online,您可以通过即时消息.音频和视频会议以及 Lync 会议之类的功能与同事.合作伙伴和客户保持联系. 在为组织中的每个人设置 Lync Online 之前,请在您自己的计算机上安装 Lync,完成适合您的组织的规划和配置任务. 在 Lync 管理中心的"用户"页面上,您可以更改一个或多个用户的设置.选择其姓名,然后单击"编辑" . 1) 配置常规设置 1. 单击"用户",然后执行下列操作之一: l 要选择单个用户,请单击

Lync Server 2013企业版部署测试七:Lync Server 2013管理、创建用户测试

一.登录Lync Server 2013控制台,查看拓扑状态 登录frt01.juc.com,安装Silverlight_x64.exe,如果未安装会登录Lync Server控制面板提示如下: 安装Silverlight_x64.exe,重新打开Lync Server控制面板,输入用户名和密码,登录Lync Server 2013控制台 查看拓扑,frt01.juc.com.frt02.juc.com运行状态正常 二.创建帐号,启用用户 登录dc001.juc.com,创建测试用户test1.

部署LyncServer2013之五 配置本地存储和安装Lync Server组件

部署LyncServer2013之五  配置本地存储和安装Lync Server组件 安装lync server系统主要包含以下的内容:安装本地配置存储.安装lync server 组件.请求并分配lync证书.启动服务.登陆Lync Server控制面板. 我们将安装本地配置存储和安装lync server 组件放到一起,请求并分配lync证书单独介绍,后两个放到一起来介绍. 1. 首先我们来安装本地配置存储, 运行lync serve的安装程序,选择[安装或更新lync server系统],

Lync 2013常用Powershell总结

1.查看Lync拓扑复制状态 Get-CsManagementStoreReplicationStatus 2.查看Lync证书状态 Get-CsCertificate 3.查看Lync Office Web App场状态 Get-OfficeWebAppsFarm (Powershell) 4.查看Lync用户数量 Get-CsUser |measure 5.查看Lync语音视频带宽 Get-CsConferencingPolicy 6.设置Lync视频会议的分辨率 Set-CsConfere

IBM V3500存储更换控制器一例

今天一早接到客户电话,说单位内部分用户不能访问网络,我登录检查之后发现存储的一个控制器损坏导致,主要原因概述如下. 当前客户核心业务运行在vSphere虚拟化平台,该单位有3台HP服务器+1台IBM 3524存储,服务器与存储之间采用SAS接口连接,其中2台HP服务器使用SAS线连接到A控制器,另1台HP服务器使用SAS线连接到B控制器,服务器与存储之间无冗余连接.3台HP服务器安装ESXi 6.0配置成HA,所有虚拟机都保存在IBM 3524存储中,当A控制器损坏之后,前2台HP服务器丢失到存

【Android先进】我们为什么要创建Activity基类Activity什么是一般的基类方法

今天,它可以被视为只是基本完成了其首个商业项目,在发展过程中,风格,然而随着工作经验的积累.最终開始慢慢的了解到抽象思想在面向对象编程中的重要性,这一篇简单的介绍一下我的一点收获. 首先,在如今的项目中使用的主要是afinal框架,并且这个框架确实比較不错,省去了不少工作量.在编写Activity的过程中,基本都是直接继承自FinalActivity类,这样能够使用这个类给我们封装好的不少的方法,可是随着项目慢慢推进,这样的直接继承框架类的一些缺点也開始慢慢的显现出来.最基本的就是扩展性受到了一

Oracle触发器如何调用Java实现Openfire消息发送

写在前面,要想实现整个过程的成功执行请先准备以下文件: 1. 登陆Openfire服务端以及Spark客户端相关程序(openfire_4_0_1.exe.spark_2_7_6.exe) 2. 连接Openfire和Oracle相关的jar包(presence.jar.smack.jar.smackx-debug.jar.smackx.jar.ojdbc.jar)  Step1:安装Openfire服务端并配置数据库连接,配置参考<Openfire服务器安装与配置教程> Step2:在Ecl

用smack+openfire做即时通讯

首发:个人博客 必须说明:smack最新的4.1.1,相对之前版本变化很大,而且资料缺乏,官方文档也不好,所以还是用老版本3.2.2吧.这篇博文中的代码是4.1.1版的,但不推荐用它.用openfire做服务器,用spark做帮助调试的客户端,用smack(官方文档在这里,感觉写得非常不好)做java的库,来完成即时通讯功能. 1.安装openfire在官网下载安装即可. 2.安装spark在官网下载安装即可. 3.maven引入smack <dependency>