gpt4 book ai didi

c# - 使用 EWS 托管 API 1.2 获取约会的重复模式

转载 作者:行者123 更新时间:2023-11-30 21:06:38 25 4
gpt4 key购买 nike

我正在寻找使用 EWS Managed API 1.2 获取与约会关联的重复模式的正确方法。我的代码看起来像这样:

FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Calendar, view);

foreach (Appointment appointment in findResults)
{
appointment.Load();

if (appointment.IsRecurring)
{
// What is the recurrence pattern???
}
}

我可以执行一个约会.Recurrence.ToString(),然后像 Microsoft.Exchange.WebServices.Data.Recurrence+WeeklyPattern 一样返回。显然我可以解析它并确定类型,但这看起来不是很干净。有没有更好的办法?

这里还有一个与此类似的帖子 - EWS: Accessing an appointments recurrence pattern但解决方案似乎并不完整。

最佳答案

这是模式的完整列表。由于没有属性,你可以使用什么模式,你将不得不将重复转换到模式。在我的项目中,我通过这种方式解决了这个问题:

Appointment app = Appointment.Bind(service,id);
Recurrence.DailyPattern dp = app.Recurrence as Recurrence.DailyPattern;
Recurrence.DailyRegenerationPattern drp = app.Recurrence as Recurrence.DailyRegenerationPattern;
Recurrence.MonthlyPattern mp = app.Recurrence as Recurrence.MonthlyPattern;
Recurrence.MonthlyRegenerationPattern mrp = app.Recurrence as Recurrence.MonthlyRegenerationPattern;
Recurrence.RelativeMonthlyPattern rmp = app.Recurrence as Recurrence.RelativeMonthlyPattern;
Recurrence.RelativeYearlyPattern ryp = app.Recurrence as Recurrence.RelativeYearlyPattern;
Recurrence.WeeklyPattern wp = app.Recurrence as Recurrence.WeeklyPattern;
Recurrence.WeeklyRegenerationPattern wrp = app.Recurrence as Recurrence.WeeklyRegenerationPattern;
Recurrence.YearlyPattern yp = app.Recurrence as Recurrence.YearlyPattern;
Recurrence.YearlyRegenerationPattern yrp = app.Recurrence as Recurrence.YearlyRegenerationPattern;

if (dp != null)
{
//Do something
}
else if (drp != null)
{
//Do something
}
else if (mp != null)
{
//Do something
}
else if (mrp != null)
{
//Do something
}
else if (rmp != null)
{
//Do something
}
else if (ryp != null)
{
//Do something
}
else if (wp != null)
{
//Do something
}
else if (wrp != null)
{
//Do something
}
else if (yp != null)
{
//Do something
}
else if (yrp != null)
{
//Do something
}

希望对你有帮助...

关于c# - 使用 EWS 托管 API 1.2 获取约会的重复模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11038646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com