このクエリをWebアプリケーションと同じサーバーで実行しているので、SPQuery.ExpandRecurrenceが機能するはずです。しかし、以下の場合、返されたリストコレクションに3つのアイテムと3つのアイテムと再発生がありますが、そのすべては現在の月に含まれます。定期的なSharePointカレンダーリストアイテムを取得するには
Stramit Caml Viewerで照会が動作していることを確認し、同じ3つの項目を返します。
わかりやすいものが紛れていると教えてください。
static SPListItemCollection GetSourceColl(SPList list)
{
SPQuery query = new SPQuery();
query.ExpandRecurrence = true;
query.CalendarDate = new DateTime(DateTime.Now.Year,DateTime.Now.Month, 1);
System.Text.StringBuilder oSb = new System.Text.StringBuilder();
oSb.Append(" <Query xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">");
oSb.Append(" <Where>");
oSb.Append(" <And>");
oSb.Append(" <DateRangesOverlap>");
oSb.Append(" <FieldRef Name=\"EventDate\" />");
oSb.Append(" <FieldRef Name=\"EndDate\" />");
oSb.Append(" <FieldRef Name=\"RecurrenceID\" />");
oSb.Append(" <Value Type=\"DateTime\">");
oSb.Append(" <Month />");
oSb.Append(" </Value>");
oSb.Append(" </DateRangesOverlap>");
oSb.Append(" <And>");
oSb.Append(" <And>");
oSb.Append(" <Eq>");
oSb.Append(" <FieldRef Name=\"Status\" />");
oSb.Append(" <Value Type=\"Text\">Finalized</Value>");
oSb.Append(" </Eq>");
oSb.Append(" <Leq>");
oSb.Append(" <FieldRef Name=\"DistributionStartDate\" />");
oSb.Append(" <Value Type=\"DateTime\">");
oSb.Append(" <Today />");
oSb.Append(" </Value>");
oSb.Append(" </Leq>");
oSb.Append(" </And>");
oSb.Append(" <Neq>");
oSb.Append(" <FieldRef Name=\"Distribution\" />");
oSb.Append(" <Value Type=\"Text\">Intranet</Value>");
oSb.Append(" </Neq>");
oSb.Append(" </And>");
oSb.Append(" </And>");
oSb.Append(" </Where>");
oSb.Append(" </Query>");
query.Query = oSb.ToString();
return list.GetItems(query);
}
アメージング、以下のようにカスタムクエリにVIEWNAMEタイを渡すことをお勧めします:それはあなたがこれらの2行を削除した場合に正しく動作しません。本当にありがとう! – Marc