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

标签 c# exchangewebservices exchange-server-2010 ews-managed-api

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

相关文章:

c# - 在类型“ResourceDictionary”中找不到可连接属性“MergedDictionaries”

exchangewebservices - 使用 EWS 一次从 Exchange 2010 服务器获取所有通知

exchange-server - 我如何检查交换连接是否有效? (来自 ews)

c# - EWS - 超时后续订?

email - VBA 中的 throttle

c# - 如何在 C# (IGMPv3) 中加入源特定多播组

c# - 如何从 EF Core 中的模型生成类图?

c# - 是不是不能使用父类的事件呢?

Java EWS findappointments 日期表现得很奇怪,要么返回很多,要么什么也没有

exchangewebservices - Exchange 2010 EWS 删除邮件