Ejemplo n.º 1
0
 /// <summary>
 /// Write all variables to file
 /// </summary>
 /// <param name="variables"></param>
 private static void WriteVariables(IEnumerable <SsisObject> variables)
 {
     SourceWriter.WriteLine(@"***");
     // Write each variable out as if it's a global
     SourceWriter.WriteLine(@"Variables".ToMarkdownSubHeader());
     foreach (SsisObject v in variables)
     {
         v.EmitVariable("        ", true);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Write all ConnectionManagers to file
        /// </summary>
        /// <param name="conns"></param>
        private static void WriteConnectionManagers(IEnumerable <SsisObject> conns)
        {
            SourceWriter.WriteLine(@"***");
            SourceWriter.WriteLine(@"ConnectionsManagers".ToMarkdownSubHeader());

            // Write each Conection String
            foreach (SsisObject connstr in conns)
            {
                string connString   = "Not Found";
                string creationName = "Not Found";
                string DtsId        = connstr.DtsId.ToString();
                string description  = "Not Found";
                //string connObject = "Not Found";

                SourceWriter.WriteLine(String.Format(@"* **{0}**", connstr.DtsObjectName));
                connstr.Properties.TryGetValue("CreationName", out creationName);
                connstr.Properties.TryGetValue("Description", out description);

                var v = connstr.GetChildByType("DTS:ObjectData");
                if (v != null)
                {
                    // Look for a SQL Connection string
                    var v2 = v.GetChildByType("DTS:ConnectionManager");
                    if (v2 != null)
                    {
                        v2.Properties.TryGetValue("ConnectionString", out connString);
                        // If not, look for an SMTP connection string
                    }
                    else
                    {
                        v2 = v.GetChildByType("SmtpConnectionManager");
                        if (v2 != null)
                        {
                            v2.Attributes.TryGetValue("ConnectionString", out connString);
                        }
                        else
                        {
                            Console.WriteLine("Help");
                        }
                    }
                }

                SourceWriter.WriteLine();

                var data = new[]
                {
                    new { Name = "Connection String", Value = connString },
                    new { Name = "Creation Name", Value = creationName },
                    new { Name = "DtsId", Value = DtsId },
                    new { Name = "Description", Value = description }
                };

                SourceWriter.WriteLine(data.ToMarkdownTable());
            }
        }
Ejemplo n.º 3
0
        public static void EmitScriptProject(SsisObject o, string indent)
        {
            // Find the script object child
            var script = o.GetChildByType("DTS:ObjectData").GetChildByType("ScriptProject");

            // Create a folder for this script
            string project_folder = Path.Combine("C://SSIS//Scripts", o.GetFolderName());

            Directory.CreateDirectory(project_folder);

            // Extract all the individual script files in this script
            foreach (SsisObject child in script.Children)
            {
                string fn  = project_folder + child.Attributes["Name"];
                string dir = Path.GetDirectoryName(fn);
                Directory.CreateDirectory(dir);

                if (child.DtsObjectType == "BinaryItem")
                {
                    byte[] contents = System.Convert.FromBase64String(child.ContentValue);
                    File.WriteAllBytes(fn, contents);
                }
                else if (child.DtsObjectType == "ProjectItem")
                {
                    File.WriteAllText(fn, child.ContentValue);
                }

                // Handle DLL files specially - they are binary!  Oh yeah base64 encoded
                if (fn.EndsWith(".dll"))
                {
                    DllFiles.Add(fn);

                    // Note this as a potential problem
                    SourceWriter.Help(o, "The Visual Basic project " + child.Attributes["Name"] + " was embedded in the DTSX project.  Visual Basic code cannot be automatically converted.");

                    // Show the user that this is how the script should be executed, if they want to fix it
                    SourceWriter.WriteLine(@"{0}//{1}.ScriptMain sm = new {1}.ScriptMain();", indent, Path.GetFileNameWithoutExtension(fn).Replace("scripttask", "ScriptTask"));
                    SourceWriter.WriteLine(@"{0}//sm.Main();", indent);

                    // Is this a project file?
                }
                else if (fn.EndsWith(".vbproj") || fn.EndsWith(".csproj"))
                {
                    ProjectFiles.Add(fn);
                }
                else
                {
                    AllFiles.Add(fn);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Write a program file that has all the major executable instructions as functions
        /// </summary>
        /// <param name="variables"></param>
        /// <param name="functions"></param>
        /// <param name="p"></param>
        private static void WriteDocumentation(SsisObject o, IEnumerable <SsisObject> variables, IEnumerable <SsisObject> connstrings, IEnumerable <SsisObject> functions, string filename)
        {
            //Get Package Creator Name
            var creatorName = "CreatorName - " + o.Properties["CreatorName"];

            //Get Version GUID
            string versionGuid = "VersionGUID - " + o.Properties["VersionGUID"];

            //Get Package Name
            var packageName = o.DtsObjectName + ".dtsx";

            //var packageName = "PackageName - " + o.DtsObjectName;

            using (SourceWriter.SourceFileStream = new StreamWriter(filename, false, Encoding.UTF8))
            {
                SourceWriter.WriteLine(packageName.ToMarkdownHeader());
                SourceWriter.WriteLine(creatorName.ToMarkdownSubHeader());
                SourceWriter.WriteLine(versionGuid.ToMarkdownSubHeader());

                WriteVariables(variables);
                WriteConnectionManagers(connstrings);

                SourceWriter.WriteLine(@"");
                SourceWriter.WriteLine(@"");
                //Write each executable out as a function
                SourceWriter.WriteLine(@"Executables".ToMarkdownSubHeader());

                SourceWriter.WriteLine(@"* #### Root Level Executables");
                foreach (SsisObject v in functions)
                {
                    SourceWriter.WriteLine(@"   * {0}", v.DtsObjectName);
                    SourceWriter.WriteLine(@"       * {0}", v.Description);
                }

                SourceWriter.WriteLine(@"* #### Executable Flows");
                foreach (SsisObject v in functions)
                {
                    v.EmitFunctionsAsSequence("\t", new List <ProgramVariable>());
                }

                SourceWriter.WriteLine(@"* #### Executables");
                foreach (SsisObject v in functions)
                {
                    v.EmitFunction("\t", new List <ProgramVariable>());
                }
            }
        }