2010-10-05 75 views
0

我希望在复制操作被激怒时增加元数据。Sharepoint-Property在ItemAdded事件中标识文档/项目的来源

 public override void ItemAdded(SPItemEventProperties properties) 
     {   
      try 
      { 
       this.DisableEventFiring(); 
       SPSecurity.RunWithElevatedPrivileges(delegate() 
       { 
       string oid = string.Empty;       
       using (SPWeb web = properties.OpenWeb()) 
       { 
        SPList list = web.Lists[properties.ListId]; 
        SPListItem item = list.Items[properties.ListItem.UniqueId];  
        String Source=item.CopySource.toString(); 
       } 
       }); 
      } 
Catch() 

以下项目> copysource返回空字符串 所以这对我来说很难检查wheter事件已触发由于复制操作

+0

您可以提供有关文档如何被复制的更多信息?至少在WSS中,我能想到复制文档的唯一方法是使用Windows资源管理器。 – 2010-10-06 20:53:10

+0

另一种方式是通过发送到其他位置选项 – 2010-10-14 11:59:55

+0

和另一种方式是通过内容和结构 - >操作 - >移动/复制 – 2010-10-14 12:00:31

回答

0

你不需要RunWithElevatedPrivileges,因为ItemAdded事件已经与形式运行特权用户。

+0

嗨詹尼斯Veinbergs,我都做到了,而无需使用RunWithElevatedPrivileges,但我的问题是项目。 copysource返回一个空字符串。那么我怎么确定这是由于复制操作造成的 – 2010-10-05 10:37:26

相关问题