计算 Lync 的可用用户数
Posted
技术标签:
【中文标题】计算 Lync 的可用用户数【英文标题】:Counting number of available users for Lync 【发布时间】:2015-07-01 13:02:09 【问题描述】:我有以下代码用于在我的网站上显示 Lync 状态,但我要做的是计算特定状态的用户数量,例如可用:3,离开:4,会议:2 等。 API 中是否有一个函数可以将状态作为数字返回给我,所以我可以使用 for 循环对它们进行计数并在 html 中显示?
<script>
var nameCtrl = new ActiveXObject('Name.NameCtrl.1');
function getStatus(sipUri)
if (nameCtrl.PresenceEnabled)
nameCtrl.OnStatusChange = onStatusChange;
nameCtrl.GetStatus(sipUri, "1");
function onStatusChange(name, status, id)
// This function is fired when the contacts presence status changes.
// In a real world solution, you would want to update an image to reflect the users presence
// alert(name + ", " + status + ", " + id);
var lyncpresencecolor = "gray";
switch (status)
case 0:
document.getElementById(name).style.borderLeftColor = "#5DD255";
break;
case 1:
document.getElementById(name).style.borderLeftColor = "#B6CFD8";
break;
case 2:
document.getElementById(name).style.borderLeftColor = "#FFD200";
break;
case 3:
document.getElementById(name).style.borderLeftColor = "#D00E0D";
break;
case 4:
document.getElementById(name).style.borderLeftColor = "#FFD200";
break;
case 5:
document.getElementById(name).style.borderLeftColor = "#D00E0D";
break;
case 6:
document.getElementById(name).style.borderLeftColor = "#D00E0D";
break;
case 7:
document.getElementById(name).style.borderLeftColor = "#D00E0D";
break;
case 8:
document.getElementById(name).style.borderLeft = "dashed";
document.getElementById(name).style.borderLeftWidth = "10px";
document.getElementById(name).style.borderLeftColor = "#E57A79";
break;
case 9:
document.getElementById(name).style.borderLeftColor = "#D00E0D";
break;
case 15:
document.getElementById(name).style.borderLeftColor = "#D00E0D";
break;
case 16:
document.getElementById(name).style.borderLeftColor = "#FFD200";
break;
default:
document.getElementById(name).style.borderLeftColor = "#B6CFD8";
break;
function ShowOOUI(sipUri)
nameCtrl.ShowOOUI(sipUri, 0, 15, 15);
function HideOOUI()
nameCtrl.HideOOUI();
</script>
<span id="sip@domain.com" onmouseover="ShowOOUI('sip@domain.com')" onmouseout="HideOOUI()" style="border-left-style:solid; border-left-width: 10px;"> User Name</span>
<script type="text/javascript">
getStatus('sip@domain.com');
</script>
谢谢
【问题讨论】:
【参考方案1】:不,没有,但是如果您在状态更改上设置或添加一些简单的类标签,例如。
document.getElementById(name).className = 'LyncStatus' + status;
然后你可以很容易地通过调用来计算它们:
function getNumberOfUserByStatus(status)
return document.getElementsByClassName('LyncStatus' + status ).length;
【讨论】:
以上是关于计算 Lync 的可用用户数的主要内容,如果未能解决你的问题,请参考以下文章
Lync server 2013高可用环境快速查看客户端的版本信息及连接状态