这是 WSS3.0 Web 服务查询中的错误吗?

发布于 2024-10-03 16:28:23 字数 1308 浏览 0 评论 0原文

我一整天都在努力调试一个查询,该查询使用 Lists Web 服务和 GetListItems 方法根据 Modified 字段过滤出元素,以仅获取自上次检查以来修改的元素。

这是查询参数:

<Where>
  <Gt>
    <FieldRef Name="Modified" /> 
    <Value Type="DateTime" IncludeTimeValue="TRUE">2010-11-23T17:0:00Z</Value> 
  </Gt>
</Where>

我很难弄清楚为什么它没有返回任何内容,因为列表中的一个元素在该日期(以 UTC 指定)之后明显被修改。这是因为,尽管您以 UTC 指定它(也在选项参数中强制执行),Sharepoint 仍会将其与使用站点设置中指定的区域设置存储或显示的修改时间戳进行字面比较。

我不确定我是否清楚,所以这是一个例子:
我正在查询的网站采用 EST 语言环境,最新元素已于今天 12:11:00(即 17:12:00Z)修改。

我上次在格林威治标准时间下午 4 点检查更新,因此我的查询参数将包含以下内容:

<Where>
  <Gt>
    <FieldRef Name="Modified" /> 
    <Value Type="DateTime" IncludeTimeValue="TRUE">2010-11-23T16:00:00Z</Value> 
  </Gt>
</Where>

这不会返回任何值,因为 sharepoint 将 16:00:00Z 与 12:11:00 进行字面比较,因此在 16:00 之后没有更新: 00Z。

我通过在查询中输入 12:10:00Z 来确认这一点,然后我得到了我想要的列表元素。输入 12:12:00Z,结果中就不再有该值了。

所以,我想我的问题是,这是 WSS 3.0 中的错误,还是我做错了什么?如果是这样,我该如何纠正这个问题?顺便说一句,我想将存储的时间保留为 UTC,并且无法控制用户对其网站设置的操作。有没有办法使用 Web 服务检索站点使用的区域设置?


更新: 请参阅有没有办法获取具有 Web 服务的 Sharepoint 站点的区域设置? 获取解决方案。

I've been struggling all day to debug a query that filters out element based on the Modified field using Lists web service and GetListItems method, to get only the elements modified since the last time I checked.

Here is the query parameter:

<Where>
  <Gt>
    <FieldRef Name="Modified" /> 
    <Value Type="DateTime" IncludeTimeValue="TRUE">2010-11-23T17:0:00Z</Value> 
  </Gt>
</Where>

I've had trouble figuring out why this returned nothing since one element in the list was clearly modified after this date, specified in UTC. That's because although you specify it in UTC (also enforced in the options parameter), Sharepoint will compare it literally with the modified timestamps stored or displayed with the locale specified in the site settings.

I'm not sure I'm clear, so here's a example:
The site I'm querying is in EST locale, and the latest element has been modified today at 12:11:00, which is 17:12:00Z.

I last checked for updates at 4pm GMT, so my query parameter will contain the following:

<Where>
  <Gt>
    <FieldRef Name="Modified" /> 
    <Value Type="DateTime" IncludeTimeValue="TRUE">2010-11-23T16:00:00Z</Value> 
  </Gt>
</Where>

And this will not return any value because sharepoint compares 16:00:00Z with 12:11:00 literally and thus has no updates after 16:00:00Z.

I confirmed this by putting 12:10:00Z in the query, and there I get the list element I wanted. Put 12:12:00Z, and it's no more in the results.

So, I guess my question is, is that a bug in WSS 3.0, or am I doing something wrong? If so, how can I do to correct this? BTW, I want to keep my stored times in UTC and cannot control what users do with their sites' settings. Is there a way to retrieve the locale used by the site using web services?


Update:
See Is there a way to get a Sharepoint site's locale with web services? for the solution.

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

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

发布评论

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

评论(1

玩物 2024-10-10 16:28:23

我不知道这是否是一个错误,但我在这里找到了解决方法:
有没有办法获得具有 Web 服务的 Sharepoint 站点的区域设置?

当您知道站点区域设置和 UTC 之间的偏移量时,只需将该偏移量应用于您想要过滤的 UTC 时间,然后将其插入查询节点中。

   ndQuery.InnerXml = "<Where><Gt><FieldRef Name='Modified' />" +
   "<Value Type='DateTime' IncludeTimeValue='TRUE'>" + (last_update + offset).ToString("yyyy-MM-dd") + " " + (last_update + offset).ToString("HH:mm:ss") + "</Value></Gt></Where>";

I don't know if that's a bug, but I found a workaround here:
Is there a way to get a Sharepoint site's locale with web services?

when you have the offset betwen the site's locale and UTC, just apply the offset to the UTC time you want to filter by and then insert it in you query node.

   ndQuery.InnerXml = "<Where><Gt><FieldRef Name='Modified' />" +
   "<Value Type='DateTime' IncludeTimeValue='TRUE'>" + (last_update + offset).ToString("yyyy-MM-dd") + " " + (last_update + offset).ToString("HH:mm:ss") + "</Value></Gt></Where>";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文