Пример #1
0
        public void Save()
        {
            string templatePath = PathManager.GetToolSubpath(Settings.Default.SubpathSsis2008EmitterContent);

            this._projectXmlDocument.Load(PathManager.AddSubpath(templatePath, Settings.Default.SubpathDTProjectTemplateFile));
            XPathNavigator templateNav = _projectXmlDocument.CreateNavigator().SelectSingleNode("//Project");

            templateNav.SelectSingleNode("Database").AppendChildElement("", "Name", "", "placeholder.database");
            templateNav.SelectSingleNode("Database").AppendChildElement("", "FullPath", "", "placeholder.database");

            XPathNavigator packageNav = templateNav.SelectSingleNode("DTSPackages");

            packageNav.PrependChildElement("", "DtsPackage", "", "");
            packageNav.MoveToFirstChild();
            packageNav.AppendChildElement("", "Name", "", String.Format("{0}.{1}", _package.Name, Resources.ExtensionDTSXPackageFile));
            packageNav.AppendChildElement("", "FullPath", "", String.Format("{0}.{1}", _package.Name, Resources.ExtensionDTSXPackageFile));
            packageNav.AppendChildElement("", "References", "", "");

            XPathNavigator miscFilesNav = templateNav.SelectSingleNode("Miscellaneous");

            foreach (string s in _miscFiles)
            {
                miscFilesNav.PrependChildElement("", "ProjectItem", "", "");
                miscFilesNav.MoveToFirstChild();
                miscFilesNav.AppendChildElement("", "Name", "", s);
                miscFilesNav.AppendChildElement("", "FullPath", "", s);
                miscFilesNav.MoveToParent();
            }

            _projectXmlDocument.Save(Path.ChangeExtension(_package.PackagePath, Resources.ExtensionDTProjectFile));
        }
Пример #2
0
        public SsisProject AddPackage(Package package)
        {
            if (!_projectDirectoryMappings.ContainsKey(package.PackageFolder))
            {
                string projectName   = package.PackageFolderSubpath ?? package.Name;
                string projectFolder = package.PackageFolder;
                string projectPath   = PathManager.AddSubpath(projectFolder, String.Format(CultureInfo.CurrentCulture, "{0}.{1}", projectName, Resources.ExtensionDTProjectFile));
                _projectDirectoryMappings.Add(package.PackageFolder, new SsisProject(projectPath));
            }

            SsisProject ssisProject = _projectDirectoryMappings[package.PackageFolder];

            ssisProject.Packages.Add(package);
            return(ssisProject);
        }
Пример #3
0
        public SSISEmitterContext Emit()
        {
            string dtsConfigHeader   = @"<DTSConfiguration>
                                    <DTSConfigurationHeading><DTSConfigurationFileInfo /></DTSConfigurationHeading>";
            string dtsPropertyConfig = @"<Configuration ConfiguredType=""Property"" Path=""\Package.Connections[{0}].Properties[{1}]"" ValueType=""String"">
                                            <ConfiguredValue>{2}</ConfiguredValue>
                                         </Configuration>";
            string dtsConfigFooter   = "</DTSConfiguration>";

            string configDirectory = PathManager.GetTargetSubpath(Settings.Default.SubpathPackageConfigurationProjectLocation);
            string configFile      = PathManager.AddSubpath(configDirectory, String.Format("{0}.{1}", _name, Resources.ExtensionDtsConfigurationFile));

            // Need to create the Target Directory :)
            Directory.CreateDirectory(configDirectory);
            using (StreamWriter sw = new StreamWriter(configFile, false, Encoding.Unicode))
            {
                sw.Write(dtsConfigHeader);
                sw.Write(dtsPropertyConfig, _name, "ConnectionString", _connectionString);
                sw.Write(dtsConfigFooter);
            }
            return(_context);
        }
Пример #4
0
        public override void Emit(SsisEmitterContext context)
        {
            Initialize(context);

            if (!ReusedExisting)
            {
                string connectionString = ConnectionString;

                ConnectionManager.ConnectionString = connectionString;
                SetProperty("RetainSameConnection", RetainSameConnection);

                // Need to unwind this and split it out logically.
                const string DtsConfigHeader   = @"<DTSConfiguration>
                                    <DTSConfigurationHeading><DTSConfigurationFileInfo /></DTSConfigurationHeading>";
                const string DtsPropertyConfig = @"<Configuration ConfiguredType=""Property"" Path=""\Package.Connections[{0}].Properties[{1}]"" ValueType=""String"">
                                            <ConfiguredValue>{2}</ConfiguredValue>
                                         </Configuration>";
                const string DtsConfigFooter   = "</DTSConfiguration>";

                string configDirectory = PathManager.GetTargetSubpath(Properties.Settings.Default.SubpathPackageConfigurationProjectLocation);
                string configFile      = PathManager.AddSubpath(configDirectory, String.Format(CultureInfo.InvariantCulture, "{0}.{1}", Name, Properties.Resources.ExtensionDtsConfigurationFile));

                // Need to create the Target Directory :)
                Directory.CreateDirectory(configDirectory);
                using (var sw = new StreamWriter(configFile, false, Encoding.Unicode))
                {
                    sw.Write(DtsConfigHeader);
                    sw.Write(DtsPropertyConfig, Name, "ConnectionString", OriginalConnectionString);
                    sw.Write(DtsConfigFooter);
                    sw.Flush();
                    sw.Close();
                }

                var pc = new PackageConfiguration(Name);
                pc.Emit(context);
            }
        }