를 취소할 수 없으며 삭제 목록 항목에 이벤트가 수신기 ItemDeleting 방법에 CMSPUBLISHINGSITE#2
-
18-09-2019 - |
문제
를 사용하여 SharePoint2010RC 내가 문제가 발생하는 이유는 취소하면 삭제 목록 항목을 사용하여 이벤트를 수 있습니다.내 코드 발포,설정하기 취소 시설의 SPItemEventProperties,설정은 오류 메시지,및 던지고는 오류를 호출하는 스레드가 있습니다.이 방식에서 잘 작동 추가/업데이트 방법,그러나,에서 사용하는 경우 삭제하는 방법을 내가 볼 수 있는 코드를 화재에 디버거나,항목은 여전히 이 사이트의 재활용 bin.
추가로,저는 이것을 보고 행동에 사이트에서 작성된"CMSPUBLISHINGSITE#2"템플릿에서 명령하지만에서는 사이트에서 생성된"팀 사이트"템플릿 중앙 관리를 통해.
오작동 코드를 따른다:
public override void ItemDeleting(SPItemEventProperties properties)
{
if (!(properties.UserLoginName == "SHAREPOINT\\system"))
{
try
{
throw new CreatorIdAliasingException("Please contact support if you feel a release web site has been inappropriately assigned to your organization.");
}
catch (CreatorIdAliasingException ex)
{
properties.Cancel = true;
properties.ErrorMessage = ex.ToString();
properties.InvalidateListItem();
throw;
}
}
}
참조용,동일한 코드가 포함된려면 itemadding 방법 및 예상대로 작동합니다.
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
if (!(properties.UserLoginName == "SHAREPOINT\\system"))
{
try
{
throw new InvalidCreatorIdException("Please contact support to add a known URL to your list of release web sites.");
}
catch (InvalidCreatorIdException ex)
{
properties.Cancel = true;
properties.ErrorMessage = ex.ToString();
properties.InvalidateListItem();
throw;
}
}
}
해결책
나는 것이 좋습니다 당신을 사용하지 않는 예외의 일부로 귀하의 비즈니스 논리입니다.예외는 비싼만 사용해야 합 예외적인 경우에는 처리하지 않으로 정상적인 논리입니다.
대신 다음과 같은 코드를 사용하면 됩니다:
public override void ItemDeleting(SPItemEventProperties properties)
{
if (properties.UserLoginName.ToLower().CompareTo("sharepoint\\system") != 0)
{
properties.Cancel = true;
properties.ErrorMessage = "Some error has occured....";
}
}
그리고,그런 식으로,당신은 당신을 던지고 있는 추가적인 예외 이벤트에서 핸들러는 아마 이유는 동작이 표시됩니다.
제휴하지 않습니다 StackOverflow