不允许用户删除 Sharepoint 2007 中的列表
我有一个包含多个项目的列表。当存在正在运行工作流程的项目时,我不希望用户删除列表。我试图避免孤立的工作流程,并更好地控制用户可以对列表中的数据执行的操作。
我已经实现了一个部分,通过实现 ItemDeleting 来拒绝用户删除正在运行的工作流中的单个项目。
/// <summary>
/// Synchronous before event that occurs before an existing item is completely deleted.
/// Business logic related to deleting items. Checks if there are any problems with deleting the list item.
/// If there are any problems with deleting then the event will be cancelled with an error message. Otherwise deletion is allowed
/// </summary>
/// <param name="properties">
/// A Microsoft.SharePoint.SPItemEventProperties object that represents properties of the event handler.
/// </param>
public override void ItemDeleting(SPItemEventProperties properties)
{
SPListItem listItem = properties.ListItem;
foreach (SPWorkflow workflow in listItem.Workflows)
{
if (workflow.InternalState == SPWorkflowState.Running)
{
properties.Cancel = true;
properties.ErrorMessage = "It is not allowed to delete items with running workflows. Complete them before deleting";
}
}
}
现在我想对列表本身执行相同的操作,但没有可用的 SPEventReceiverType 来完成我的任务。我已经在谷歌上搜索了一下,但没有运气。
有人为 Sharepoint 2007 做过这个吗?
I have a list with multiple items. I don't want the user to delete the list when there are items with running workflows. I'm trying to avoid orphaned workflows and get more control over what the user is allowed to do with data in lists.
I've already implemented a part which denies the user to delete a single item with a running workflow by implementing ItemDeleting
/// <summary>
/// Synchronous before event that occurs before an existing item is completely deleted.
/// Business logic related to deleting items. Checks if there are any problems with deleting the list item.
/// If there are any problems with deleting then the event will be cancelled with an error message. Otherwise deletion is allowed
/// </summary>
/// <param name="properties">
/// A Microsoft.SharePoint.SPItemEventProperties object that represents properties of the event handler.
/// </param>
public override void ItemDeleting(SPItemEventProperties properties)
{
SPListItem listItem = properties.ListItem;
foreach (SPWorkflow workflow in listItem.Workflows)
{
if (workflow.InternalState == SPWorkflowState.Running)
{
properties.Cancel = true;
properties.ErrorMessage = "It is not allowed to delete items with running workflows. Complete them before deleting";
}
}
}
Now I want to do the same with the list itself, but there is no SPEventReceiverType available to accomplish my task. I've been googling around a little bit, but no luck.
Has anyone done this for Sharepoint 2007?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论