首先要搞清楚日历事件的各种类型,参考文章:

http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?PageType=4&ListId={72C1C85B-1D2D-4A4A-90DE-CA74A7808184}&pID=761

Type Description fRecurrence fAllDayEvent EventType
Single event

An event created with the All Day Event and

Recurrence checkboxes unselected.

FALSE FALSE 0
All-day event

An event created with the All Day Event

checkbox selected.

FALSE TRUE 0
Recurring event

An event created with the Recurrence checkbox selected.

Has a recurrence icon in the All Events view.

Appears as a single master event on the All Events view,

but as recurring instances on the Current Events and

Calendar views.

TRUE FALSE 1
Recurring all-day event

Same as above, but with the All Day Event checkbox

selected at creation time.

TRUE TRUE 1
Recurrence exception

Created by editing an instance of a recurring event.

Has a strikethrough recurrence icon in the All Events view.

TRUE FALSE 4
All-day recurrence exception

Same as above, but created by editing an instance of an

all-day recurring event.

TRUE TRUE 4

Deleted instance of a

recurring event

Created by deleting a instance of a recurring event.

Title is prefixed with “Deleted:” in the All Events view,

and is hidden in the Current Events and Calendar views.

TRUE FALSE 3

Deleted instance of an

all-day recurring event

Same as above, but created by deleting an instance of

an all-day recurring event.

TRUE TRUE 3

  重复事件

Field Value for single event Value for recurring event
EventDate Start date and time

Start date and time set for the recurring event when it was created,

which may be an earlier date than the first instance of the recurring event.

EndDate End date and time

End date and time for the last instance of the recurring event.

For recurring events with no end date, this is a computed date

several years in the future.

Duration

The time in seconds between EventDate

and EndDate.

The duration in seconds of an individual instance of the recurring event.

  特例事件和已删除事件

Field Value for exception or deleted instance
MasterSeriesItemID

The ID of the recurring event from which this exception

or deleted instance was made.

RecurrenceID

The date and time of the instance of the recurring event which this exception

or deleted instance takes the place of.

  重复事件的重复模式

Recurrence type RecurrenceData field value
Daily every 1 days, no end date

<recurrence>

  <rule>

    <firstDayOfWeek>su</firstDayOfWeek>

    <repeat><daily dayFrequency="1" /></repeat>

    <repeatForever>FALSE</repeatForever>

  </rule>

</recurrence>

Weekly every Monday, Tuesday,

and Wednesday, end by 5/31/2007

<recurrence>

  <rule>

    <firstDayOfWeek>su</firstDayOfWeek>

    <repeat>

      <weekly mo="TRUE" tu="TRUE" we="TRUE" weekFrequency="1" />

    </repeat>

    <windowEnd>2007-05-31T22:00:00Z</windowEnd>

  </rule>

</recurrence>

Monthly the third Wednesday of every 2 months,

no end date

<recurrence>

  <rule>

    <firstDayOfWeek>su</firstDayOfWeek>

    <repeat>

      <monthlyByDay we="TRUE" weekdayOfMonth="third" monthFrequency="2" />

    </repeat>

    <repeatForever>FALSE</repeatForever>

  </rule>

</recurrence>

Yearly every May 18, end after 10 instances

<recurrence>

  <rule>

    <firstDayOfWeek>su</firstDayOfWeek>

    <repeat><yearly yearFrequency="1" month="5" day="18" /></repeat>

    <repeatInstances>10</repeatInstances>

  </rule>

</recurrence>

虽然事件的重复模式是以XML格式储存,但在使用ClientObjectModel查询时,并不需要手动去解析XML。

使用SPQuery对象查询时,需指定以下属性:

ExpandRecurrence -- 是否展开重复事件

CalendarDate -- 指定查询的参考时间

查询每日事件

  1. using (SPSite site = new SPSite(siteUrl))
  2. {
  3. using (SPWeb web = site.OpenWeb())
  4. {
  5. SPList calendar = web.GetList(listUrl);
  6. SPQuery caml = new SPQuery();
  7. caml.Query = @"<Where>
  8. <DateRangesOverlap>
  9. <FieldRef Name='EventDate' />;
  10. <FieldRef Name='EndDate' />
  11. <FieldRef Name='RecurrenceID' />
  12. <Value Type='DateTime'><Today /></Value>
  13. </DateRangesOverlap>
  14. </Where>";
  15.  
  16. caml.ExpandRecurrence = true;
  17. caml.CalendarDate = DateTime.Now;
  18.  
  19. return calendar.GetItems(caml);
  20. }
  21. }

查询每周事件

  1. caml.Query = @"<Where>
  2. <DateRangesOverlap>
  3. <FieldRef Name='EventDate' />;
  4. <FieldRef Name='EndDate' />
  5. <FieldRef Name='RecurrenceID' />
  6. <Value Type='DateTime'><Week /></Value>
  7. </DateRangesOverlap>
  8. </Where>";

查询每月事件

  1. caml.Query = @"<Where>
  2. <DateRangesOverlap>
  3. <FieldRef Name='EventDate' />;
  4. <FieldRef Name='EndDate' />
  5. <FieldRef Name='RecurrenceID' />
  6. <Value Type='DateTime'><Month /></Value>
  7. </DateRangesOverlap>
  8. </Where>";

查询每年事件

  1. caml.Query = @"<Where>
  2. <DateRangesOverlap>
  3. <FieldRef Name='EventDate' />;
  4. <FieldRef Name='EndDate' />
  5. <FieldRef Name='RecurrenceID' />
  6. <Value Type='DateTime'><Year /></Value>
  7. </DateRangesOverlap>
  8. </Where>";

[SharePoint 2007/2010]Query SharePoint Calendar Event的更多相关文章

  1. [Beginning SharePoint Designer 2010]探索SharePoint Designer

    本章概要: 1.SharePoint Designer是如何进入到微软的工具集中去的 2.SharePoint Designer的基本特性 3.如何创建SharePoint站点 4.如何打开一个已经存 ...

  2. 更改SharePoint 2007/2010/2013 Web 应用程序端口号

    之前创建的Web应用程序端口为80,因为其他需要要将端口更改为85,下面是具体步骤: 第一步:更改IIS绑定. 打开IIS服务管理器,右击需要更改的站点,选择编辑绑定. 在打开的网站绑定窗口,选择端口 ...

  3. WIN中SharePoint Server 2010 入门安装部署详解

    目前流行的原始安装文件基本都是这样的:Windows Server 2008 R2+SQL Server 2008R2+SharePoint Server 2010     这个初始环境原本也无可厚非 ...

  4. SharePoint Server 2010 中的基本任务

    SharePoint Foundation 和 SharePoint Server 概述 SharePoint Foundation 2010 是一项用于 SharePoint 网站的基础技术,它可以 ...

  5. SharePoint Srver 2010 资源汇总

    转:http://bbs.winos.cn/thread-93681-1-1.html Microsoft SharePoint Server 2010 是适用于企业和网络的业务协作平台,可以帮助您通 ...

  6. 【SharePoint 2010】SharePoint 2010开发方面的课堂中整理有关问题

    SharePoint 2010开发方面的课堂中整理有关问题陈希章 ares@xizhang.com1. 对于SharePoint的体系结构不甚清楚,觉得有点乱了解了就不会觉得乱了,请理解1) 场服务 ...

  7. SharePoint Server 2010安装图解

    SharePoint Server 2010作为MOSS 2007的升级版本,自从2009年底发布Beta版本以来就备受关注,网络上已经出现了很多相关的文章,其中也不乏中文的信息. 最近SharePo ...

  8. SharePoint 2013/2010 中的日历重合 (Calendars Overlay)

    本文介绍 SharePoint 2013/2010 中的日历重合 (Calendars Overlay). 日历重合 (Calendars Overlay)的用途就是将 不多于10个日历或日历视图聚集 ...

  9. 【SharePoint 2010】将Sharepoint Server 2010部署到WINDOWS 7

    1.部署-安装环境: 在这里先说明一下:2007的版本中我们只能装在WINDOWS 2003 SERVER 上,这种限制在2010被彻底打破了.我们可以将它安装在VISTA/WINDOWS 7/SER ...

随机推荐

  1. .NET中RabbitMQ的使用

    概述 MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统.他遵循Mozilla Public ...

  2. HDU 2045 不容易系列之(3)―― LELE的RPG难题(递推)

    题意:有排成一行的n个方格,用红(Red).粉(Pink).绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.求全部的满足要求的涂法. 题解:本来当n=1时, ...

  3. C# 可视化读取文件、文件夹

    OpenFileDialog fd = new OpenFileDialog(); fd.Filter = "txt files (*.txt)|*.txt|All files(*.*)|* ...

  4. WSDL项目---添加头信息和附件

    用于底层协议的SOAP请求是HTTP,可以添加两个自定义HTTP头(例如用于身份验证或会话)和附件. 让我们看一下这两个. 1. 自定义HTTP标头 直接添加自定义HTTP头: 我们已经添加了自定义内 ...

  5. MFC的本质

    一.引言 上一专题中,纯手动地完成了一个Windows应用程序,然而,在实际开发中,我们大多数都是使用已有的类库来开发Windows应用程序.MFC(Microsoft Foundation Clas ...

  6. 堆排序 Heapsort

    Prime + Heap 简直神了 时间优化好多,顺便就把Heapsort给撸了一发 具体看图 Heapsort利用完全二叉树+大(小)顶锥的结构每次将锥定元素和锥最末尾的元素交换 同时大(小)顶锥元 ...

  7. jQuery全屏滚动插件fullPage.js

    github https://github.com/alvarotrigo/fullPage.js demo http://alvarotrigo.com/fullPage/ 脚手架 <link ...

  8. css 设置圆角

    CSS3 圆角(border-radius) -moz(例如 -moz-border-radius)用于Firefox -webkit(例如:-webkit-border-radius)用于Safar ...

  9. 实战java虚拟机的学习计划图(看懂java虚拟机)

    啥也不说了,实战java虚拟机,好好学习,天天向上!针对自己的软肋制定学习计划. 一部分内容看完,自己做的学习笔记和感想. 学java很简单,但懂java会有难度,如果你的工资还没超过1W,那是时候深 ...

  10. 【5集iCore3_ADP演示视频】5-2 iCore3应用开发平台上电及注意事项

    iCore3双核心应用开发平台基于iCore3双核心板,包含ARM.FPGA.7寸液晶屏.双通道数字示波器.任意波发生器.电压表等模块,是一款专为电子爱好者设计的综合性电子学习系统. [视频简介]本视 ...