简体   繁体   English

使用Lync SDK为所有Skype for Business参与者结束会议的正确方法

[英]Proper way to end meeting for all participants in Skype for Business using Lync SDK

I'm trying to implement a function for ending the current conversation for all participants using Microsoft Lync SDK for Skype for business. 我正在尝试使用Microsoft Lync SDK for Business来为所有参与者实现结束当前对话的功能。 The job it's supposed to be done like this: 应该按照以下方式完成工作:

conversation.End();

But it only closes the window of the participant that started the meeting. 但是,它只会关闭开始会议的参与者的窗口。 Is there another way to do it? 还有另一种方法吗?

The "End" method just leave the conference call as you say. “结束”方法只是让电话会议如您所说。

There is no documented API to "End Meeting". 没有记录到“结束会议”的API。

If you really want to do this programmatically then you will need to use something like Windows Automation to select the "More options" button then then select the "End Meeting" button. 如果您真的想以编程方式执行此操作,则需要使用Windows Automation之类的方法来选择“更多选项”按钮,然后选择“结束会议”按钮。

Here is a example method for using windows automation to click the End Meeting button. 这是使用Windows自动化单击“结束会议”按钮的示例方法。

bool EndMeeting(ConversationWindow window)
{
    var conversationWindowElement = AutomationElement.FromHandle(window.InnerObject.Handle);
    if (conversationWindowElement == null)
    {
        return false;
    }

    AutomationElement moreOptionsMenuItem;
    if (GetAutomationElement(conversationWindowElement, out moreOptionsMenuItem, "More options", ControlType.MenuItem))
    {
        (moreOptionsMenuItem.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern).Expand();
    }
    else if (GetAutomationElement(conversationWindowElement, out moreOptionsMenuItem, "More options", ControlType.Button))
    {
        // in the Office 365 version of lync client, the more options menu item is actually a button
        (moreOptionsMenuItem.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern).Invoke();
    }
    else
    {
        // didn't find it.
        return false;
    }

    AutomationElement menuOptionAction;
    if (!GetAutomationElement(moreOptionsMenuItem, out menuOptionAction, "End Meeting", ControlType.MenuItem))
    {
        return false;
    }

    (menuOptionAction.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern).Invoke();
    return true;
}

private static bool GetAutomationElement(AutomationElement rootElement, out AutomationElement resultElement, string name, ControlType expectedControlType)
{
    Condition propCondition = new PropertyCondition(AutomationElement.NameProperty, name, PropertyConditionFlags.IgnoreCase);
    resultElement = rootElement.FindFirst(TreeScope.Subtree, propCondition);
    if (resultElement == null)
    {
        return false;
    }

    var controlTypeId = resultElement.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty) as ControlType;
    if (!Equals(controlTypeId, expectedControlType))
    {
        return false;
    }

    return true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM