Sharepoint 内容查询 Web 部件:显示“事件”中的项目设置为在一个月内发生或重复发生的列表

发布于 2024-09-06 05:07:51 字数 1600 浏览 9 评论 0原文

我一直在读这篇msdn帖子: http://msdn.microsoft.com/en-us/library/aa981241。 aspx

尝试编辑内容查询 Web 部件,以仅显示事件列表中 30 天内发生或 30 天内重复发生的项目。处理不会重复发生的事件很简单,因为我可以通过修改此共享 Web 部件配置来将 [开始日期] 与 [今天]+30 进行比较,但对于重复发生的事件,似乎 [开始日期] 和 [结束日期] ] 描述重复发生的事件将发生的时间段,并且我不知道如何确定事件即将再次发生的最快时间。 cqwp 仅采用三个过滤器项目,因此我无法在不覆盖查询的情况下处理重复出现的项目和单次出现的项目。

我认为我需要用于重复发生的字段是以下字段之一: msdn-microsoft-com/en-us/library/microsoft.sharepoint.spfieldrecurrence_members.aspx 但它们似乎都不合适。

“初四”再次发生,你如何应对 msdn-microsoft-com/en-us/library/microsoft.sharepoint.weekofmonth.aspx

基本上,如何覆盖查询来过滤重复发生和单次发生的事件,以仅显示一周内发生的事件?

我已将以下代码添加到 CQWP .webpart 文件中:

<Where>
<Or>
<And>
  <Neq>
    <FieldRef Name="FRecurrence"/>
    <Value Type="Recurrance">1</Value>
  </Neq>
  <And> 
    <Lt>
      <FieldRef Name="EventDate" Type="DateTime"/>
      <Value Type="DateTime"><Today OffsetDays="30"/></Value>
    </Lt>
    <Gt>
     <FieldRef Name="EventDate" Type="DateTime"/>
    <Value Type="DateTime"><Today /></Value>
    </Gt>
  </And>
</And>
<DataRangesOverlap>
  <FieldRef Name="EventDate" />
  <FieldRef Name="EndDate" />
  <FieldRef Name="RecirrenceId" />
  <Value Type="DateTime"><Month /></Value>
</DataRangesOverlap>
</Or>   
</Where>

但我的页面返回:“无法添加选定的 Web 部件。文件格式无效。尝试导入 Web 部件文件 (.WebPart)。”

I've been reading this msdn post:
http://msdn.microsoft.com/en-us/library/aa981241.aspx

trying to edit the content query web part to only show items from the event list which either occur within 30 days or reoccur within 30 days. It is straight forward to deal with events which do not reoccur because I can compare [Start Date] to [Today]+30 with the modify this shared web part configuration, but for reocurring events it seems that [Start Date] and [End Date] describe the period over which the reocurring event is to occur, and I don't know what to do to determine the soonest upcoming reoccurance of an event. The cqwp only takes three filter items, so I can't deal with both recurring and single occurance items without overriding the query.

I think the field I need to use for reoccurrance is one of these:
msdn-microsoft-com/en-us/library/microsoft.sharepoint.spfieldrecurrence_members.aspx
but none of them seem appropriate.

How do you deal with the "fourth day of the month" reocurrance
msdn-microsoft-com/en-us/library/microsoft.sharepoint.weekofmonth.aspx

Basically, how do you override the query to filter reocurring and single occurance events to show only those which occur within a week?

I've added the following code to the CQWP .webpart file:

<Where>
<Or>
<And>
  <Neq>
    <FieldRef Name="FRecurrence"/>
    <Value Type="Recurrance">1</Value>
  </Neq>
  <And> 
    <Lt>
      <FieldRef Name="EventDate" Type="DateTime"/>
      <Value Type="DateTime"><Today OffsetDays="30"/></Value>
    </Lt>
    <Gt>
     <FieldRef Name="EventDate" Type="DateTime"/>
    <Value Type="DateTime"><Today /></Value>
    </Gt>
  </And>
</And>
<DataRangesOverlap>
  <FieldRef Name="EventDate" />
  <FieldRef Name="EndDate" />
  <FieldRef Name="RecirrenceId" />
  <Value Type="DateTime"><Month /></Value>
</DataRangesOverlap>
</Or>   
</Where>

but my page is returning: "Unable to add selected web part(s). The file format is not valid. Try importing a Web Part file (.WebPart)."

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

携君以终年 2024-09-13 05:07:51

SharePoint 重复事件很棘手。这篇文章是了解重复发生的事件混乱的最佳资源

了解 SharePoint 日历以及如何将其导出到iCal 格式

我认为您无法在 CEWP 中执行此操作,但您可以使用类似的内容获得重复事件,

    SPList list = oSPWeb.GetList(listGuid);
    SPQuery query = new SPQuery();
    query.ExpandRecurrence = true;
    query.CalendarDate = new DateTime(2010, 6, 17);

    query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Week /></Value></DateRangesOverlap></Where>";
    SPListItemCollection listItems = list.GetItems(query);
    foreach (SPListItem items in listItems)
    {
        // items["EventDate"].ToString()
    }

然后您将获得本周发生的重复和非重复事件。

但请注意,这是设计供日历视图使用的,因此如果您这样做,例如

query.CalendarDate = new DateTime(2010, 6, 17);
query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Month /></Value></DateRangesOverlap></Where>";

(注意月份设置),那么您将获得应出现在本月日历视图上的所有事件 - 即 2010 年 5 月 31 日到 7 月 4 日2010年。

SharePoint recurring events are tricky. This post is the single best resource for understanding the mess of recurring events

Understanding the SharePoint calendar and how to export it to iCal format

I don't think you're going to be able to do this in a CEWP but you can get the recurrences using something like

    SPList list = oSPWeb.GetList(listGuid);
    SPQuery query = new SPQuery();
    query.ExpandRecurrence = true;
    query.CalendarDate = new DateTime(2010, 6, 17);

    query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Week /></Value></DateRangesOverlap></Where>";
    SPListItemCollection listItems = list.GetItems(query);
    foreach (SPListItem items in listItems)
    {
        // items["EventDate"].ToString()
    }

Then you will get recurring and non-recurring events that occur this week.

But beware that this is designed to be used by the calendar view so if you do, for example,

query.CalendarDate = new DateTime(2010, 6, 17);
query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Month /></Value></DateRangesOverlap></Where>";

(Notice the Month setting) then you will get all events that should appear on this months calendar view - that is 31st May 2010 to 4th July 2010.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文