April 26, 2012

SQLSaturday #130 Presentation

/*******************************************************************
 *
 * Jorge Novo
 * SQLSaturday SSIS Demostration
 * jorge.novo@gmail.com
 * http://etldevelopernotes.blogspot.com/
 * 4/27/2012
 *
 * Package to demostrate an empty ssis package
 *
 * Class 1- 7
 *
 *
 *
 * *****************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.SqlServer.Dts.Runtime;


namespace SQLSaturday130
{
    public class Demo1 : IDisposable
    {
        protected Package myPackage = new Package();
        const String SaveLocation = @"c:\\temp";

        public void CreatePackage()
        {
        
            using (myPackage = new Package())
            {
                myPackage.Name = "Demo1_EmptyPackage";
              
               SavePackage(SaveLocation);

            }
        }
        public Package GetSetPackage
        {
            get { return myPackage; }
            set { myPackage = value; }

        }
        public String PackageName
        {
            set { myPackage.Name = value; }
        }
     
        private void SavePackage(String DirectoryPath)
        {
            String FullFilePath = DirectoryPath + "\\" + myPackage.Name.ToString() + ".dtsx";
            if (File.Exists(FullFilePath))
            {
              
                File.Delete(FullFilePath);
                Application app = new Application();
                app.SaveToXml(FullFilePath, myPackage, null);
              
            }
            else
            {
                Application app = new Application();
                app.SaveToXml(FullFilePath,myPackage, null);
              
            }
        }
        protected void Dispose(bool disposing)
        {
            if (disposing)
            {
                // dispose managed resources
                myPackage.Dispose();
            }
            // free native resources
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }
}

No comments:

Post a Comment

Contact Form

Name

Email *

Message *