Exemple #1
0
        public string Emit(Table table)
        {
            string sConstraints = new ConstraintsBuilder(table).BuildConstraints();
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("CreateTable",table.Name,new ColumnsBuilder(table, sConstraints.Length > 0).Build(),sConstraints);

            StringBuilder sTable = new StringBuilder(te.Emit(table));
            sTable.Append(new ConstraintsBuilder(table).BuildForeignKeyConstraints());
            sTable.Append(new IndexesBuilder(table.Indexes).Build());
            sTable.Append(new InsertDefaultValuesEmitter().Emit(table));
            return sTable.ToString();
        }
Exemple #2
0
        public string Emit(Table table)
        {
            string sConstraints        = new ConstraintsBuilder(table).BuildConstraints();
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("CreateTable", table.Name, new ColumnsBuilder(table, sConstraints.Length > 0).Build(), sConstraints);

            StringBuilder sTable = new StringBuilder(te.Emit(table));

            sTable.Append(new ConstraintsBuilder(table).BuildForeignKeyConstraints());
            sTable.Append(new IndexesBuilder(table.Indexes).Build());
            sTable.Append(new InsertDefaultValuesEmitter().Emit(table));
            return(sTable.ToString());
        }
Exemple #3
0
        public string Emit(string tableName, string columns, string where)
        {
            TemplatePlatformEmitter teSelect = new TemplatePlatformEmitter("SimpleSelect", columns, tableName);
            StringBuilder           sSelect  = new StringBuilder(teSelect.Emit(null));

            if (!string.IsNullOrEmpty(where))
            {
                TemplatePlatformEmitter teWhere = new TemplatePlatformEmitter("SimpleWhere", where);
                sSelect.Append(teWhere.Emit(null));
            }

            return(sSelect.ToString());
        }
Exemple #4
0
        public string Emit(string tableName, string columns, string where)
        {
            TemplatePlatformEmitter teSelect = new TemplatePlatformEmitter("SimpleSelect", columns, tableName);
            StringBuilder sSelect = new StringBuilder(teSelect.Emit(null));

            if (!string.IsNullOrEmpty(where))
            {
                TemplatePlatformEmitter teWhere = new TemplatePlatformEmitter("SimpleWhere", where);
                sSelect.Append(teWhere.Emit(null));
            }

            return sSelect.ToString();
        }
Exemple #5
0
        private void Append(string tableName, Index index)
        {
            string unique = index.Unique ? "UNIQUE" : "";
            string clustered = index.Clustered ? "CLUSTERED" : "NONCLUSTERED";
            string dropExisting = index.DropExisting ? "DROP_EXISTING = ON" : "DROP_EXISTING = OFF";
            string ignoreDupKey = index.IgnoreDupKey ? "IGNORE_DUP_KEY = ON" : "IGNORE_DUP_KEY = OFF";
            string online = index.Online ? "ONLINE = ON" : "ONLINE = OFF";
            string padIndex = index.Online ? "PAD_INDEX = ON" : "PAD_INDEX = OFF";
            string sortInTempdb = index.SortInTempdb ? "SORT_IN_TEMPDB = ON" : "SORT_IN_TEMPDB = OFF";
            string sProperties = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0},\n{1},\n{2},\n{3},\n{4}", padIndex, sortInTempdb, dropExisting, ignoreDupKey, online);
            string kName;
            string keys = new KeysBuilder(index.Keys).Build(index.Name, out kName);

            TemplatePlatformEmitter te = new TemplatePlatformEmitter("CreateIndex", unique, clustered, kName, tableName, keys, sProperties, string.Empty);
            _stringBuilder.Append(te.Emit(index));
            _stringBuilder.Append(NEWLINE);
        }
Exemple #6
0
        public string LogStart(SequenceTask logContainer, string packageName, string taskName, string varScopeXML)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogStart", packageName, taskName, varScopeXML);

            return(te.Emit(logContainer));
        }
        public static PhysicalTask.SequenceTask Lower(this AstTask.AstStagingContainerTaskNode astNode)
        {
            if (astNode.AsClassOnly)
            {
                return null;
            }

            try
            {
                TSQLEmitter.TemplatePlatformEmitter createStagingTemplate =
                    new Ssis2008Emitter.Emitters.TSQL.PlatformEmitter.TemplatePlatformEmitter("CreateStagingTable", astNode.Table.Name, astNode.CreateAs);

                IR.TSQL.Table table = astNode.Table.Lower();
                table.Indexes.IndexList.Clear();
                //table.ConstraintList.Clear();
                if (astNode.UseStaticSource == false)
                {
                    table.DefaultValues.DefaultValueList.Clear();
                }
                foreach (string s in astNode.DropConstraints)
                {
                    for (int i = 0; i < table.ConstraintList.Count; i++)
                    {
                        if (String.Compare(s.Trim(), table.ConstraintList[i].Name.Trim(), true) == 0)
                        {
                            table.ConstraintList.RemoveAt(i);
                            break;
                        }
                    }
                }

                foreach (IR.TSQL.Constraint constraint in table.ConstraintList)
                {
                    constraint.Name = String.Format("{0}_{1}", astNode.CreateAs, constraint.Name);
                }
                table.ForeignKeyConstraintList.Clear();
                table.Name = astNode.CreateAs;
                table.ConnectionConfiguration = astNode.StagingConnection.Lower();


                AstTask.AstExecuteSQLTaskNode createStagingTask = new VulcanEngine.IR.Ast.Task.AstExecuteSQLTaskNode();

                createStagingTask.ParentASTNode = astNode;
                createStagingTask.Connection = astNode.StagingConnection;
                AddConnection(astNode.StagingConnection);
                createStagingTask.ExecuteDuringDesignTime = true;
                createStagingTask.Name = astNode.Name;
                //createStagingTask.Type = VulcanEngine.IR.Ast.Task.ExecuteSQLTaskType.Expression;
                createStagingTask.Type = VulcanEngine.IR.Ast.Task.ExecuteSQLTaskType.File;
                //createStagingTask.Body = String.Format("\"{0}\"", createStagingTemplate.Emit(null));
                createStagingTask.Body = new TSQLEmitter.TablePlatformEmitter().Emit(table);

                TSQLEmitter.TemplatePlatformEmitter dropStagingTemplate =
                    new Ssis2008Emitter.Emitters.TSQL.PlatformEmitter.TemplatePlatformEmitter("DropStagingTable", astNode.CreateAs);

                AstTask.AstExecuteSQLTaskNode truncateStagingTask = new VulcanEngine.IR.Ast.Task.AstExecuteSQLTaskNode();

                truncateStagingTask.ParentASTNode = astNode;
                truncateStagingTask.Connection = astNode.StagingConnection;
                truncateStagingTask.ExecuteDuringDesignTime = false;
                truncateStagingTask.Name = astNode.Name;
                truncateStagingTask.Type = VulcanEngine.IR.Ast.Task.ExecuteSQLTaskType.Expression;
                truncateStagingTask.Body = String.Format("\"{0}\"", dropStagingTemplate.Emit(null));

                astNode.Tasks.Insert(0, createStagingTask);
                astNode.Tasks.Add(truncateStagingTask);
                return ((AstTask.AstContainerTaskNode)astNode).Lower();
            }
            catch (Exception e)
            {
                throw new SSISEmitterException(astNode, e);
            }
        }
Exemple #8
0
        public string LogSetValue(SequenceTask logContainer, string logIDName, string pathVariable, string nameVariable, string value)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogSetValue", logIDName, pathVariable, nameVariable, value);

            return(te.Emit(logContainer));
        }
Exemple #9
0
        private void Append(ForeignKeyConstraint constraint)
        {
            string strConstraintName;

            if (String.IsNullOrEmpty(constraint.Name) || !constraint.Name.StartsWith("FK_"))
            {
                strConstraintName = String.Format(System.Globalization.CultureInfo.InvariantCulture, "FK_{0}_{1}", constraint.Parent.Name, constraint.Name);
            }
            else
            {
                strConstraintName = constraint.Name;
            }

            if (strConstraintName.Length >= 128)
            {
                strConstraintName = strConstraintName.Substring(0, 127);
            }

            TemplatePlatformEmitter te = new TemplatePlatformEmitter(
                "ForeignKeyConstraintTemplate",
                constraint.Parent.Name,
                strConstraintName,
                new KeysBuilder(constraint.LocalColumnList).BuildForeignKeys(),
                constraint.Table,
                new KeysBuilder(constraint.ForeignColumnList).BuildForeignKeys()
            );
            _stringBuilder.Append(te.Emit(constraint));
            _stringBuilder.Append(NEWLINE);
        }
Exemple #10
0
        public string Emit(StoredProc storedProc)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("StoredProc", storedProc.Name, new StoredProcColumnsBuilder(storedProc.Columns).Build(), storedProc.Body);

            return(te.Emit(storedProc));
        }
Exemple #11
0
 public string LogEnd(SequenceTask logContainer, string logIDName)
 {
     TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogEnd", logIDName);
     return te.Emit(logContainer);
 }
Exemple #12
0
 public string LogSetValue(SequenceTask logContainer, string logIDName, string pathVariable, string nameVariable, string value)
 {
     TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogSetValue", logIDName, pathVariable, nameVariable, value);
     return te.Emit(logContainer);
 }
Exemple #13
0
 public string LogPrepareToSetValue(SequenceTask logContainer)
 {
     TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogPrepareToSetValue");
     return te.Emit(logContainer);
 }
Exemple #14
0
 public string LogGetPredefinedValues(SequenceTask logContainer)
 {
     TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogGetPredefinedValues");
     return te.Emit(logContainer);
 }
Exemple #15
0
 public string LogStart(SequenceTask logContainer, string packageName, string taskName, string varScopeXML)
 {
     TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogStart", packageName, taskName, varScopeXML);
     return te.Emit(logContainer);
 }
Exemple #16
0
        public string LogGetPredefinedValues(SequenceTask logContainer)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogGetPredefinedValues");

            return(te.Emit(logContainer));
        }
Exemple #17
0
        public string LogPrepareToSetValue(SequenceTask logContainer)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogPrepareToSetValue");

            return(te.Emit(logContainer));
        }
Exemple #18
0
        private void AppendConstraintBase(IndexBase constraint, string primaryKeyString, string unique)
        {
            string clustered = constraint.Clustered ? "CLUSTERED" : "NONCLUSTERED";
            string ignoreDupKey = constraint.IgnoreDupKey ? "IGNORE_DUP_KEY = ON" : "IGNORE_DUP_KEY = OFF";
            string padIndex = constraint.PadIndex ? "PAD_INDEX = ON" : "PAD_INDEX = OFF";
            string kName;
            string keys = new KeysBuilder(constraint.Keys).Build(constraint.Name, out kName);

            TemplatePlatformEmitter te = new TemplatePlatformEmitter("ConstraintTemplate", kName, unique + clustered, keys, "WITH(" + padIndex + "," + ignoreDupKey + ")", primaryKeyString);
            _stringBuilder.Append(te.Emit(constraint));
        }
Exemple #19
0
        public string LogEnd(SequenceTask logContainer, string logIDName)
        {
            TemplatePlatformEmitter te = new TemplatePlatformEmitter("LogEnd", logIDName);

            return(te.Emit(logContainer));
        }
 public string Emit(StoredProc storedProc)
 {
     TemplatePlatformEmitter te = new TemplatePlatformEmitter("StoredProc", storedProc.Name, new StoredProcColumnsBuilder(storedProc.Columns).Build(), storedProc.Body);
     return te.Emit(storedProc);
 }