Exemplo n.º 1
0
        public ProgramVariable(SsisObject o, bool as_global)
        {
            // Figure out what type of a variable we are
            DtsType = o.GetChildByType("DTS:VariableValue").Attributes["DTS:DataType"];
            CSharpType = null;
            DefaultValue = o.GetChildByType("DTS:VariableValue").ContentValue;
            Comment = o.Description;
            Namespace = o.Properties["Namespace"];
            IsGlobal = as_global;
            VariableName = o.DtsObjectName;

            // Here are the DTS type codes I know
            if (DtsType == "3") {
                CSharpType = "int";
            } else if (DtsType == "8") {
                CSharpType = "string";
                if (!String.IsNullOrEmpty(DefaultValue)) {
                    DefaultValue = "\"" + DefaultValue.Replace("\\","\\\\").Replace("\"","\\\"") + "\"";
                }
            } else if (DtsType == "13") {
                CSharpType = "DataTable";
                DefaultValue = "new DataTable()";
            } else if (DtsType == "2") {
                CSharpType = "short";
            } else if (DtsType == "11") {
                CSharpType = "bool";
                if (DefaultValue == "1") {
                    DefaultValue = "true";
                } else {
                    DefaultValue = "false";
                }
            } else if (DtsType == "20") {
                CSharpType = "long";
            } else if (DtsType == "7") {
                CSharpType = "DateTime";
                if (!String.IsNullOrEmpty(DefaultValue)) {
                    DefaultValue = "DateTime.Parse(\"" + DefaultValue + "\")";
                }
            } else {
                SourceWriter.Help(o, "I don't understand DTS type " + DtsType);
            }
        }
Exemplo n.º 2
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(AppFolder, 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);
                }
            }
        }