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

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 -- 指定查询的参考时间

查询每日事件

             using (SPSite site = new SPSite(siteUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList calendar = web.GetList(listUrl);
SPQuery caml = new SPQuery();
caml.Query = @"<Where>
<DateRangesOverlap>
<FieldRef Name='EventDate' />;
<FieldRef Name='EndDate' />
<FieldRef Name='RecurrenceID' />
<Value Type='DateTime'><Today /></Value>
</DateRangesOverlap>
</Where>"; caml.ExpandRecurrence = true;
caml.CalendarDate = DateTime.Now; return calendar.GetItems(caml);
}
}

查询每周事件

                     caml.Query = @"<Where>
<DateRangesOverlap>
<FieldRef Name='EventDate' />;
<FieldRef Name='EndDate' />
<FieldRef Name='RecurrenceID' />
<Value Type='DateTime'><Week /></Value>
</DateRangesOverlap>
</Where>";

查询每月事件

                     caml.Query = @"<Where>
<DateRangesOverlap>
<FieldRef Name='EventDate' />;
<FieldRef Name='EndDate' />
<FieldRef Name='RecurrenceID' />
<Value Type='DateTime'><Month /></Value>
</DateRangesOverlap>
</Where>";

查询每年事件

                     caml.Query = @"<Where>
<DateRangesOverlap>
<FieldRef Name='EventDate' />;
<FieldRef Name='EndDate' />
<FieldRef Name='RecurrenceID' />
<Value Type='DateTime'><Year /></Value>
</DateRangesOverlap>
</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. Java基本数据类型与位运算

    >>赋值运算符 赋值使用操作符“=”.它的意思是“取右边的值(即右值),把它复制给左边(即左值)”.右值可以是任何 常数.变量或者表达式 (只要它能 生成 一个值就行).但左值必须是一个明 ...

  2. 几年前做家教写的C教程(之五专讲结构体与文件操作)

    C语言学习宝典(5) 结构体: 将不同类型的数据组合成为一个有机的整体,这个整体就是一个结构体. 例如: Struct student { Int name; Char sex; Float scor ...

  3. PS 使用的常用命令

    本文记载一些简单的PS使用的命令 1. photoshop 画完矩形调整大小方法: a.画完矩形. b.按下Ctrl+T. c.拖边线上的小正方形就是了. 2. 画圆或者矩形时,按住shift 可以变 ...

  4. Daily Scrum Meeting ——SixthDay

    一.Daily Scrum Meeting照片 佳恺请假了...可能去约会了罢 二.Burndown Chart 欣慰,但是还是感到"鸭梨山大"! 三.项目进展 1.活动列表查询功 ...

  5. 分布式缓存技术redis学习系列(一)——redis简介以及linux上的安装

    redis简介 redis是NoSQL(No Only SQL,非关系型数据库)的一种,NoSQL是以Key-Value的形式存储数据.当前主流的分布式缓存技术有redis,memcached,ssd ...

  6. 简述UIScrollView的属性和用法

    contentOffset 默认CGPointZero,用来设置scrollView的滚动偏移量.       // 设置scrollView的滚动偏移量       scrollView.conte ...

  7. activity 、window与view的关系(下)

    在activity的attacth方法中,通过policymanager 的makenewwindow来创建window 而window的具体实现是phonewindow 接下来通过setconten ...

  8. jQuery学习笔记--JqGrid相关操作 方法列表(上)

    1.获得当前列表行数:$("#gridid").getGridParam("reccount"); 2.获取选中行数据(json):$("#gridi ...

  9. Query Mobile学习笔记

    1.获取jQuery mobile 文件,访问jQuerymobile网站下载 (貌似使用jquery mobile后,jquery会自动在网页中添加一些class类,第一次知道的我是被吓呆的!!) ...

  10. 【Raspberry Pi】新入手的Raspberry Pi3拼装日志

    一.概述 2016年暑假某宝入手Raspberry Pi 3,装机清单: 树莓派主板 亚克力外壳 小风扇 散热片 30G SD card 螺丝若干颗 因机型问题,可能与你的机器有微小差异 二.装机过程 ...