如何阻止该项目发布?

时间:2013-04-24 07:30:44

标签: sharepoint sharepoint-2013

我有一个事件记录器,用于具有以下方法的项目更新:

public override void ItemUpdated(SPItemEventProperties properties)
        {
            base.ItemUpdated(properties);

            if (!HandleEvent(properties))
            {
                return;
            }

            var item = properties.ListItem;

            EventFiringEnabled = false;

            if (IsPublished(item))
            {       

            }

            EventFiringEnabled = true;

} 

以下是IsPublished的方法:

private bool IsPublished(SPListItem item)
{
    return item.Level == SPFileLevel.Published;

}

我需要将其停止发布,我该怎么办呢?

1 个答案:

答案 0 :(得分:1)

public override void ItemCheckingIn(SPFeatureReceiverProperties properties)
{
  base.ItemCheckingIn(properties);
  //Major Version
  if(..){
   properties.Cancel = true;
   properties.ErrorMessage = "you cannot publish!";
  }

 }