August 19, 2009 at 8:30 am
My expectation would be that post execute would run once at the end of the package.
It appears to be running once for each component in the control flow.
What event fires only once at the end?
I need to email if a file that was created is smaller than a certain size or if the file doesn't exist, but I only want to do this once. Also if the package has a fatal error I need to check the file status and send this notification, but only once. One problem is we have containers set to force success so the error event can fire repeatedly (this is were we log the errors) so I can't check file status in the on error event because the file creation may not have occurred yet, but don't it in the control flow because a fatal error will prevent that part from running.
August 19, 2009 at 10:22 am
A bit more info on this...
According to microsoft:
"OnPostExecute
The event handler for the OnPostExecute event. This event is raised by an executable immediately after it has finished running."
I put a message box on the post execute event of a sequence container that contained a script task and the event fired twice. When the script task was disabled to post execute event on the container only fired once. I set the propagate variable to false on the script task but it still fired twice.
I guess there is no Last event that fires.
August 19, 2009 at 11:30 am
Keep in mind that the OnPostExecute event can be coded at both the package level and the individual task level. OnPostExecute will fire one last time after the package completes.
To keep things simple, I would code OnPostExecute at the package level, but use a Script Task to determine which task fired the event and execute code only when it's the package itself that fired the event.
For example, I have a package with a number of tasks in the the control flow. I added a Script Task to the package's OnPostExecute event and added "PackageName" and "SourceName" to the Script Task's ReadOnlyVariables property in the script task editor. The code would be something like this:
Public Sub Main()
If Dts.Variables("SourceName").Value.ToString = Dts.Variables("PackageName").Value.ToString Then
' do something
End If
Dts.TaskResult = Dts.Results.Success
End Sub
August 19, 2009 at 12:00 pm
Yes, that will be perfect, thanks for the suggestion. - tom
August 19, 2009 at 12:30 pm
I ended up just using a dummy script component then added a precedence constraint with the expression
@SourceName == @PackageName
This accomplished what I needed. Thanks again.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply