Esempio n. 1
0
        private static PhysicalTask.SqlTask CreateLogReadPreviousValuesTask(PhysicalTask.SequenceTask logContainer, PhysicalTask.SequenceTask container, string path)
        {
            string logTaskName = Resources.Log + Resources.Seperator + Resources.LoadInto + Resources.Seperator + logContainer.Name;

            PhysicalTask.SqlTask logReadValuesTask = new PhysicalTask.SqlTask();
            logReadValuesTask.Type = "Expression";
            logReadValuesTask.Name = String.Format("LogReadValues-{0}", logContainer.Name);
            logReadValuesTask.Connection = logContainer.LogConnectionName;
            logReadValuesTask.ResultSet = "NONE";

            AddVariable(logContainer, Resources.LastSuccessfulRunLogID, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Input, logReadValuesTask, "INT32");
            AddVariable(logContainer, Resources.StartTime, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, logReadValuesTask, "INT32");
            AddVariable(logContainer, Resources.EndTime, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, logReadValuesTask, "INT32");
            AddVariable(logContainer, Resources.Status, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, logReadValuesTask, "STRING");
            AddVariable(logContainer, Resources.Notes, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, logReadValuesTask, "STRING");

            StringBuilder sGetValues = new StringBuilder();
            sGetValues.Append(new TSQLEmitter.LogPlatformEmitter().LogGetPredefinedValues(logContainer));

            foreach (Variable v in container.VariableList)
            {
                sGetValues.Append(" + \n");

                sGetValues.Append(new TSQLEmitter.LogPlatformEmitter().LogGetValue(logContainer, Resources.LastSuccessfulRunLogID, SetVariablePath(path), v.Name));

                AddVariable(v, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, logReadValuesTask);
            }
            logReadValuesTask.Body = sGetValues.ToString();
            return logReadValuesTask;
        }
Esempio n. 2
0
        public static PhysicalTask.SqlTask CreateLogEndTask(PhysicalTask.SequenceTask logContainer, PhysicalTask.SequenceTask container, string path)
        {
            StringBuilder sLogEndTask = new StringBuilder();

            sLogEndTask.Append(new TSQLEmitter.LogPlatformEmitter().LogPrepareToSetValue(logContainer));
            sLogEndTask.Append(" + \n");

            string logTaskName = Resources.Log + Resources.Seperator + _CurrentPackage.Name + Resources.Seperator + logContainer.Name + Resources.Seperator;
            PhysicalTask.SqlTask logEndTask = new PhysicalTask.SqlTask();//logEndTask.logContainer, context, logTaskName + Resources.Stop);
            logEndTask.Type = "Expression";
            logEndTask.Connection = logContainer.LogConnectionName;
            logEndTask.ResultSet = "NONE";

            Variable varLogID = AddVariable(logContainer, Resources.LogID, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Input, logEndTask, "INT32");

            foreach (Variable variable in container.VariableList)
            {
                sLogEndTask.Append(new TSQLEmitter.LogPlatformEmitter().LogSetValue(logContainer, varLogID.Name, SetVariablePath(path), variable.Name, variable.Name));
                sLogEndTask.Append(" + \n");

                AddVariable(variable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Input, logEndTask);
            }

            sLogEndTask.Append(new TSQLEmitter.LogPlatformEmitter().LogEnd(logContainer, varLogID.Name));

            AddVariable(logContainer, Resources.LogID, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Input, logEndTask, "INT32");

            logEndTask.Body = sLogEndTask.ToString();
            return logEndTask;
        }
Esempio n. 3
0
        public static PhysicalTask.SqlTask CreateLogStartTask(PhysicalTask.SequenceTask LogContainer, string path)
        {
            string logTaskName = Resources.Log + Resources.Seperator + _CurrentPackage.Name + Resources.Seperator + LogContainer.Name + Resources.Seperator;

            PhysicalTask.SqlTask logStartTask = new PhysicalTask.SqlTask();

            Variable varLogID = AddVariable(LogContainer, Resources.LogID, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, logStartTask, "INT32");
            AddVariable(LogContainer, Resources.LastSuccessfulRunLogID, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, logStartTask, "INT32");
            AddVariable(LogContainer, Resources.IsAnotherInstanceCurrentlyRunningLogID, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections.Output, logStartTask, "INT32");
            logStartTask.Type = "Expression";
            logStartTask.Name = logTaskName + Resources.Start;
            logStartTask.ResultSet = "NONE";
            logStartTask.Connection = LogContainer.LogConnectionName;
            logStartTask.ExecuteDuringDesignTime = false;
            logStartTask.Parent = LogContainer;
            logStartTask.Body = new TSQLEmitter.LogPlatformEmitter().LogStart(LogContainer, _CurrentPackage.Name, LogContainer.Name, GetVariablePathXML(path));

            return logStartTask;
        }
Esempio n. 4
0
 private static void AddVariable(Variable variable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections direction, PhysicalTask.SqlTask sqlTask)
 {
     PhysicalTask.ExecuteSQLParameter parameter = new PhysicalTask.ExecuteSQLParameter();
     parameter.Variable = variable;
     parameter.Direction = direction;
     parameter.OleDbType = GetVariableType(variable.Type);
     sqlTask.ParameterList.Add(parameter);
 }
Esempio n. 5
0
 private static Variable AddVariable(PhysicalTask.SequenceTask LogContainer, string name, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections direction, PhysicalTask.SqlTask sqlTask, string type)
 {
     Variable variable = new Variable();
     variable.Name = LogContainer.Name + Resources.Seperator + name;
     variable.Type = type;
     variable.Value = "-1";
     AddVariable(variable, direction, sqlTask);
     return variable;
 }
Esempio n. 6
0
        private static PhysicalDataFlow.Transformation ProcessTransformList(VulcanCollection<AstTransformation.AstTransformationNode> transformations, PhysicalTask.PipelineTask pipelineTask, PhysicalDataFlow.Transformation previousNode, Dictionary<string, PhysicalDataFlow.Transformation> componentLibrary)
        {
            PhysicalDataFlow.Transformation firstNode = null;

            List<AstTransformation.AstTransformationNode> allTransformations = new List<VulcanEngine.IR.Ast.Transformation.AstTransformationNode>();

            foreach (AstTransformation.AstTransformationNode astTransformation in transformations)
            {
                if (astTransformation.AsClassOnly)
                {
                    continue;
                }

                if (astTransformation is AstTransformation.AstDataFlowNode)
                {
                    foreach (AstTransformation.AstTransformationNode transformation in ((AstTransformation.AstDataFlowNode)astTransformation).Transformations)
                    {
                        allTransformations.Add(transformation);
                    }
                }
                else
                {
                    allTransformations.Add(astTransformation);
                }
            }

            foreach (AstTransformation.AstTransformationNode astTransformation in allTransformations)
            {
                if (astTransformation.AsClassOnly)
                {
                    continue;
                }

                try
                {
                    PhysicalDataFlow.Transformation physicalTransformation = astTransformation.Lower();
                    physicalTransformation.Parent = pipelineTask;
                    pipelineTask.Transformations.Add(physicalTransformation);

                    // TODO: Fix logical node remapping
                    switch (astTransformation.GetType().Name)
                    {
                        case "AstUnionAllNode":
                            AstTransformation.AstUnionAllNode unionNode = astTransformation as AstTransformation.AstUnionAllNode;
                            Ssis2008Emitter.IR.DataFlow.UnionAll physicalUnionNode = physicalTransformation as Ssis2008Emitter.IR.DataFlow.UnionAll;

                            foreach (AstTransformation.AstUnionAllInputPathNode unionInputPath in unionNode.InputPathCollection)
                            {
                                Ssis2008Emitter.IR.DataFlow.UnionInputPath inputPath = new Ssis2008Emitter.IR.DataFlow.UnionInputPath();

                                inputPath.Name = unionInputPath.PathName;
                                string componentFullName = astTransformation.ParentASTNode.ReferenceableName + VulcanEngine.Common.IRUtility.NamespaceSeparator + unionInputPath.Source;
                                if (componentLibrary.ContainsKey(componentFullName))
                                {
                                    inputPath.Source = componentLibrary[componentFullName].Name;
                                }
                                inputPath.Parent = physicalUnionNode;

                                var physicalMappings = from map in unionInputPath.Maps
                                                       select new Ssis2008Emitter.IR.DataFlow.UnionMapping()
                                                       {
                                                           Input = map.SourceName,
                                                           Output = map.DestinationName
                                                       };
                                inputPath.MappingList = physicalMappings.ToList<Ssis2008Emitter.IR.DataFlow.UnionMapping>();
                                physicalUnionNode.InputPathList.Add(inputPath);
                            }
                            break;
                        case "AstConditionalSplitNode":
                            AstTransformation.AstConditionalSplitNode splitNode = astTransformation as AstTransformation.AstConditionalSplitNode;
                            Ssis2008Emitter.IR.DataFlow.ConditionalSplit physicalSplitNode = physicalTransformation as Ssis2008Emitter.IR.DataFlow.ConditionalSplit;

                            PhysicalDataFlow.Condition defaultCondition = new Ssis2008Emitter.IR.DataFlow.Condition();
                            defaultCondition.Expression = "false";
                            defaultCondition.OutputPath = splitNode.OutputPath.Name;
                            physicalSplitNode.DefaultCondition = defaultCondition;

                            foreach (AstTransformation.AstConditionalSplitOutputNode outputNode in splitNode.Outputs)
                            {
                                PhysicalDataFlow.Condition physicalCondition = new Ssis2008Emitter.IR.DataFlow.Condition();
                                physicalCondition.Expression = outputNode.Expression;
                                physicalCondition.OutputPath = outputNode.Name;
                                physicalSplitNode.ConditionList.Add(physicalCondition);
                            }
                            break;
                    }

                    if (astTransformation.InputPath != null)
                    {
                        string componentFullName = astTransformation.ParentASTNode.ReferenceableName + VulcanEngine.Common.IRUtility.NamespaceSeparator + astTransformation.InputPath.Source;
                        if (componentLibrary.ContainsKey(componentFullName))
                        {
                            physicalTransformation.InputPath.Source = componentLibrary[componentFullName].Name;
                        }
                    }

                    if (firstNode == null)
                    {
                        firstNode = physicalTransformation;
                    }
                    previousNode = physicalTransformation;
                    componentLibrary[physicalTransformation.AstNodeName] = physicalTransformation;
                }
                catch (Exception e)
                {
                    throw new SSISEmitterException(astTransformation, e);
                }
            }
            return firstNode;
        }
Esempio n. 7
0
        private static PhysicalTask.SequenceTask ProcessHelperTables(AstTask.AstContainerTaskNode astNode, PhysicalTask.SequenceTask sequenceTask)
        {
            foreach (AstTable.AstTableNode helperTableNode in astNode.HelperTables)
            {
                IR.TSQL.Table helperTable = helperTableNode.Lower();
                if (helperTable != null)
                {
                    AstTask.AstExecuteSQLTaskNode createHelperTableTask = new VulcanEngine.IR.Ast.Task.AstExecuteSQLTaskNode();
                    createHelperTableTask.ParentASTNode = astNode;
                    createHelperTableTask.Name = "__Create HelperTable " + helperTable.Name;
                    createHelperTableTask.Connection = helperTableNode.Connection;
                    createHelperTableTask.ExecuteDuringDesignTime = helperTableNode.ExecuteDuringDesignTime;
                    createHelperTableTask.Type = VulcanEngine.IR.Ast.Task.ExecuteSQLTaskType.File;
                    createHelperTableTask.Body = new TSQLEmitter.TablePlatformEmitter().Emit(helperTable);
                    sequenceTask.Tasks.Insert(0, createHelperTableTask.Lower());

                    AstTask.AstExecuteSQLTaskNode dropHelperTableTask = new VulcanEngine.IR.Ast.Task.AstExecuteSQLTaskNode();
                    dropHelperTableTask.ParentASTNode = astNode;
                    dropHelperTableTask.Name = "__Drop HelperTable " + helperTable.Name;
                    dropHelperTableTask.Connection = helperTableNode.Connection;
                    dropHelperTableTask.ExecuteDuringDesignTime = false;
                    dropHelperTableTask.Type = VulcanEngine.IR.Ast.Task.ExecuteSQLTaskType.Expression;
                    dropHelperTableTask.Body = String.Format("\"{0}\"", new TSQLEmitter.TemplatePlatformEmitter("DropHelperTable", helperTable.Name).Emit(helperTable));
                    sequenceTask.Tasks.Add(dropHelperTableTask.Lower());
                }
            }

            return sequenceTask;
        }