Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » Utilities » Downloads
 
Add your own
alternative version

Load and Execute SSIS Packages in Microsoft Windows

, 26 Mar 2010 CPOL
This article introduces a method to load and execute SSIS packages in Microsoft Windows with a demo WPF application.
CreateSourceAndDestinationForSSISPackage.zip
SSISWindowsLauncher.zip
SampleSSIS
bin
SamplePackage.dtsx
SampleSSIS.database
SampleSSIS.dtproj
SampleSSIS.dtproj.user
SSISWindowsLauncher
bin
Debug
icon_eek.ico
Images
Brittany.jpg
icon_eek.ico
Microsoft.SQLServer.ManagedDTS.dll
obj
Debug
Properties
Settings.settings
SSISWindowsLibrary
bin
Debug
Microsoft.SQLServer.ManagedDTS.dll
obj
Debug
Properties
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;

namespace SSISWindowsLibrary
{
    public class SSISEventListener : Microsoft.SqlServer.Dts.Runtime.DefaultEvents
    {
        private System.Data.DataTable _EventLogTable;
        private int _EventCount;

        public SSISEventListener()
        {
            _EventCount = 0;

            _EventLogTable = new System.Data.DataTable();
            _EventLogTable.Columns.Add("Status", System.Type.GetType("System.Int16"));
            _EventLogTable.Columns.Add("Event Sequence", System.Type.GetType("System.Int16"));
            _EventLogTable.Columns.Add("Time", System.Type.GetType("System.DateTime"));
            _EventLogTable.Columns.Add("SSIS Execution Status", System.Type.GetType("System.String"));
        }

        public int EventCount
        {
            get { return _EventCount; }
        }

        public System.Data.DataTable EventLogTable
        {
            get { return _EventLogTable; }
        }

        public override bool OnError(DtsObject source, int errorCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError)
        {
            _EventCount++;

            string[] LogData = { "2", _EventCount.ToString(), System.DateTime.Now.ToLongTimeString(), description };
            _EventLogTable.Rows.Add(LogData);

            return base.OnError(source, errorCode, subComponent, description, helpFile, helpContext, idofInterfaceWithError);
        }

        public override void OnInformation(DtsObject source, int informationCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError, ref bool fireAgain)
        {
            _EventCount++;

            string[] LogData = { "0", _EventCount.ToString(), System.DateTime.Now.ToLongTimeString(), description };
            _EventLogTable.Rows.Add(LogData);

            base.OnInformation(source, informationCode, subComponent, description, helpFile, helpContext, idofInterfaceWithError, ref fireAgain);
        }

        public override void OnWarning(DtsObject source, int warningCode, string subComponent, string description, string helpFile, int helpContext, string idofInterfaceWithError)
        {
            _EventCount++;

            string[] LogData = { "1", _EventCount.ToString(), System.DateTime.Now.ToString(), description };
            _EventLogTable.Rows.Add(LogData);

            base.OnWarning(source, warningCode, subComponent, description, helpFile, helpContext, idofInterfaceWithError);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Dr. Song Li

United States United States
I have been working in the IT industry for some time. It is still exciting and I am still learning. I am a happy and honest person, and I want to be your friend.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150331.1 | Last Updated 26 Mar 2010
Article Copyright 2010 by Dr. Song Li
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid