vsto - VSTO Outlook 如何在定期会议中的 AppointmentItems 链中获取上一个 AppointmentItem
问题描述
我目前正在为 AppointmentItem 开发 Outlook 插件。如果 AppointmentItem 是定期会议“链”的成员,我想检索/查找上一次会议的 AppointmentItem。我怎样才能做到这一点?
我想出了以下部分解决方案:
Outlook.AppointmentItem item = (Outlook.AppointmentItem)inspector.CurrentItem;
if (item.IsRecurring) {
Outlook.RecurrencePattern pattern = item.GetRecurrencePattern();
Outlook.OlRecurrenceType occurenceType = pattern.RecurrenceType;
int dayFactor = 0;
switch (occurenceType) {
case Outlook.OlRecurrenceType.olRecursDaily:
dayFactor = 1;
break;
case Outlook.OlRecurrenceType.olRecursWeekly:
default:
dayFactor = 7;
break;
// TODO handly all other cases of RecurrenceType
}
Outlook.AppointmentItem lastItem = pattern.GetOccurrence(item.StartInStartTimeZone.AddDays(-1*pattern.Interval*dayFactor));
但这仅处理极少数“简单”的情况。尤其是当涉及到计算时,例如每个月的第一个星期二,这对我来说太棘手了。有输入吗?此代码示例也可能有用:http ://www.outlookcode.com/codedetail.aspx?id=1414
解决方案
不容易。您需要在代码中明确扩展该系列,同时考虑到重复模式和异常。
如果使用Redemption是一个选项,它的版本RDORecurrencePattern。GetOccurrence
方法允许传递一个整数索引(除了日期 a-la OOM)作为参数,因此您可以构建一个出现的数组。
推荐阅读
- swift - 使用 DisclosureGroup 时的 SwiftUI List 与 ForEach
- android - 在通过 Android WebRTC 流式传输视频时拍摄高分辨率(本地)照片?
- ruby - 如何检查 nil 并比较 != nil on Hashes?
- javascript - Next.js 得到混淆的 API 响应
- r - 自动扩展网页的折叠部分以在 R 中进行网页抓取
- php - 运行 composer install 时内存不足
- java - 将十进制int转换为二进制
- python - 如何在matplotlib中修改数字堆叠在一起的x轴
- python - 在 Pandas 的时间戳中计算特定帧内出现的次数
- javascript - 如何在 html 的另一个组件中使用导出的函数?角度?