我正在寻找使用 EWS 托管 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/