SharePoint:更新了单个项目的多个事件

发布于 2024-10-04 03:18:51 字数 280 浏览 0 评论 0原文

我有一个用于页面库中使用的特定内容类型的项目事件接收器。我正在使用事件记录器来调试它,我可以看出,每当我编辑页面并发布它时,它都会触发 3 个 ItemUpdating 和 3 个 ItemUpdated 事件。我确信在该特定时间内没有其他页面被保存。

造成这种情况的原因是什么?有什么方法可以“修复”它,以便每个页面发布仅触发 1 个事件?

或者,有什么方法可以将最后一个事件(即:页面现已发布或正在发布)与其他事件区分开来,这样我就不会最终运行我的代码三次?

I have an item event receiver for a specific content type that is used in a Pages library. I am using the event logger to debug it, and I can tell that whenever I edit a page and publish it, it fires 3 ItemUpdating and 3 ItemUpdated events. I am certain that no other pages are being saved in that specific time.

What is the cause of this and is there any way to "fix" it to trigger only 1 event per page publish?

Alternatively, is there any way to distinguish the last of the events (ie: page is now published or being published) from the others, so I don't end up running my code three times?

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

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

发布评论

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

评论(2

美男兮 2024-10-11 03:18:51

事实证明,这是因为当用户点击“发布”时,页面实际上被保存了3次:

  1. 文档被保存。
  2. 文档已签入。
  3. 文档已发布。

其中每一个都会触发 ItemUpdatedItemUpdating 事件。

As it turns out, it was because the page was actually being saved 3 times when a user clicks "Publish":

  1. The document is saved.
  2. The document is checked in.
  3. The document is published.

Each of these triggers an ItemUpdated and ItemUpdating event.

归属感 2024-10-11 03:18:51

使用DisableEventFiring() 方法可以防止触发任何其他事件。只需记住通过 EnableEventFiring() 再次启用它即可。希望这有帮助。

Use the DisableEventFiring() method to prevent any other events from firing. Just remember to enable it again via EnableEventFiring(). Hope this helps.

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