如何区分 SharePoint 文件更新和文件上传?
在 SharePoint 中,当项目首次添加到文档库时,它会按预期触发 ItemAdded 和 ItemAdding 事件。如果您上传相同的文件名来更新现有文件,它将触发 ItemUpdated 和 ItemUpdating 事件,同样与预期相同。然而,我一直未能确定这种行为是否确实发生过。或者,更具体地说,我完全无法区分以下内容:
- 项目被更新,因为有人上传了新文件,但对任何表单字段没有执行任何操作。
- 由于有人点击“确定”但未对任何表单字段执行任何操作,因此项目已更新。
实际上有办法区分这些类型的更新吗?事件属性中似乎没有任何内容包含此信息,列表项和文件本身的版本历史记录中似乎也没有任何内容。我什至尝试通过 OpenBinary() 比较文件本身,但在上述两种情况下我仍然得到相同的结果。预先感谢您的帮助!
In SharePoint, when an item is first added to a document library, it fires the ItemAdded and ItemAdding events as expected. And if you upload the same filename to update the existing file, it will fire off ItemUpdated and ItemUpdating events, likewise as expected. However, I have been unsuccessful at determining whether this kind of action has actually occurred or not. Or, more specifically, I am entirely unable to differentiate between the following:
- An item is updated because someone uploaded a new file but did nothing to any of the form fields.
- An item is updated because someone hit "OK" but did nothing to any of the form fields.
Is there actually a way to distinguish these kinds of updates? There appears to be nothing in event properties that contains this information, nor in the version history for both the list item and the file itself. I have even tried comparing the files themselves via OpenBinary(), but in both mentioned cases I still get the same result. Thank you in advance for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两年多前我也经历过同样的问题。我实现它的方法是查看两种事件类型的 before 和 after 属性中的所有字段,并且一些更模糊的字段根据事件类型而有所不同。
不幸的是,我无法再访问该代码,因此我无法为您提供该字段的名称。只需转储所有之前和之后的属性并使用它即可。
痛苦,你会认为还有更简单的方法。我曾希望在第一次上传期间,Before Properties 将为 null 或为空,但没有这样的运气。
I went through this same problem just over 2 years ago. The way I implemented it was by looking at all the fields in the before and after properties for both event types and some of the more obscure fields were different depending on the kind of event.
Unfortunately I don't have access to that code any more so I can't give you the name of the field. Just dump all the before and after properties and play around with it.
Painful, you'd think there would be an easier way. I had hoped that during the first upload the Before Properties would be null or empty, but no such luck.