不允许用户删除 Sharepoint 2007 中的列表

发布于 2024-09-12 16:43:51 字数 1251 浏览 4 评论 0原文

我有一个包含多个项目的列表。当存在正在运行工作流程的项目时,我不希望用户删除列表。我试图避免孤立的工作流程,并更好地控制用户可以对列表中的数据执行的操作。

我已经实现了一个部分,通过实现 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文