Esempio n. 1
0
        public override void Initialize(SsisEmitterContext context)
        {
            base.Initialize(context);
            TransformationUtility.RegisterOleDBConnection(context, _oleDBConnection, Component);

            Instance.SetComponentProperty("SqlCommand", _astOleDBCommandNode.Query.Body);
            ProcessBindings(context);
            Flush();
        }
Esempio n. 2
0
        public virtual IDTSInputColumn100 SetInputColumnUsage(object inputPathIndex, object columnIndex, IDTSVirtualInput100 virtualInput, IDTSVirtualInputColumn100 virtualInputColumn, DTSUsageType usageType, bool forceOverwrite)
        {
            if ((virtualInputColumn.UsageType == usageType || virtualInputColumn.UsageType == DTSUsageType.UT_READWRITE) && !forceOverwrite)
            {
            }
            else
            {
                Instance.SetUsageType(Component.InputCollection[inputPathIndex].ID, virtualInput, virtualInputColumn.LineageID, usageType);
            }

            return(TransformationUtility.FindInputColumnByName(columnIndex.ToString(), Component.InputCollection[inputPathIndex], true));
        }
Esempio n. 3
0
        public override void Initialize(SsisEmitterContext context)
        {
            base.Initialize(context);
            TransformationUtility.RegisterOleDBConnection(context, _oleDBConnection, Component);

            Instance.SetComponentProperty("IsCaseSensitive", _astTermLookupNode.IsCaseSensitive);
            Instance.SetComponentProperty("RefTermColumn", _astTermLookupNode.RefTermColumnName);
            Instance.SetComponentProperty("RefTermTable", _astTermLookupNode.RefTermTableName);

            Component.OutputCollection[0].ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
            ProcessBindings(context);
            Flush();
        }
Esempio n. 4
0
        protected override void ProcessBindingMappings(SsisEmitterContext context, MappedBinding mappedBinding, IDTSPath100 path)
        {
            if (mappedBinding != null && path != null)
            {
                foreach (AstDataflowColumnMappingNode map in mappedBinding.Mappings)
                {
                    int lineageId;
                    var matchedOutput = TransformationUtility.FindOutputColumnByName(map.SourceName, path.StartPoint, true);

                    if (matchedOutput == null)
                    {
                        var matchedInput = TransformationUtility.FindVirtualInputColumnByName(map.SourceName, path.EndPoint, true);
                        if (matchedInput == null)
                        {
                            MessageEngine.Trace(_astUnionAllNode, Severity.Error, "V0145", "Could not find input column {0} for transformation {1}", map.SourceName, _astUnionAllNode.Name);
                        }

                        lineageId = matchedInput.LineageID;
                    }
                    else
                    {
                        lineageId = matchedOutput.LineageID;
                    }

                    IDTSInputColumn100 ic = TransformationUtility.FindInputColumnByName(map.SourceName, path.EndPoint, true);
                    if (ic == null)
                    {
                        ic           = path.EndPoint.InputColumnCollection.New();
                        ic.Name      = map.SourceName;
                        ic.LineageID = lineageId;
                    }

                    IDTSOutputColumn100 oc = TransformationUtility.FindOutputColumnByName(map.TargetName, OutputPath, true);
                    if (oc == null)
                    {
                        oc      = OutputPath.OutputColumnCollection.New();
                        oc.Name = map.TargetName;
                        oc.SetDataTypeProperties(ic.DataType, ic.Length, ic.Precision, ic.Scale, ic.CodePage);
                    }

                    IDTSCustomProperty100 cp = TransformationUtility.FindCustomPropertyByName("OutputColumnLineageID", ic.CustomPropertyCollection, true);
                    if (cp == null)
                    {
                        cp      = ic.CustomPropertyCollection.New();
                        cp.Name = "OutputColumnLineageID";
                    }

                    cp.Value = oc.LineageID;
                }
            }
        }
Esempio n. 5
0
        public override void Initialize(SsisEmitterContext context)
        {
            base.Initialize(context);
            TransformationUtility.RegisterOleDBConnection(context, _oleDBConnection, Component);

            switch (_astDestination.AccessMode)
            {
            case DestinationAccessModeFacet.Table:
                Instance.SetComponentProperty("AccessMode", 0);
                Instance.SetComponentProperty("OpenRowset", _astDestination.Table.SchemaQualifiedName);
                break;

            case DestinationAccessModeFacet.TableFastLoad:
                Instance.SetComponentProperty("AccessMode", 3);
                Instance.SetComponentProperty("OpenRowset", _astDestination.Table.SchemaQualifiedName);

                Instance.SetComponentProperty("FastLoadKeepIdentity", _astDestination.KeepIdentity);
                Instance.SetComponentProperty("FastLoadKeepNulls", _astDestination.KeepNulls);
                Instance.SetComponentProperty("FastLoadMaxInsertCommitSize", _astDestination.MaximumInsertCommitSize);

                var fastLoadOptions = new StringBuilder();
                if (_astDestination.TableLock)
                {
                    fastLoadOptions.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "TABLOCK,");
                }

                if (_astDestination.CheckConstraints)
                {
                    fastLoadOptions.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "CHECK_CONSTRAINTS,");
                }

                if (_astDestination.RowsPerBatch > 0)
                {
                    fastLoadOptions.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "ROWS_PER_BATCH = {0}", _astDestination.RowsPerBatch);
                }

                fastLoadOptions = fastLoadOptions.Replace(",", String.Empty, fastLoadOptions.Length - 5, 5);

                Instance.SetComponentProperty("FastLoadOptions", fastLoadOptions.ToString());
                break;

            default:
                MessageEngine.Trace(Severity.Error, new NotImplementedException(), "Unknown Destination Load Type of {0}", _astDestination.AccessMode);
                break;
            }

            ProcessBindings(context);
            Flush();
        }
Esempio n. 6
0
        protected virtual void ProcessBindingMappings(SsisEmitterContext context, MappedBinding mappedBinding, IDTSPath100 path)
        {
            if (mappedBinding != null && path != null)
            {
                foreach (AstDataflowColumnMappingNode map in mappedBinding.Mappings)
                {
                    int lineageId;
                    var matchedOutput = TransformationUtility.FindOutputColumnByName(map.SourceName, path.StartPoint, true);

                    if (matchedOutput == null)
                    {
                        var matchedInput = TransformationUtility.FindVirtualInputColumnByName(map.SourceName, path.EndPoint, true);
                        if (matchedInput == null)
                        {
                            // Message.Error
                            throw new InvalidOperationException();
                        }

                        lineageId = matchedInput.LineageID;
                    }
                    else
                    {
                        lineageId = matchedOutput.LineageID;
                    }

                    IDTSInputColumn100 ic = TransformationUtility.FindInputColumnByName(map.SourceName, path.EndPoint, true);
                    if (ic == null)
                    {
                        ic           = path.EndPoint.InputColumnCollection.New();
                        ic.LineageID = lineageId;
                    }

                    if (String.IsNullOrEmpty(map.TargetName))
                    {
                        // TODO: What is the right way to destroy a column in dataflow?
                        ic.UsageType = DTSUsageType.UT_IGNORED;
                    }
                    else
                    {
                        ic.Name = map.TargetName;
                    }
                }
            }
        }
Esempio n. 7
0
        public override void Initialize(SsisEmitterContext context)
        {
            base.Initialize(context);
            TransformationUtility.RegisterOleDBConnection(context, _oleDBConnection, Component);

            Instance.SetComponentProperty("SqlCommand", _astSlowlyChangingDimensionNode.Query);
            Instance.SetComponentProperty("CurrentRowWhere", _astSlowlyChangingDimensionNode.CurrentRowWhere);
            Instance.SetComponentProperty("EnableInferredMember", _astSlowlyChangingDimensionNode.EnableInferredMember);
            Instance.SetComponentProperty("FailOnFixedAttributeChange", _astSlowlyChangingDimensionNode.FailOnFixedAttributeChange);
            Instance.SetComponentProperty("FailOnLookupFailure", _astSlowlyChangingDimensionNode.FailOnLookupFailure);
            Instance.SetComponentProperty("IncomingRowChangeType", _astSlowlyChangingDimensionNode.IncomingRowChangeType);
            Instance.SetComponentProperty("UpdateChangingAttributeHistory", _astSlowlyChangingDimensionNode.UpdateChangingAttributeHistory);

            string inferredMemberIndicatorName = String.Empty;

            if (_astSlowlyChangingDimensionNode.InferredMemberIndicator != null)
            {
                inferredMemberIndicatorName = _astSlowlyChangingDimensionNode.InferredMemberIndicator.Name;
            }

            Instance.SetComponentProperty("InferredMemberIndicator", inferredMemberIndicatorName);

            Flush();
        }
Esempio n. 8
0
        public override void Emit(SsisEmitterContext context)
        {
            ProcessBindings(context);

            // TODO: Add Input column custom property mapping
            foreach (var column in _astSlowlyChangingDimensionNode.Mappings)
            {
                int columnType;
                switch (column.MappingType)
                {
                case ScdColumnMappingType.ChangingAttribute:
                    columnType = 2;
                    break;

                case ScdColumnMappingType.FixedAttribute:
                    columnType = 4;
                    break;

                case ScdColumnMappingType.HistoricalAttribute:
                    columnType = 3;
                    break;

                case ScdColumnMappingType.Key:
                    columnType = 1;
                    break;

                case ScdColumnMappingType.Other:
                    columnType = 0;
                    break;

                default:
                    MessageEngine.Trace(_astSlowlyChangingDimensionNode, Severity.Error, "V0140", "Unrecognized ScdColumnMappingType {0} on column {1}", column.MappingType.ToString(), column.QueryColumnName);
                    return;
                }

                IDTSInputColumn100 inputColumn = TransformationUtility.FindInputColumnByName(column.QueryColumnName, Component.InputCollection[0], true);
                if (inputColumn == null)
                {
                    IDTSVirtualInputColumn100 virtualInputColumn = TransformationUtility.FindVirtualInputColumnByName(column.QueryColumnName, Component.InputCollection[0], true);
                    if (virtualInputColumn == null)
                    {
                        MessageEngine.Trace(_astSlowlyChangingDimensionNode, Severity.Error, "V0141", "Column {0} could not be found", column.QueryColumnName);
                        return;
                    }

                    inputColumn           = Component.InputCollection[0].InputColumnCollection.New();
                    inputColumn.Name      = column.QueryColumnName;
                    inputColumn.LineageID = virtualInputColumn.LineageID;
                }

                IDTSCustomProperty100 propColumnType = TransformationUtility.FindCustomPropertyByName("ColumnType", inputColumn.CustomPropertyCollection, true);
                if (propColumnType == null)
                {
                    propColumnType               = inputColumn.CustomPropertyCollection.New();
                    propColumnType.Name          = "ColumnType";
                    propColumnType.TypeConverter = "ColumnType";
                }

                propColumnType.Value = columnType;
            }
        }
Esempio n. 9
0
 public override void Initialize(SsisEmitterContext context)
 {
     base.Initialize(context);
     TransformationUtility.RegisterOleDBConnection(context, _oleDBConnection, Component);
 }
Esempio n. 10
0
        protected void ProcessMappings()
        {
            IDTSVirtualInput100 cvi = Component.InputCollection[0].GetVirtualInput();

            var virtualInputDictionary = new Dictionary <string, IDTSVirtualInputColumn100>();

            foreach (IDTSVirtualInputColumn100 vc in cvi.VirtualInputColumnCollection)
            {
                virtualInputDictionary["@" + vc.Name.ToUpperInvariant()] = vc;
            }

            // Automatically map columns
            foreach (IDTSExternalMetadataColumn100 extCol in Component.InputCollection[0].ExternalMetadataColumnCollection)
            {
                if (virtualInputDictionary.ContainsKey(extCol.Name.ToUpperInvariant()))
                {
                    IDTSVirtualInputColumn100 vc = virtualInputDictionary[extCol.Name.ToUpperInvariant()];
                    Instance.SetUsageType(Component.InputCollection[0].ID, cvi, vc.LineageID, DTSUsageType.UT_READONLY);
                    Component.InputCollection[0].InputColumnCollection[vc.Name].ExternalMetadataColumnID = extCol.ID;
                }
            }

            // Map any overrides
            foreach (AstDataflowColumnMappingNode mapping in _astOleDBCommandNode.Query.Mappings)
            {
                if (String.IsNullOrEmpty(mapping.TargetName))
                {
                    SetInputColumnUsage(0, mapping.SourceName, DTSUsageType.UT_IGNORED, true);
                }
                else
                {
                    IDTSExternalMetadataColumn100 ecol = TransformationUtility.FindExternalColumnByName(mapping.TargetName, Component.InputCollection[0].ExternalMetadataColumnCollection, true);

                    // Unmap anything else that maps to this external metadata column)
                    foreach (IDTSInputColumn100 inputColumn in Component.InputCollection[0].InputColumnCollection)
                    {
                        if (inputColumn.ExternalMetadataColumnID == ecol.ID)
                        {
                            MessageEngine.Trace(_astOleDBCommandNode, Severity.Debug, "V0401", "{0}: {1} Unmapping Input {2}", GetType(), Component.Name, inputColumn.Name);
                            SetInputColumnUsage(0, inputColumn.Name, DTSUsageType.UT_IGNORED, true);
                            break;
                        }
                    }

                    IDTSInputColumn100 icol = SetInputColumnUsage(0, mapping.SourceName, DTSUsageType.UT_READONLY, false);
                    if (ecol != null)
                    {
                        if (icol != null)
                        {
                            icol.ExternalMetadataColumnID = ecol.ID;
                        }
                        else
                        {
                            MessageEngine.Trace(_astOleDBCommandNode, Severity.Error, "V0105", "Could not find source column {0}", mapping.SourceName);
                        }
                    }
                    else
                    {
                        MessageEngine.Trace(_astOleDBCommandNode, Severity.Error, "V0106", "Could not find destination column {0}", mapping.TargetName);
                    }
                }
            }
        }