我有一个插件的活动。
在预创建i检查几个条件,如果我得到真,所以我抛出OperationCanceledException停止创建执行。
但是记录被保存了,为什么?如何取消创建?也试图抛出InvalidPluginExecutionException,但它仍然被执行。
代码:
public void Execute(IPluginExecutionContext context)
{
try
{
switch (context.MessageName)
{
case "Create":
if (context.Stage == MessageProcessingStage.BeforeMainOperationOutsideTransaction)
{
bool shouldnotcreateactivity = Create(context, service);
if (shouldnotcreateactivity)
throw new OperationCanceledException();
}
if (context.OutputParameters.Properties.Contains("id"))
{
//continue...
}
break;
}
}
catch (OperationCanceledException cancled)
{
}
catch (InvalidPluginExecutionException invalid)
{
}
catch (SoapException ex)
{
}
catch (Exception ex)
{
}
}
听起来你好像做错了什么。您可能应该发布一些与活动
的预检查和保存相关的代码。你应该有一些像下面这样的逻辑…
if(ValidateActivity()){
CreateAndSaveActivity();
}
else
throw execption;