如何在SharePoint的ItemAdded()事件上检测项目还原 [英] How to detect the item restore on a ItemAdded() event on SharePoint

查看:140
本文介绍了如何在SharePoint的ItemAdded()事件上检测项目还原的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,从回收站中还原项目时,将触发ItemAdded事件. 但是,如何检测添加的项目是来自回收站还是新文件.

I know that when an item is restored from the recycle bin, the ItemAdded event is fired. However, how can I detect if the item added comes from the recycle bin or if it is a new file.

推荐答案

这是一个非常古老的主题,但是在有关该主题的搜索中排名最高.

This is a very old thread, but it comes up in the top results for searches on the topic.

根据我对SP2010的实验,它看起来像属性当项目来自回收站时,.Property 为空,而在实际的新项目中已完全填充.

From my experiments with SP2010, it looks like properties.AfterProperties is empty when the item is coming from the Recycle Bin, whereas it is fully populated on an actual new item.

因此,像这样的简单块就可以解决问题:

So, a simple block such as this would do the trick:

if (!properties.AfterProperties.Cast<DictionaryEntry>().Any())
{
    // From Recycle Bin!
}
else
{
    // This item is really new.
}

我尚未测试过MOSS或SP2013.

I have not tested MOSS or SP2013 yet.

这篇关于如何在SharePoint的ItemAdded()事件上检测项目还原的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆