实现 IAlertUpdateHandler 接口的问题
我在一个类中实现了 IAlertUpdateHandler 接口,并使用它来处理警报的创建和更新。代码被触发,但它通过一次又一次地调用自身而进入无限循环。
实际上我想禁止电子邮件通知,所以我调用 a.Update(false);
但这再次调用 PreUpdate
或 PostUpdate
方法,并且有是 StackOverFlowException :(
我尝试从这两种方法返回 true/false 但没有任何帮助。
I've implemented IAlertUpdateHandler
interface in a class and used it for handling creation and updating of alerts. The code is fired but it goes into endless loop by calling itself again and again.
Actually I want to suppress email notification so I'm calling a.Update(false);
but this again calls PreUpdate
or PostUpdate
method and there isStackOverFlowException
:(
I've tried returning true/false from both the methods but nothing is helping.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据文档,您应该只返回 true 或 false。尝试注释掉 Update 调用并仅返回 true 或 false。如果您调用 Update,您将进入递归循环,并且您的 return 语句将永远不会被评估。
According to the documentation, you're supposed to just return true or false. Try commenting out the Update call and just return either true or false. If you call Update, you'll just go into the recursive loop and your return statement will never get evaluated.
正如我在此处发布的:
我知道这可能有点晚了,但我认为无论如何都可以帮助下一个一。
我找到了这个问题的解决方案/黑客。
我相信,当从 UI 创建警报时,系统会触发 SPAlert.update(),所以我想出的是做类似的事情,但忽略从 UI 调用的更新,为此我向 SPAlert 添加了一个自定义属性财产袋。
我已经测试过,它似乎可以解决问题。
As I posted here:
I know that it might be a bit late for this but I thought put it anyway to help the next one.
I found a solution/hack for this problem.
I beleive that when the alert is created from the UI the system fires an SPAlert.update(), so what I came up with is to do similar but ignore the update called from the UI to do that I added a custom property to the SPAlert property bag.
I have tested and it seems to do the trick.