本文介绍了SQL Server Integration Services (SSIS) - 捕获用户停止的调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我在 SQL Server SSIS 解决方案中实现的自定义审核框架,我需要在调试停止时进行记录.

For a custom audit framework that I am implementing in a SQL Server SSIS solution, I need to log when debugging stops.

据我所知,有3种可能的情况:1. 发生了致命错误(即不会忽略或允许发生然后单独处理).2. 执行成功.3. 由于崩溃或用户停止(即停止按钮,shift + f5)导致调试停止.

As far as I can tell, there are 3 possible situations:1. An error is occured that is fatal (i.e. it is not ignored or allowed to occur to then be handled separately).2. Execution finishes succesfully.3. Debugging stops due to a crash or user stopping (i.e. the STOP button, shift + f5).

1 和 2 我可以分别处理事件处理程序和任务.但是,我似乎找不到在调试因用户取消或系统关闭而停止时触发的事件(这可能是 2 个不同的类别).

1 and 2 I can handle with an event handler and task respectively. However, I can't seem to find an event that is triggered when debugging stops due to user cancelling or system shut down (these are possibly 2 separate categories).

任何人都可以建议我如何在稍后阶段捕获或处理它们.

Can anyone advise how I can catch these or process them at a later stage.

谢谢,亚当

推荐答案

您可以尝试挂钩 OnQueryCancel 事件.正如文档所述

You could try hooking the OnQueryCancel event. As the docs state

OnQueryCancel 事件的事件处理程序.此事件由可执行文件引发,以确定它是否应停止运行.

有趣(和棘手)的地方在于 OnQueryCancel 事件会在整个包执行过程中引发.基本上,它在将脸放回水中之前先吸一口气.因此,您需要检查仅存在于 OnQueryCancel 事件处理程序范围内的系统变量 Cancel 是否设置为 true.

Where this gets fun (and tricky) is that the OnQueryCancel event is raised throughout the package execution. Basically, it's taking a breath before putting its face back in the water. So, you'll need to check whether the system Variable Cancel, which only exists in the OnQueryCancel event handler scope, is set to true.

在我的 POC 中,我将脚本任务的 Disabled 属性上的表达式设置为 !@[System::Cancel] 并且这似乎工作正常.当我没有单击取消时,它停止显示我的消息框.不幸的是,当我点击停止调试"

In my POC, I set the expression on the Disabled property for my Script Task to be !@[System::Cancel] and that seemed to work fine. It stopped displaying my message box when I hadn't clicked Cancel. Unfortunately, it also didn't show the message box when I did click "Stop Debugging"

我需要结束这一天,今晚我会重新审视这个,但我想我会给你一个答案的开头,希望能把你推向正确的方向

I need to wrap up for the day and will revisit this tonight but thought I'd leave you with the beginning of an answer which hopefully shoves you in the right direction

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/6d7ad9d7-9889-4b1d-859b-8fa6d281e63f/what-does-the-onquerycancel-event-do

这篇关于SQL Server Integration Services (SSIS) - 捕获用户停止的调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-02 16:19