上传document后的表单中owner的默认值为当前上传的人.
分析:
要实现该功能, MS只能通过Event handle的方法实现了.
实现:
1. 在central administration中启动Event handle功能, application management - web application general settings , 在web application列表中选择你需要启动该功能的网站, 然后在backward-compatible event handlers中选择on 选项. 如图:
![](https://www.cnblogs.com/images/cnblogs_com/Lordan/120531/r_Snap4.gif)
2. 进入到document library, settings - document library settings , 选择advanced settings, 在backward-compatible event handler表单中输入assembly name , class name 和 properties的内容, 如图:
![](https://www.cnblogs.com/images/cnblogs_com/Lordan/120531/r_Snap5.gif)
其实第二步的内容是关于dll的内容.
3, 关于编译后的dll, 我把它放在C:\WINDOWS\assembly, 应该放在Bin也可以的, 然后修改web.config 中关于<SafeControls> 就可以了.
代码:
实现该功能需要完成IListEventSink接口![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
public class DocumentEvent
:IListEventSink
{
private string strOwner = "Owner";
private string strIsExpired = "IsExpired";
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
public void OnEvent(SPListEvent listEvent)
{
if (listEvent.Type == SPListEventType.Insert || listEvent.Type == SPListEventType.Update )
{
try
{
SPWeb web = listEvent.Site.OpenWeb();
if (web.Lists[listEvent.ListID].Fields.ContainsField(strOwner))
{
SPFile file = web.GetFile(listEvent.UrlAfter);
while (file.CheckOutStatus != SPFile.SPCheckOutStatus.None)
{
System.Threading.Thread.Sleep(1000);
file = web.GetFile(listEvent.UrlAfter);
}
if (file.Item[strOwner] == null)
{
file.Item[strOwner] = file.Author;
file.Item.Update();
}
}
}
catch
{
}
}
}
}
分析:
要实现该功能, MS只能通过Event handle的方法实现了.
实现:
1. 在central administration中启动Event handle功能, application management - web application general settings , 在web application列表中选择你需要启动该功能的网站, 然后在backward-compatible event handlers中选择on 选项. 如图:
![](https://www.cnblogs.com/images/cnblogs_com/Lordan/120531/r_Snap4.gif)
2. 进入到document library, settings - document library settings , 选择advanced settings, 在backward-compatible event handler表单中输入assembly name , class name 和 properties的内容, 如图:
![](https://www.cnblogs.com/images/cnblogs_com/Lordan/120531/r_Snap5.gif)
其实第二步的内容是关于dll的内容.
3, 关于编译后的dll, 我把它放在C:\WINDOWS\assembly, 应该放在Bin也可以的, 然后修改web.config 中关于<SafeControls> 就可以了.
代码:
实现该功能需要完成IListEventSink接口
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)