Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 实现IAlertUpdateHandler接口时出现的问题_Sharepoint_Email_Alerts_Sharepoint Alerts - Fatal编程技术网

Sharepoint 实现IAlertUpdateHandler接口时出现的问题

Sharepoint 实现IAlertUpdateHandler接口时出现的问题,sharepoint,email,alerts,sharepoint-alerts,Sharepoint,Email,Alerts,Sharepoint Alerts,我在一个类中实现了IAlertUpdateHandler接口,并使用它来处理警报的创建和更新。代码被触发,但它通过一次又一次地调用自身进入无止境的循环 实际上,我想抑制电子邮件通知,所以我调用a.Update(false)但这会再次调用PreUpdate或postapdate方法,并且 StackOverFlowException:( 我尝试从这两个方法返回true/false,但没有任何帮助。根据,您应该只返回true或false。尝试注释更新调用,只返回true或false。如果调用Upda

我在一个类中实现了
IAlertUpdateHandler
接口,并使用它来处理警报的创建和更新。代码被触发,但它通过一次又一次地调用自身进入无止境的循环

实际上,我想抑制电子邮件通知,所以我调用
a.Update(false)
但这会再次调用
PreUpdate
postapdate
方法,并且
StackOverFlowException
:(

我尝试从这两个方法返回true/false,但没有任何帮助。

根据,您应该只返回true或false。尝试注释更新调用,只返回true或false。如果调用Update,您将进入递归循环,并且您的return语句将永远不会得到计算。

1

我知道这可能有点晚了,但我想还是把它放在一边,以帮助下一个

我找到了解决这个问题的方法

我相信,当从UI创建警报时,系统会触发一个SPAlert.update(),因此我想到的是执行类似的操作,但忽略从UI调用的更新,以便在SPAlert属性包中添加一个自定义属性

public bool PreUpdate(SPAlert a, SPWeb web, bool newAlert, string properties)
{
    if (CHECK_IF_SUPPRESSING_EMAIL && !a.Properties.ContainsKey("CustomUpdate"))
    {
        //add a property to identify this update
        a.Properties.Add("CustomUpdate", ""); //can be called anything :)
        a.Update(false);
        //return false to ignore the update sent by the UI
        return false;
    }
    else 
    {
       //no changes here proceed with custom behaviour
       return true;
    }

}
我已经测试过了,它似乎做到了这一点,希望这对某人有所帮助:)

@Hirvox它说的是一个布尔值,可以用来阻止更新或抛出SPException。我不想阻止更新,只是为了抑制订阅创建的电子邮件。