SQL Server Integration Services (SSIS) - Catch User-Stopped Debugging

六月ゝ 毕业季﹏ 提交于 2020-01-04 10:49:24

问题


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

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 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.

Thanks, Adam


回答1:


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

The event handler for the OnQueryCancel event. This event is raised by an executable to determine whether it should stop running.

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.

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



来源:https://stackoverflow.com/questions/26136824/sql-server-integration-services-ssis-catch-user-stopped-debugging

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!