Пример #1
0
        private static Transformation CreateTermLookupFromXml(Vulcan.Packages.VulcanPackage vulcanPackage, IDTSComponentMetaData90 parentComponent, MainPipe dataFlowTask, XPathNavigator termLookupNav)
        {
            if (termLookupNav == null || termLookupNav.Name.ToUpperInvariant() != "TermLookup".ToUpperInvariant())
            {
                return(null);
            }
            string termLookupName  = termLookupNav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value;
            bool   isCaseSensitive = termLookupNav.SelectSingleNode("@IsCaseSensitive").ValueAsBoolean;
            string refTermColumn   = termLookupNav.SelectSingleNode("@RefTermColumn").Value;
            string refTermTable    = termLookupNav.SelectSingleNode("@RefTermTable").Value;

            Message.Trace(Severity.Debug, "Begin: TermLookup Transformation {0}", termLookupName);
            Connection sourceConnection =
                Connection.GetExistingConnection(vulcanPackage, termLookupNav.SelectSingleNode("@ConnectionName").Value);
            TermLookup tl = new TermLookup(
                vulcanPackage,
                dataFlowTask,
                parentComponent,
                termLookupName,
                termLookupName,
                sourceConnection,
                isCaseSensitive,
                refTermColumn,
                refTermTable
                );

            foreach (XPathNavigator nav in termLookupNav.Select("rc:InputColumn", vulcanPackage.VulcanConfig.NamespaceManager))
            {
                string inputColumnName = nav.SelectSingleNode("@InputColumnName").Value;
                TermLookup.InputColumnUsageType inputColumnUsageType = (TermLookup.InputColumnUsageType)Enum.Parse(typeof(TermLookup.InputColumnUsageType), nav.SelectSingleNode("@InputColumnUsageType").Value);
                tl.MapInput(inputColumnName, inputColumnUsageType);
            }
            return(tl);
        }
Пример #2
0
 protected Pattern(Vulcan.Packages.VulcanPackage vulcanPackage, DTS.IDTSSequence parentContainer)
 {
     _vulcanPackage   = vulcanPackage;
     _parentContainer = parentContainer;
     _firstExecutableGeneratedByPattern = null;
     _lastExecutableGeneratedByPattern  = null;
 }
Пример #3
0
 protected Pattern(Vulcan.Packages.VulcanPackage vulcanPackage,DTS.IDTSSequence parentContainer)
 {
     _vulcanPackage = vulcanPackage;
     _parentContainer = parentContainer;
     _firstExecutableGeneratedByPattern = null;
     _lastExecutableGeneratedByPattern = null;
 }
Пример #4
0
 public LogtainerPattern(Vulcan.Packages.VulcanPackage vulcanPackage, DTS.IDTSSequence parentContainer)
     :
     base(
         vulcanPackage,
         parentContainer
         )
 {
 }
Пример #5
0
        public LogtainerLog(Packages.VulcanPackage vulcanPackage, string logName, string sourceColumn, string destinationColumn, string table, string tableConnectionName)
        {
            _sourceColumn        = sourceColumn;
            _destinationColumn   = destinationColumn;
            _table               = table;
            _tableConnectionName = tableConnectionName;

            _vulcanPackage            = vulcanPackage;
            _logName                  = logName;
            _columnVariableDictionary = new Dictionary <string, Microsoft.SqlServer.Dts.Runtime.Variable>();
            _logVariable              = vulcanPackage.AddVariable(logName, (System.Int32)(-1));
            _lastRecordLogVariable    = vulcanPackage.AddVariable(logName + Resources.LastSuccessfulRunLogID, (System.Int32)(-1));
            _isAnotherInstanceCurrentlyRunningLogVariable = vulcanPackage.AddVariable(logName + Resources.IsAnotherInstanceCurrentlyRunningLogID, (System.Int32) 0);
        }
Пример #6
0
        public LogtainerLog(Packages.VulcanPackage vulcanPackage, string logName, string sourceColumn, string destinationColumn, string table, string tableConnectionName)
        {
            _sourceColumn = sourceColumn;
            _destinationColumn = destinationColumn;
            _table = table;
            _tableConnectionName = tableConnectionName;

            _vulcanPackage = vulcanPackage;
            _logName = logName;
            _columnVariableDictionary = new Dictionary<string, Microsoft.SqlServer.Dts.Runtime.Variable>();
            _logVariable = vulcanPackage.AddVariable(logName, (System.Int32)(-1));
            _lastRecordLogVariable = vulcanPackage.AddVariable(logName + Resources.LastSuccessfulRunLogID, (System.Int32)(-1));
            _isAnotherInstanceCurrentlyRunningLogVariable = vulcanPackage.AddVariable(logName + Resources.IsAnotherInstanceCurrentlyRunningLogID, (System.Int32)0);
        }
Пример #7
0
        private static Transformation CreateUnionAllFromXml(Vulcan.Packages.VulcanPackage vulcanPackage, IDTSComponentMetaData90 parentComponent, MainPipe dataFlowTask, XPathNavigator unionAllNav)
        {
            if (unionAllNav == null || unionAllNav.Name.ToUpperInvariant() != "UnionAll".ToUpperInvariant())
            {
                return(null);
            }
            string unionAllName = unionAllNav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value;

            Message.Trace(Severity.Debug, "Begin: UnionAll Transformation {0}", unionAllName);
            UnionAll ua = new UnionAll(
                vulcanPackage,
                dataFlowTask,
                parentComponent,
                unionAllName,
                unionAllName
                );


            foreach (XPathNavigator navInput in unionAllNav.Select("rc:SourceComponent", vulcanPackage.VulcanConfig.NamespaceManager))
            {
                string sourceComponentName = navInput.SelectSingleNode("@SourceComponentName", vulcanPackage.VulcanConfig.NamespaceManager).Value;
                ua.Component.InputCollection.New().Name = "Input for " + sourceComponentName;

                ua.MapInput(sourceComponentName, dataFlowTask);

                foreach (XPathNavigator navInputColumn in navInput.Select("rc:Map", vulcanPackage.VulcanConfig.NamespaceManager))
                {
                    string sourceColumnName = navInputColumn.SelectSingleNode("@Source", vulcanPackage.VulcanConfig.NamespaceManager).Value;
                    string destinationColumnName;
                    bool   unMap = false;
                    if (navInputColumn.SelectSingleNode("@Destination") == null)
                    {
                        unMap = true;
                        destinationColumnName = sourceColumnName;
                    }
                    else
                    {
                        destinationColumnName = navInputColumn.SelectSingleNode("@Destination", vulcanPackage.VulcanConfig.NamespaceManager).Value;
                    }
                    ua.MapInputColumn(sourceComponentName, sourceColumnName, destinationColumnName, unMap);
                }
            }

            ua.InitializeAndMapDestination();
            return(ua);
        }
Пример #8
0
        private static Transformation CreateSortFromXml(Vulcan.Packages.VulcanPackage vulcanPackage, IDTSComponentMetaData90 parentComponent, MainPipe dataFlowTask, XPathNavigator sortNav)
        {
            if (sortNav == null || sortNav.Name.ToUpperInvariant() != "Sort".ToUpperInvariant())
            {
                return(null);
            }
            string sortName            = sortNav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value;
            bool   eliminateDuplicates = sortNav.SelectSingleNode("@EliminateDuplicates", vulcanPackage.VulcanConfig.NamespaceManager).ValueAsBoolean;
            int    maximumThreads      = sortNav.SelectSingleNode("@MaximumThreads", vulcanPackage.VulcanConfig.NamespaceManager).ValueAsInt;

            //MaximumThreads can not be 0, according to SSIS
            if (maximumThreads == 0)
            {
                maximumThreads = -1;
            }

            Message.Trace(Severity.Debug, "Begin: UnionAll Transformation {0}", sortName);
            Sort sortTask = new Sort(
                vulcanPackage,
                dataFlowTask,
                parentComponent,
                sortName,
                sortName,
                eliminateDuplicates,
                maximumThreads
                );

            foreach (XPathNavigator navInput in sortNav.Select("rc:InputColumn", vulcanPackage.VulcanConfig.NamespaceManager))
            {
                string inputColumnName = navInput.SelectSingleNode("@InputColumnName", vulcanPackage.VulcanConfig.NamespaceManager).Value;
                Sort.InputColumnUsageType inputColumnUsageType = (Sort.InputColumnUsageType)Enum.Parse(typeof(Sort.InputColumnUsageType), navInput.SelectSingleNode("@InputColumnUsageType").Value);
                Sort.SortType             SortType             = (Sort.SortType)Enum.Parse(typeof(Sort.SortType), navInput.SelectSingleNode("@SortType").Value);

                List <Sort.ComparisonFlag> comparisonFlagList = new List <Sort.ComparisonFlag>();
                foreach (XPathNavigator navComparisonFlag in navInput.Select("rc:ComparisonFlag", vulcanPackage.VulcanConfig.NamespaceManager))
                {
                    comparisonFlagList.Add((Sort.ComparisonFlag)Enum.Parse(typeof(Sort.ComparisonFlag), navComparisonFlag.Value));
                }
                sortTask.SetInputColumnProperty(inputColumnName, inputColumnUsageType, SortType, comparisonFlagList);
            }

            return(sortTask);
        }
Пример #9
0
        private static Transformation CreateConditionalSplitFromXml(Vulcan.Packages.VulcanPackage vulcanPackage, IDTSComponentMetaData90 parentComponent, MainPipe dataFlowTask, XPathNavigator conditionalSplitNav)
        {
            if (conditionalSplitNav == null || conditionalSplitNav.Name.ToUpperInvariant() != "ConditionalSplit".ToUpperInvariant())
            {
                return(null);
            }
            string conditionalSplitName = conditionalSplitNav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value;

            Message.Trace(Severity.Debug, "Begin: ConditionalSplit Transformation {0}", conditionalSplitName);
            ConditionalSplit cs = new ConditionalSplit(
                vulcanPackage,
                dataFlowTask,
                parentComponent,
                conditionalSplitName,
                conditionalSplitName
                );

            int    intEvaluationOrder = 0;
            string expression         = string.Empty;

            foreach (XPathNavigator nav in conditionalSplitNav.Select("//rc:Output|//rc:DefaultOutput", vulcanPackage.VulcanConfig.NamespaceManager))
            {
                if (nav.Name == "DefaultOutput")
                {
                    cs.Component.OutputCollection.SetIndex(cs.Component.OutputCollection.GetObjectIndexByID(cs.Component.OutputCollection["Conditional Split Default Output"].ID), 0);
                }
                else
                {
                    expression = nav.SelectSingleNode("rc:Expression", vulcanPackage.VulcanConfig.NamespaceManager).Value;
                    IDTSOutput90 newPath = cs.Component.OutputCollection.New();
                    newPath.Name                       = nav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value;
                    newPath.Description                = nav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value;
                    newPath.ExclusionGroup             = cs.Component.OutputCollection["Conditional Split Default Output"].ExclusionGroup;
                    newPath.SynchronousInputID         = cs.Component.OutputCollection["Conditional Split Default Output"].SynchronousInputID;
                    newPath.ErrorOrTruncationOperation = "Computation";
                    newPath.ErrorRowDisposition        = DTSRowDisposition.RD_IgnoreFailure;
                    newPath.TruncationRowDisposition   = DTSRowDisposition.RD_FailComponent;

                    IDTSCustomProperty90 propEvaluationOrder = newPath.CustomPropertyCollection.New();
                    propEvaluationOrder.Name  = "EvaluationOrder";
                    propEvaluationOrder.Value = intEvaluationOrder;

                    IDTSCustomProperty90 propFriendlyExpression = newPath.CustomPropertyCollection.New();
                    propFriendlyExpression.Name  = "FriendlyExpression";
                    propFriendlyExpression.Value = expression;

                    IDTSCustomProperty90 propExpression = newPath.CustomPropertyCollection.New();
                    propExpression.Name  = "Expression";
                    propExpression.Value = expression;

                    //A workaround to connect the path to Conditional Spit's output,
                    //because we always connect the current task to the previous task's first output
                    cs.Component.OutputCollection.SetIndex(cs.Component.OutputCollection.GetObjectIndexByID(newPath.ID), 0);
                    intEvaluationOrder++;
                }

                IDTSComponentMetaData90 startComponent = cs.Component;

                XPathNavigator transNav = nav.SelectSingleNode("rc:ConditionalSplitOutputPath/rc:Transformations", vulcanPackage.VulcanConfig.NamespaceManager);
                if (transNav != null)
                {
                    foreach (XPathNavigator etlNav in transNav.SelectChildren(XPathNodeType.Element))
                    {
                        // this is naughty but can be fixed later :)
                        Transformation t = TransformationFactory.ProcessTransformation(vulcanPackage, startComponent, dataFlowTask, etlNav);
                        if (t != null)
                        {
                            startComponent = t.Component;
                        }
                    }
                }

                XPathNavigator destNav = nav.SelectSingleNode("rc:ConditionalSplitOutputPath/rc:Destination", vulcanPackage.VulcanConfig.NamespaceManager);
                if (destNav != null)
                {
                    string           name             = destNav.SelectSingleNode("@Name").Value;
                    Connection       destConnection   = Connection.GetExistingConnection(vulcanPackage, destNav.SelectSingleNode("@ConnectionName").Value);
                    string           tableName        = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", destNav.SelectSingleNode("@Table").Value.Trim());
                    OLEDBDestination oledbDestination = new OLEDBDestination(vulcanPackage, dataFlowTask, startComponent, name, name, destConnection, tableName);

                    string accessMode       = destNav.SelectSingleNode("@AccessMode").Value;
                    bool   tableLock        = destNav.SelectSingleNode("@TableLock").ValueAsBoolean;
                    bool   checkConstraints = destNav.SelectSingleNode("@CheckConstraints").ValueAsBoolean;
                    bool   keepIdentity     = destNav.SelectSingleNode("@KeepIdentity").ValueAsBoolean;
                    bool   keepNulls        = destNav.SelectSingleNode("@KeepNulls").ValueAsBoolean;

                    int rowsPerBatch        = destNav.SelectSingleNode("@RowsPerBatch").ValueAsInt;
                    int maxInsertCommitSize = destNav.SelectSingleNode("@MaximumInsertCommitSize").ValueAsInt;

                    switch (accessMode.ToUpperInvariant())
                    {
                    case "TABLE":
                        oledbDestination.ComponentInstance.SetComponentProperty("AccessMode", 0);
                        oledbDestination.ComponentInstance.SetComponentProperty("OpenRowset", tableName);
                        break;

                    case "TABLEFASTLOAD":
                        oledbDestination.ComponentInstance.SetComponentProperty("AccessMode", 3);
                        oledbDestination.ComponentInstance.SetComponentProperty("OpenRowset", tableName);

                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadKeepIdentity", keepIdentity);
                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadKeepNulls", keepNulls);
                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadMaxInsertCommitSize", maxInsertCommitSize);

                        StringBuilder fastLoadOptions = new StringBuilder();
                        if (tableLock)
                        {
                            fastLoadOptions.AppendFormat("TABLOCK,");
                        }
                        if (checkConstraints)
                        {
                            fastLoadOptions.AppendFormat("CHECK_CONSTRAINTS,");
                        }
                        if (rowsPerBatch > 0)
                        {
                            fastLoadOptions.AppendFormat("ROWS_PER_BATCH = {0}", rowsPerBatch);
                        }
                        fastLoadOptions = fastLoadOptions.Replace(",", "", fastLoadOptions.Length - 5, 5);

                        oledbDestination.ComponentInstance.SetComponentProperty("FastLoadOptions", fastLoadOptions.ToString());
                        break;

                    default:
                        Message.Trace(Severity.Error, "Unknown Destination Load Type of {0}", accessMode);
                        break;
                    }

                    try
                    {
                        oledbDestination.InitializeAndMapDestination();
                    }
                    catch (Exception)
                    {
                    }

                    // Map any overrides
                    foreach (XPathNavigator navMap in destNav.Select("rc:Map", vulcanPackage.VulcanConfig.NamespaceManager))
                    {
                        string source = navMap.SelectSingleNode("@Source").Value;
                        string destination;
                        bool   unMap = false;

                        if (navMap.SelectSingleNode("@Destination") == null)
                        {
                            unMap       = true;
                            destination = source;
                        }
                        else
                        {
                            destination = nav.SelectSingleNode("@Destination").Value;
                        }

                        oledbDestination.Map(source, destination, unMap);
                    }
                } // end DestNav != null
                  //this.FirstExecutableGeneratedByPattern = pipeHost;
                  //this.LastExecutableGeneratedByPattern = pipeHost;
            }

            return(cs);
        }