Isaiah Nelson
Isaiah Nelson

Reputation: 2490

Execute SSIS Package from C# and know when it's finished?

I need to be able to execute an SSIS package from a .NET program and know when it's finished. Most of my jobs that my packages fire on can take anywhere from 2 minutes to 9 hours. Why I need to know when I job completes is because I can only run 1 job at a time. Since scheduling is of importance here, is there an OnSuccess or OnFailure event that the finishing package can raise?

Note: I already have some minor event handling on events such as OnError, but the PackageEventListener class I am writing inherits from DefaultEvents, and DefaultEvents doesn't define an OnSucess or OnFailure event.

Upvotes: 3

Views: 1837

Answers (1)

Adil B
Adil B

Reputation: 16866

One approach is to use the System.Diagnostics.Process class to execute an SSIS package from within a batch file.

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx

The System.Diagnostics.Process class has a method called WaitForExit() which will wait for its launched process to exit before continuing and then will return its return code.

Here is a list of the return codes to look for from an SSIS package: http://msdn.microsoft.com/en-us/library/ms162810.aspx

Upvotes: 1

Related Questions