Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# UCMA 3.0如何建立收件人列表,然后向这些收件人广播IM呼叫_C#_Lync_Lync 2010_Ucma - Fatal编程技术网

C# UCMA 3.0如何建立收件人列表,然后向这些收件人广播IM呼叫

C# UCMA 3.0如何建立收件人列表,然后向这些收件人广播IM呼叫,c#,lync,lync-2010,ucma,C#,Lync,Lync 2010,Ucma,我正在使用UCMA3.0开发一个应用程序,它将作为服务运行,并以即时消息调用的形式定期发送“广播”。我一直在使用这本书“”,并且已经准备好了一切,并且能够建立一个应用程序端点 不过,我在两个方面都有困难 1)如何获取Lync所有用户的列表?UCMA所能做的一切都集中在一个用户身上。例如,它允许我检索给定用户“联系人列表”上的所有联系人/组,但不提供任何方法来查询可添加到其中一个联系人列表中的可用联系人列表。在MSDN论坛上,我发现了这一点,这让我觉得我最好的选择就是直接查询广告 2)发送广播式即

我正在使用UCMA3.0开发一个应用程序,它将作为服务运行,并以即时消息调用的形式定期发送“广播”。我一直在使用这本书“”,并且已经准备好了一切,并且能够建立一个应用程序端点

不过,我在两个方面都有困难

1)如何获取Lync所有用户的列表?UCMA所能做的一切都集中在一个用户身上。例如,它允许我检索给定用户“联系人列表”上的所有联系人/组,但不提供任何方法来查询可添加到其中一个联系人列表中的可用联系人列表。在MSDN论坛上,我发现了这一点,这让我觉得我最好的选择就是直接查询广告

2)发送广播式即时通讯的最佳方式是什么?我的工作前提是尝试类似于我在本文中发现的东西(特别是
public void SendIM()
方法)

因此,从广告中获取收件人列表,(在每个收件人上循环以检查当前状态?),然后使用自动化为集合中的每个收件人进行IM呼叫

这有意义吗?我是否需要检查收件人是否在场,还是只是乐观地让IM电话不理会他们当前的在场状态?有人能告诉我一些演示发送IM广播的工作代码吗?您可能会认为这可能是最常见的用例之一,但是SDK示例没有涵盖它。提前谢谢



更新: 正如李斯特所说,没有“广播”方法。我不得不在收件人上循环,打电话给每个收件人发送即时消息。我发现我还需要检查收件人的状态,因为它会尝试向脱机、忙碌等用户发送消息,从而导致异常。最好只发送到某些状态。由于应用程序终结点没有用户/组列表,您需要使用AD和目录服务确定收件人,或者只需维护自己的收件人列表。最后,我编写了一个工作流,用户可以将IM发送到automaton应用程序端点,以选择加入或退出警报广播。该工作流维护一个简单的订阅服务器数据库表

/// <summary>
/// Sending of the actual IM to broadcast subscribers.  Here we check that the presence of the target recipient
/// is in fact suitable for us to barge in with an alert.
/// </summary>
private void sendIMBroadcast(string sipTarget, byte[] htmlBytes)
{

    try {
        _appEndpoint.PresenceServices.BeginPresenceQuery(
            new List<string>() {sipTarget},
            new string[] {"state"},
            null,
            result =>
            {
                try 
                {
                    // Retrieve the results of the query.
                    IEnumerable<RemotePresentityNotification> notifications = _appEndpoint.PresenceServices.EndPresenceQuery(result);

                    // Grab the first notification in the results.
                    RemotePresentityNotification notification = notifications.FirstOrDefault();

                    if (notification == null)
                    {
                        logger.Warn("Invalid recipient for P1 broadcast: {0}", sipTarget);
                        return;
                    }

                    //ensure presense is one we want to send alert to
                    //if (notification.AggregatedPresenceState.AvailabilityValue )

                    long v = notification.AggregatedPresenceState.AvailabilityValue;
                    bool skip = false;
                    if (v >= 3000 && v <= 4499)
                    {
                        //online
                    }
                    else if (v >= 4500 && v <= 5999)
                    {
                        //idle online
                    }
                    else if (v >= 6000 && v <= 7499)
                    {
                        //busy
                        skip = true;
                    }
                    else if (v >= 7500 && v <= 8999)
                    {
                        //idle busy
                        skip = true;
                    }
                    else if (v >= 9000 && v <= 11999)
                    {
                        //dnd
                        skip = true;
                    }
                    else if (v >= 12000 && v <= 14999)
                    {
                        //brb
                        skip = true;
                    }
                    else if (v >= 15000 && v <= 17999)
                    {
                        //away
                        skip = true;
                    }
                    else if (v >= 18000)
                    {
                        //offline
                        skip = true;
                    }

                    if (skip == true)
                    {
                        logger.Debug("Skipping broadcast for user '{0}' due to presense status {1}.", sipTarget, v.ToString());
                        return;
                    }

                    logger.Debug("Sending broadcast for user '{0}' with presense status {1}.", sipTarget, v.ToString());

                    // Send an IM, create a new Conversation and make call
                    Conversation conversation = new Conversation(_appEndpoint);                     
                    InstantMessagingCall _imCall = new InstantMessagingCall(conversation);

                    try
                    {
                        ToastMessage toast = new ToastMessage("Unassigned P1 Tickets!");

                        // Establish the IM call.                 
                        _imCall.BeginEstablish(sipTarget,
                            toast,
                            new CallEstablishOptions(),
                            result2 =>
                            {
                                try
                                {
                                    // Finish the asynchronous operation.
                                    _imCall.EndEstablish(result2);

                                    _imCall.Flow.BeginSendInstantMessage(
                                        new System.Net.Mime.ContentType("text/html"),
                                        htmlBytes,
                                        ar =>
                                        {
                                            try
                                            {
                                                _imCall.Flow.EndSendInstantMessage(ar);
                                            }
                                            catch (RealTimeException rtex)
                                            {
                                                logger.Error("Failed sending P1 Broadcast Instant Message call.", rtex);
                                            }
                                        },
                                        null
                                    );
                                }
                                catch (RealTimeException rtex)
                                {
                                    // Catch and log exceptions.
                                    logger.Error("Failed establishing IM call", rtex);
                                }
                            },
                            null
                        );
                    }
                    catch (InvalidOperationException ioex)
                    {
                        logger.Error("Failed establishing IM call", ioex);
                    }

                }
                catch (RealTimeException ex)
                {
                    logger.Error("Presence query failed.", ex);
                }
            },
        null);
    }
    catch (InvalidOperationException ex) 
    {
        logger.Error("Failed accepting call and querying presence.", ex);
    }                 
}
//
///向广播用户发送实际IM。这里我们检查目标接收者的存在
///事实上,它适合我们带着警报闯进来。
/// 
私有void sendIMBroadcast(字符串sipTarget,字节[]htmlBytes)
{
试一试{
_appEndpoint.PresenceServices.BeginPresenceQuery(
新列表(){sipTarget},
新字符串[]{“状态”},
无效的
结果=>
{
尝试
{
//检索查询结果。
IEnumerable notifications=\u appEndpoint.PresenceServices.EndPresenceQuery(结果);
//抓取结果中的第一个通知。
RemotePresentityNotification=notifications.FirstOrDefault();
如果(通知==null)
{
logger.Warn(“P1广播的无效收件人:{0}”,sipTarget);
返回;
}
//确保presense是我们要发送警报的对象
//if(notification.AggregatedPresenceState.AvailabilityValue)
long v=notification.AggregatedPresenceState.AvailabilityValue;
bool skip=false;
如果(v>=3000&&v=4500&&v=6000&&v=7500&&v=9000&&v=12000&&v=15000&&v=18000)
{
//离线
跳过=真;
}
如果(跳过==真)
{
Debug(“由于存在状态{1},正在跳过用户{0}的广播。”,sipTarget,v.ToString();
返回;
}
Debug(“为状态为{1}的用户{0}发送广播”,sipTarget,v.ToString());
//发送即时消息、创建新对话并拨打电话
对话=新对话(_appEndpoint);
InstantMessageCall _imCall=新建InstantMessageCall(对话);
尝试
{
ToastMessage toast=新的ToastMessage(“未分配的P1票”);
//建立即时通讯呼叫
_imCall.BeginEstablish(sipTarget,
干杯
新的CallEstablishOptions(),
结果2=>
{
尝试
{
//完成异步操作。
_imCall.EndEstablish(结果2);
_imCall.Flow.BeginSendInstantMessage(
新System.Net.Mime.ContentType(“text/html”),
htmlBytes,
ar=>
{
尝试
{
_imCall.Flow.EndSendInstantMessage(ar);
}
捕获(实时异常rtex)
{
logger.错误(“发送P1广播即时消息呼叫失败。”,rtex);