I have a package that sends an email using the OnPostExecute Event Handler. My understanding is that the event is fired once for the package and once for any containers in the package.
I only want to send the email once. Currently I use a variable to count the number of times OnPostExecute is called and only send the email if it is the first time. This is probably not a good long term solution. How can I determine when OnPostExecute is being fired by the package instead of by a container?
Thanks in advance.
Check the SourceName variable. Put a dummy script task in the event handler and put a precedence contraint from the script task to the Send Mail task with the expression "SourceName == PackageName".|||Which just goes to show that I'd like to see container specific events -- meaning child events don't propagate up.|||
Thanks, Jay. Your recommendation solved the problem.
Code Snippet
If (Dts.Variables("PackageName").Value.ToString = Dts.Variables("SourceName").Value.ToString) Then
'Do something
End If
Phil, I agree. That would be nice.
|||Okay, I just want to make sure I was clear that I wasn't recommending that any code go into the Script Task. As I described it, the Script Task is simply there to allow you to set a precedence between the Script Task and the Send Mail Task. You can then put an expression on the contraint (@.PackageName == @.SourceName) and require that the expression evaluate to true for the dependent task to execute. Then your mail would only be sent if the SourceName of the event was the same as the PackageName. Right-click on the green line and click Edit to see these options.
No comments:
Post a Comment