定期的なパターンと EWS
Exchange の定期的なパターンと定期的なアイテムについて説明します。
定期的なシリーズは、定義されたパターンに従って繰り返される予定または会議です。 定期的な系列は、特定の回数の出現回数を持つか、無期限に繰り返すことができます。 さらに、定期的な系列には、残りの出現のパターンに従わない例外があり、パターンから削除された出現箇所を含めることができます。 EWS マネージ API と EWS を使用して、定期的な系列とそれに関連付けられている予定表アイテムを操作できます。
定期的な予定表アイテム
すべての予定表アイテムは、次に示す 4 つのカテゴリのいずれか 1 つに分類されます。
非定期的な予定表アイテム
定期的マスター
定期的なアイテム内のアイテム
定期的なアイテム内の変更されたアイテム (例外)
この記事では、定期的なアイテムの一部である予定表アイテムの 3 つの種類について説明します。
定期的なシリーズが Exchange サーバーでどのように実装されているかを理解すると便利です。 サーバーは、定期的な系列の出現ごとに個別の項目を作成する代わりに、定期的なマスターと呼ばれる 1 つの実際の項目のみを予定表に作成します。 定期的なマスターの形式は、定期的なパターン情報を追加して、非定期的な予定に非常によく似ています。 その後、サーバーは、予定情報のクライアント要求に応じて、展開と呼ばれるプロセスを使用して、定期的なパターンに基づいて出現を生成します。 これらの生成された出現は、サーバーに永続的に格納されません。 予定表アイテムを検索する方法によって、受け取る情報と拡張が行われるかどうかが決まるので、これは理解することが重要です。
定期的なパターン
展開を可能にする定期的な系列の重要な部分は、繰り返しパターンです。 定期的なパターンは定期的なマスターで見つかり、定期的なマスターの日付と時刻に基づいて発生を計算するための一連の条件を記述します。
表 1. 使用可能な定期的なパターン
EWS マネージ API のクラス | EWS の要素 | 例 |
---|---|---|
Recurrence.DailyPattern |
DailyRecurrence |
毎日繰り返します。 隔日で繰り返します。 |
Recurrence.MonthlyPattern |
AbsoluteMonthlyRecurrence |
毎月 10 日に繰り返します。 隔月の 21 日に繰り返します。 |
Recurrence.RelativeMonthlyPattern |
RelativeMonthlyRecurrence |
毎月第 2 火曜日に繰り返します。 3 か月ごとの第 3 木曜日に繰り返します。 |
Recurrence.RelativeYearlyPattern |
RelativeYearlyRecurrence |
毎年 8 月の第 1 月曜日に繰り返します。 |
Recurrence.WeeklyPattern |
WeeklyRecurrence |
毎週月曜日に繰り返します。 隔週の火曜日と木曜日に繰り返します。 |
Recurrence.YearlyPattern |
AbsoluteYearlyRecurrence |
毎年 9 月 1 日に繰り返します。 |
定期的なパターンについての別の重要な情報は、定期的なアイテムが終了するのはいつかということです。 これは、アイテムのセット数、終了日、または終了日なしとして表すことができます。
表 2. 定期的なアイテムの終了オプション
EWS マネージ API メソッド/プロパティ | EWS の要素 | 説明 |
---|---|---|
Recurrence.NumberOfOccurrences |
NumberedRecurrence |
このプロパティまたは要素の値は、アイテムの数を指定します。 |
Recurrence.EndDate |
EndDateRecurrence |
定期的なアイテムの最後のアイテムは、このプロパティまたは要素で指定された日付の当日またはそれ以前になります。 |
Recurrence.HasEnd Recurrence.NeverEnds |
NoEndRecurrence |
定期的なアイテムには終わりがありません。 |
展開ビューと非展開ビュー
EWS マネージ API で FindAppointments メソッド (または EWS の CalendarView 要素を使用した FindItem 操作) を使用すると、拡張プロセスが呼び出されます。 これにより、定期的なマスター予定が結果セットから非表示になり、代わりにその定期的な系列の展開ビューが表示されます。 カレンダー ビューのパラメーターに含まれる定期的なマスターの出現と例外は、結果セットに含まれます。 逆に、EWS マネージ API で FindItems メソッド (または、EWS の IndexedPageItemView 要素または FractionalPageItemView 要素を使用した FindItem 操作) を使用しても、展開プロセスは呼び出されず、出現と例外は含まれません。 2 つのメソッドを比較する例を見てみましょう。
表 3. 予定を検索するメソッドと操作
EWS マネージ API メソッド | EWS 操作 | 定期的なアイテムの展開 | 結果に含まれるアイテム |
---|---|---|---|
ExchangeService.FindAppointments |
CalendarView 要素を設定した FindItem 操作 |
はい |
非定期的な予定、定期的なアイテムの 1 つのアイテム、および定期的なアイテムに対する例外 |
ExchangeService.FindItems |
IndexedPageItemView 要素または FractionalPageItemView 要素を設定した FindItem 操作 |
いいえ |
非定期的な予定と定期的マスターの予定 |
サディは息子をスイムチームにサインアップしたばかりです。 チームは毎週水曜日の午前8時30分、7月2日から練習を行い、最後の練習は8月6日です。 練習を忘れたくないサディは、カレンダーに定期的な予定を追加して思い出させます。
表 4. Sadie の定期的な予定
予定フィールド | 値 |
---|---|
件名 |
水泳チームの練習 |
開始 |
2014 年 7 月 2 日午前 8 時 30 分 |
終了 |
2014 年 7 月 2 日午前 10 時 00 分 |
繰り返し |
毎週水曜日 |
最後のアイテム |
2014 年 8 月 6 日午前 8 時 30 分 |
予定表を一瞥すると、チームは合計 6 回の練習を行うと示されています。 しかし予定表には、6 つの個別の予定アイテムはありません。 その代わりに、定期的なアイテムを代表する定期的マスターの予定が 1 つだけあります。
ここで、Sadie の予定表の、7 月中に発生する予定を見つけることについて説明します。 次のコード例では、Exchange マネージ API の FindItems メソッドを使用して、Sadie の予定表の非展開ビューを作成します。
PropertySet propSet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Location,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.AppointmentType);
#region FindItems + ItemView method
ItemView itemView = new ItemView(100);
itemView.PropertySet = propSet;
List<SearchFilter> filterList = new List<SearchFilter>();
// Find appointments that start after midnight on July 1, 2014.
SearchFilter.IsGreaterThan startFilter = new SearchFilter.IsGreaterThan(AppointmentSchema.Start,
new DateTime(2014, 7, 1));
// Find appointments that end before midnight on July 31, 2014
SearchFilter.IsLessThan endFilter = new SearchFilter.IsLessThan(AppointmentSchema.End,
new DateTime(2014, 7, 31));
filterList.Add(startFilter);
filterList.Add(endFilter);
SearchFilter.SearchFilterCollection calendarFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, filterList);
// This results in a call to EWS.
FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.Calendar, calendarFilter, itemView);
foreach(Item appt in results.Items)
{
Console.WriteLine(appt.Subject);
}
このコードの結果は、次に示す IndexedPageItemView 要素を設定した FindItem 操作要求になります。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2007_SP1" />
<t:TimeZoneContext>
<t:TimeZoneDefinition Id="Pacific Standard Time" />
</t:TimeZoneContext>
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:FieldURI FieldURI="calendar:Location" />
<t:FieldURI FieldURI="calendar:Start" />
<t:FieldURI FieldURI="calendar:End" />
<t:FieldURI FieldURI="calendar:CalendarItemType" />
</t:AdditionalProperties>
</m:ItemShape>
<m:IndexedPageItemView MaxEntriesReturned="100" Offset="0" BasePoint="Beginning" />
<m:Restriction>
<t:And>
<t:IsGreaterThan>
<t:FieldURI FieldURI="calendar:Start" />
<t:FieldURIOrConstant>
<t:Constant Value="2014-07-01T07:00:00.000Z" />
</t:FieldURIOrConstant>
</t:IsGreaterThan>
<t:IsLessThan>
<t:FieldURI FieldURI="calendar:End" />
<t:FieldURIOrConstant>
<t:Constant Value="2014-07-31T07:00:00.000Z" />
</t:FieldURIOrConstant>
</t:IsLessThan>
</t:And>
</m:Restriction>
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="calendar" />
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
サーバーの応答には、 RecurringMaster の CalendarItemType 要素の値を示す 1 つのアイテム (定期的マスター) のみが含まれます。 ItemId 要素の値は読みやすいよう短縮されています。
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="https://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="939" MinorBuildNumber="16" Version="V2_11"
xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:FindItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:RootFolder IndexedPagingOffset="1" TotalItemsInView="1" IncludesLastItemInRange="true">
<t:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkADA5..." ChangeKey="DwAAABYA..." />
<t:Subject>Swim Team Practice</t:Subject>
<t:Start>2014-07-02T15:30:00Z</t:Start>
<t:End>2014-07-02T17:00:00Z</t:End>
<t:Location>Neighborhood Swimming Pool</t:Location>
<t:CalendarItemType>RecurringMaster</t:CalendarItemType>
</t:CalendarItem>
</t:Items>
</m:RootFolder>
</m:FindItemResponseMessage>
</m:ResponseMessages>
</m:FindItemResponse>
</s:Body>
</s:Envelope>
では、展開ビューと比較してみましょう。 次のコード例では、EWS マネージ API の FindAppointments メソッドを使用して、Sadie の予定表の展開ビューを作成します。
PropertySet propSet = new PropertySet(AppointmentSchema.Subject,
AppointmentSchema.Location,
AppointmentSchema.Start,
AppointmentSchema.End,
AppointmentSchema.AppointmentType);
CalendarView calView = new CalendarView(new DateTime(2014, 7, 1),
new DateTime(2014, 7, 31));
calView.PropertySet = propSet;
FindItemsResults<Appointment> results = service.FindAppointments(WellKnownFolderName.Calendar, calView);
foreach(Appointment appt in results.Items)
{
Console.WriteLine(appt.Subject);
}
このコードの結果は、次に示す CalendarView 要素を設定した FindItem 操作要求になります。
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2007_SP1" />
<t:TimeZoneContext>
<t:TimeZoneDefinition Id="Pacific Standard Time" />
</t:TimeZoneContext>
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
<t:FieldURI FieldURI="calendar:Location" />
<t:FieldURI FieldURI="calendar:Start" />
<t:FieldURI FieldURI="calendar:End" />
<t:FieldURI FieldURI="calendar:CalendarItemType" />
</t:AdditionalProperties>
</m:ItemShape>
<m:CalendarView StartDate="2014-07-01T07:00:00.000Z" EndDate="2014-07-31T07:00:00.000Z" />
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="calendar" />
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
今度は、サーバーの応答に 5 つのアイテム (7 月の各水曜日につき 1 つ) が含まれます。 これらのアイテムの CalendarItemType 要素は、すべて Occurrence の値を持っています。 定期的マスターはこの応答に存在しない点に注意してください。 ItemId 要素の値は、読みやすいよう短縮されています。
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="https://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="15" MinorVersion="0" MajorBuildNumber="939" MinorBuildNumber="16" Version="V2_11"
xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<m:FindItemResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<m:ResponseMessages>
<m:FindItemResponseMessage ResponseClass="Success">
<m:ResponseCode>NoError</m:ResponseCode>
<m:RootFolder TotalItemsInView="5" IncludesLastItemInRange="true">
<t:Items>
<t:CalendarItem>
<t:ItemId Id="AAMkADA6..." ChangeKey="DwAAABYA..." />
<t:Subject>Swim Team Practice</t:Subject>
<t:Start>2014-07-02T15:30:00Z</t:Start>
<t:End>2014-07-02T17:00:00Z</t:End>
<t:Location>Neighborhood Swimming Pool</t:Location>
<t:CalendarItemType>Occurrence</t:CalendarItemType>
</t:CalendarItem>
<t:CalendarItem>
<t:ItemId Id="AAMkADA7..." ChangeKey="DwAAABYA..." />
<t:Subject>Swim Team Practice</t:Subject>
<t:Start>2014-07-09T15:30:00Z</t:Start>
<t:End>2014-07-09T17:00:00Z</t:End>
<t:Location>Neighborhood Swimming Pool</t:Location>
<t:CalendarItemType>Occurrence</t:CalendarItemType>
</t:CalendarItem>
<t:CalendarItem>
<t:ItemId Id="AAMkADA8..." ChangeKey="DwAAABYA..." />
<t:Subject>Swim Team Practice</t:Subject>
<t:Start>2014-07-16T15:30:00Z</t:Start>
<t:End>2014-07-16T17:00:00Z</t:End>
<t:Location>Neighborhood Swimming Pool</t:Location>
<t:CalendarItemType>Occurrence</t:CalendarItemType>
</t:CalendarItem>
<t:CalendarItem>
<t:ItemId Id="AAMkADA9..." ChangeKey="DwAAABYA..." />
<t:Subject>Swim Team Practice</t:Subject>
<t:Start>2014-07-23T15:30:00Z</t:Start>
<t:End>2014-07-23T17:00:00Z</t:End>
<t:Location>Neighborhood Swimming Pool</t:Location>
<t:CalendarItemType>Occurrence</t:CalendarItemType>
</t:CalendarItem>
<t:CalendarItem>
<t:ItemId Id="AAMkADAA..." ChangeKey="DwAAABYA..." />
<t:Subject>Swim Team Practice</t:Subject>
<t:Start>2014-07-30T15:30:00Z</t:Start>
<t:End>2014-07-30T17:00:00Z</t:End>
<t:Location>Neighborhood Swimming Pool</t:Location>
<t:CalendarItemType>Occurrence</t:CalendarItemType>
</t:CalendarItem>
</t:Items>
</m:RootFolder>
</m:FindItemResponseMessage>
</m:ResponseMessages>
</m:FindItemResponse>
</s:Body>
</s:Envelope>
定期的なマスター、出現、または例外を取得した後は、 常に他の関連項目を取得できます。 発生または例外が発生した場合は、定期的なマスターを取得できます。その逆も可能です。
定期的な予定表アイテムの操作
非定期的な予定表アイテムを操作するために使用するメソッドおよび操作と同じものを、定期的なアイテムを操作するために使用します。 相違点は、実行するアクションが定期的なアイテム全体に適用されるか、1 つのアイテムのみに適用されるかが、それらのメソッドまたは操作を呼び出すために使用するアイテムによって決まることです。 定期的マスターに実行したアクションは、定期的なアイテム内のすべてのアイテムに適用されますが、1 つのアイテムまたは例外に実行したアクションは、そのアイテムまたは例外にのみ適用されます。