【问题标题】:Find All Available Meeting Rooms using Microsoft.Office.Interop.Outlook使用 Microsoft.Office.Interop.Outlook 查找所有可用的会议室
【发布时间】:2018-07-15 14:42:19
【问题描述】:

我正在开发一个应用程序,我想从 Outlook 通讯簿的“所有房间”中检索可用房间。我能够从“所有房间”地址条目列表中检索所有房间条目。然后可以通过调用 AddressEntry.GetFreeBusy() 搜索单个房间的可用性。 但我面临的问题是代码的时间性能。如果房间数量很多(比如 500 个),那么搜索房间可用性所需的时间(最坏的情况是可用房间位于列表的最后一个附近)。

Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application()
var allRooms = app.Session.AddressLists["All Rooms"].Cast<Microsoft.Office.Interop.Outlook.AddressEntry>().ToLis();
DateTime today = DateTime.Today;
foreach(var room in allRooms)
{
    //the below function will return the room status in a string of 1&0 for an interval of 1 min
    string status = room.GetFreeBusy(today, 1, true); //sequentially calling this method is costly. What improvement can I do here?
    //process the status and make some if free for certain time period add to list of available list
}

【问题讨论】:

    标签: c# outlook office-interop outlook-addin


    【解决方案1】:

    GetFreeBusy 方法接受三个参数,MinPerChar 参数的默认值为 30 分钟。但是您的代码只检查约会的第一分钟。您需要浏览整个会议期间(至少 30 分钟)。看看similar 论坛主题。

    【讨论】:

      【解决方案2】:

      如果您是 .Net 开发人员,请为此目的使用 Microsoft Graph API。我用过

      POST /me/calendar/getSchedule POST /users/{id|userPrincipalName}/calendar/getSchedule

      从实现这一点。您可以使用用户 ID 登录并使用 ME 选项,也可以使用应用程序模式登录登录并使用 {id|userPrincipalName} 获取房间的日历详细信息。

      此链接提供了有关如何登录的基础知识,并提供了很好的 Graph 示例。

      https://developer.microsoft.com/en-us/graph/graph-explorer

      参考: https://docs.microsoft.com/en-us/graph/api/calendar-getschedule?view=graph-rest-1.0&tabs=http

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多