EWS:访问约会重复模式 [英] EWS: Accessing an appointments recurrence pattern

查看:114
本文介绍了EWS:访问约会重复模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在下面的代码中获取与约会相关联的重复模式.当我调试代码并在本地窗口"中展开microsoftAppointment.Recurrence属性时,我可以看到一个名为[Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern]的嵌套类,其中包含我需要的信息,但我无法弄清楚如何在我的代码中访问此信息.显然它在内存中,我只是不明白为什么在运行时无法在代码中读取它.我已经尝试过FindAppointments,但是只会将Recurrence返回为null.

I am trying to get the recurrence pattern associated with the appointment in the below code. When I debug the code and expand the microsoftAppointment.Recurrence property in the Locals Window I can see a nested class called [Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern] that has the information in it I need but I can not figure out how to access this information in my code. It is obviously in memory I just don't understand why I can't read it in code during run time. I have tried FindAppointments but that only returns Recurrence as null.

FindItemsResults<Item> findResults = exchangeService.FindItems(WellKnownFolderName.Calendar, new ItemView(folderCount));

exchangeService.LoadPropertiesForItems(findResults.Items, new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Location, AppointmentSchema.Body, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.IsAllDayEvent, AppointmentSchema.Body, AppointmentSchema.IsRecurring, AppointmentSchema.Recurrence));

foreach (var v in findResults.Items)
{
    Microsoft.Exchange.WebServices.Data.Appointment microsoftAppointment = v as Microsoft.Exchange.WebServices.Data.Appointment;

    if (microsoftAppointment.IsRecurring)
    {
    ...
    }
}

推荐答案

以下强制转换对我有用.您可以跳过间隔模式"步骤,但此后我进行了切换以查找类型(每周,每天等),这样我就可以正确地投射间隔模式.

The following casts ended up working for me. You can skip the Interval Pattern step but I did a switch after that to find the type (weekly, daily, etc.) so I could correctly cast the interval pattern.

Microsoft.Exchange.WebServices.Data.Recurrence.IntervalPattern pattern = (Microsoft.Exchange.WebServices.Data.Recurrence.IntervalPattern)microsoftAppointment.Recurrence;
weeklyPattern = (Microsoft.Exchange.WebServices.Data.Recurrence.WeeklyPattern) pattern;

这篇关于EWS:访问约会重复模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆