I have a content query webpart that read the calendar list and display currently running events.
The issue I have is when I set up a recurring event, my query gets "broken".
My CAML request :
<Where>
<And>
<Leq>
<FieldRef Name="EventDate" Nullable="False" Type="DateTime"/>
<Value Type="DateTime" IncludeTimeValue="TRUE">
<Today />
</Value>
</Leq>
<Geq>
<FieldRef Name="EndDate" Nullable="False" Type="DateTime"/>
<Value Type="DateTime" IncludeTimeValue="TRUE">
<Today />
</Value>
</Geq>
</And>
</Where>
Problem is, recurring events are defined with an EventDate of whenever it starts, but the EndDate is something like in 10 years from now (or in year 4499 O_o ).
Here's the identity output of a recurring event (it seems nothing define it like that... at least, from the info I can toy with).
Property:ListId | Value:<gibberish>
Property:WebId | Value:<gibberish>
Property:ID | Value:17
Property:Title | Value:maint
Property:FileRef | Value:SiteDirectory/mysite/Lists/Calendrier/17_.000
Property:_x007B_1d22ea11_x002D_1e32_x002D_424e_x002D_89ab_x002D_9fedbadb6ce1_x007D_ | Value:17
Property:Modified | Value:2011-07-05 10:37:02
Property:Author | Value:Admin
Property:Editor | Value:Admin
Property:Created | Value:2011-07-05 10:37:02
Property:PublishingRollupImage | Value:
Property:_Level | Value:1
Property:Comments | Value:
Property:EventDate | Value:2011-07-05 03:00:00
Property:EndDate | Value:2021-01-26 05:00:00
Property:fAllDayEvent | Value:0
Property:LinkUrl | Value:http://localhost/SiteDirectory/mySite/Lists/Calendrier/17_.000
Property:PubDate | Value:Tue, 05 Jul 2011 14:37:02 GMT
Property:ImageUrl | Value:
Property:ImageUrlAltText | Value:
Property:Description | Value:
Property:Style | Value:identity
Property:GroupStyle | Value:Band
Property:__begincolumn | Value:True
Property:__begingroup | Value:False
(This event is defined as happening every Monday and Tuesday).
- How can I know if an event is recurrent or not?
- How could I filter my query to contains only currently running occurrence of a开发者_开发问答 periodic event?
The first thing to realise is that a recurring event series is stored as just one event, not as each individual instance.
Hence the start/end dates being so long - its the total length of the recurrance, not any particular instance.
There is an fRecurrance field that is True if you are dealing with a recurring event.
This is about the only guide you will find for understanding recurring events - but heads up, working with recurring events is hard work and that way lies anger, hate and suffering...
MSDN - Understanding the SharePoint calendar and how to export it to iCal format
精彩评论