protected virtual IDTSPath100 ProcessAutoLexicalBinding(SsisEmitterContext context) { // TODO: Add handling for the exception below try { int lastObject = Dataflow.MainPipe.ComponentMetaDataCollection.GetObjectIndexByID(Dataflow.MainPipe.ComponentMetaDataCollection[Name].ID) - 1; if (lastObject >= 0) { IDTSPath100 path = Dataflow.MainPipe.PathCollection.New(); path.AttachPathAndPropagateNotifications(Dataflow.MainPipe.ComponentMetaDataCollection[lastObject].OutputCollection[0], Component.InputCollection[0]); // Shove in annotation for the path reference! :) context.Package.DtsPackage.ExtendedProperties.Add(Dataflow.DtsTaskHost.ID + "-" + path.ID, "dts-designer-1.0", Properties.Resources.DTSDesignerPathAnnotation); return(path); } } catch (Exception e) { MessageEngine.Trace(this._astTransformationNode, Severity.Error, "TF101", "Error binding AST Data Flow Transformation. This is probably due to having two Transformations with the same name. Please contact support.\n{0}", e.ToString()); } return(null); }
public override void Emit(SsisEmitterContext context) { DtsContainer.IsolationLevel = ContainerIsolationLevel; DtsContainer.DelayValidation = DelayValidation; context = new SsisEmitterContext(context.Package, this, context.ProjectManager); foreach (PhysicalObject po in this.Children) { try { po.Initialize(context); po.Emit(context); } catch (DTS.DtsException e) { if (e.ErrorCode == -1073659647) { MessageEngine.Trace(AstNamedNode, Severity.Error, "V1050", "Attempted to reuse the name '{0}' within an SSIS package, which is illegal. Use a unique name.\nContainer: {1}\nTask: {0}", po.Name, this.Name); } else { throw; } } } }
protected virtual IDTSPath100 ProcessBinding(SsisEmitterContext context, Binding binding) { if (binding != null) { try { IDTSPath100 path = Dataflow.MainPipe.PathCollection.New(); object index = binding.ParentOutputName ?? 0; path.AttachPathAndPropagateNotifications( Dataflow.MainPipe.ComponentMetaDataCollection[binding.ParentTransformName].OutputCollection[index], Component.InputCollection[binding.TargetInputName]); // Shove in annotation for the path reference! :) context.Package.DtsPackage.ExtendedProperties.Add(Dataflow.DtsTaskHost.ID + "-" + path.ID, "dts-designer-1.0", Properties.Resources.DTSDesignerPathAnnotation); ProcessBindingMappings(context, binding as MappedBinding, path); return(path); } catch (System.Runtime.InteropServices.COMException e) { MessageEngine.Trace(_astTransformationNode, Severity.Error, "V0210", GetScrubbedErrorDescription(e.ErrorCode)); throw; } } return(null); }
public override void Emit(SsisEmitterContext context) { context.Package.DtsPackage.EnableConfigurations = true; string packageRoot = String.IsNullOrEmpty(PackageConfigurationPath) ? Settings.Default.DetegoPackageConfigurationRoot : PackageConfigurationPath; string configFilePath = StringManipulation.CleanPath(packageRoot + Path.DirectorySeparatorChar + Name + "." + Resources.ExtensionDtsConfigurationFile); MessageEngine.Trace(Severity.Debug, "Adding Configuration File {0}", configFilePath); if (!context.Package.DtsPackage.Configurations.Contains(Name)) { DTS.Configuration config = context.Package.DtsPackage.Configurations.Add(); config.ConfigurationType = DTS.DTSConfigurationType.ConfigFile; config.Name = Name; config.Description = Name; config.ConfigurationString = configFilePath; context.Package.DtsPackage.ImportConfigurationFile(configFilePath); } }
public override void Initialize(SsisEmitterContext context) { _parentContainer = context.ParentContainer.DtsContainer; SetVariablePath(_parentContainer); if (_parentContainer.Variables.Contains(Name)) { _dtsVariable = _parentContainer.Variables[Name]; } else { if (EvaluateAsExpression) { _dtsVariable = _parentContainer.Variables.Add(Name, false, "User", null); _dtsVariable.EvaluateAsExpression = true; _dtsVariable.Expression = ValueString; } else { _dtsVariable = _parentContainer.Variables.Add(Name, false, "User", Value); } if (!String.IsNullOrEmpty(InheritFromPackageParentConfigurationString)) { var parentConfig = context.Package.DtsPackage.Configurations.Add(); parentConfig.ConfigurationType = Microsoft.SqlServer.Dts.Runtime.DTSConfigurationType.ParentVariable; parentConfig.Name = _dtsVariable.Name; parentConfig.PackagePath = String.Format(CultureInfo.InvariantCulture, @"\Package.Variables[{0}].Properties[Value]", _dtsVariable.QualifiedName); parentConfig.ConfigurationString = InheritFromPackageParentConfigurationString; } } }
public override void Emit(SsisEmitterContext context) { try { _forLoop = (DTS.ForLoop)context.ParentContainer.AppendExecutable(Moniker); context.ParentContainer.ProcessTaskBinding(this); _forLoop.Name = Name; _forLoop.TransactionOption = (DTSTransactionOption)Enum.Parse(typeof(DTSTransactionOption), TransactionMode); _forLoop.AssignExpression = _countingExpression; _forLoop.EvalExpression = _loopTestExpression; _forLoop.InitExpression = _initializerExpression; base.Emit(context); } catch (DtsException e) { if (e.ErrorCode == -1073659647) { MessageEngine.Trace(AstNamedNode, Severity.Error, "V1050", "Attempted to reuse the name '{0}' within an SSIS package, which is illegal. Use a unique name.", Name); } else { throw; } } }
public override void Initialize(SsisEmitterContext context) { base.Initialize(context); TransformationUtility.RegisterOleDBConnection(context, _oleDBConnection, Component); Instance.SetComponentProperty("SqlCommand", _astOleDBCommandNode.Query.Body); ProcessBindings(context); Flush(); }
public override void Initialize(SsisEmitterContext context) { base.Initialize(context); Component.CustomPropertyCollection["EliminateDuplicates"].Value = _astSortNode.EliminateDuplicates; Component.CustomPropertyCollection["MaximumThreads"].Value = _astSortNode.MaximumThreads; ProcessBindings(context); Flush(); }
public override void Emit(SsisEmitterContext context) { base.Emit(context); var fc = new FileConnection(Name + _relativePath, _relativePath); fc.Initialize(context); fc.Emit(context); ExecutePackageTaskObject.Connection = fc.Name; }
public override void Emit(SsisEmitterContext context) { base.Emit(context); foreach (PhysicalObject po in Children) { po.Initialize(context); po.Emit(context); } }
public override void Initialize(SsisEmitterContext context) { Component = Dataflow.NewComponentMetadata(); Component.ComponentClassID = Moniker; Instance = Component.Instantiate(); Instance.ProvideComponentProperties(); Component.Name = Name; Component.ValidateExternalMetadata = ValidateExternalMetadata; }
public override void Emit(SsisEmitterContext context) { _eventHandler = (DTS.DtsEventHandler)_hostExecutable.DtsEventsProvider.EventHandlers.Add(_eventName); context = new SsisEmitterContext(context.Package, this, context.ProjectManager); foreach (PhysicalObject po in this.Children) { po.Initialize(context); po.Emit(context); } }
public override void Initialize(SsisEmitterContext context) { base.Initialize(context); var v = new Framework.Variable(_astRowCountNode.Variable); v.Initialize(context); Component.CustomPropertyCollection["VariableName"].Value = v.DtsVariable.QualifiedName; ProcessBindings(context); Flush(); }
public override void Emit(SsisEmitterContext context) { ProcessBindings(context); // Configure Default Ouput Path Component.OutputCollection[0].Name = _astConditionalSplitNode.DefaultOutputPath.Name; foreach (AstConditionalSplitOutputPathNode opn in _astConditionalSplitNode.OutputPaths) { AppendOutputPath(opn.Name, opn.Expression); } }
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(); }
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; } } }
protected virtual void ProcessBindings(SsisEmitterContext context) { if (BindingList.Count > 0) { foreach (Binding b in BindingList) { ProcessBinding(context, b); } } else { ProcessAutoLexicalBinding(context); } }
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(); }
public override void Emit(SsisEmitterContext context) { base.Emit(context); _connection.Emit(context); SetProperty("Connection", _connection.Name); ExecuteSqlTask.ResultSetType = _resultSetTypeDTS; ExecuteSqlTask.SqlStatementSourceType = _sourceStatementTypeDTS; switch (_sourceStatementType) { case SqlTaskStatementType.File: string filePath; string fileName; _writeSqlToFile(context, out fileName, out filePath); var fileConnection = new FileConnection(fileName, filePath); fileConnection.Initialize(context); fileConnection.Emit(context); ExecuteSqlTask.SqlStatementSource = fileConnection.Name; break; case SqlTaskStatementType.Expression: ExecuteSqlTask.SqlStatementSource = Properties.Resources.Placeholder; SetExpression("SqlStatementSource", _body); break; default: throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, Properties.Resources.ErrorEnumerationTypeNotSupported, _sourceStatementType)); } // Parameter Binding int index = 0; foreach (ExecuteSqlParameter param in Parameters.Values) { BindParameter(param.VariableName, param.Direction, param.Name, (int)param.OleDBType, param.Length); index++; } foreach (ExecuteSqlResult executeSqlResult in Results.Values) { BindResult(executeSqlResult.Name, executeSqlResult.VariableName); } TryExecuteDuringDesignTime(); }
public override void Emit(SsisEmitterContext context) { ProcessBindings(context); foreach (AstDerivedColumnNode dc in _astDerivedColumnListNode.Columns) { if (dc.ReplaceExisting) { EmitReplaceExisting(dc); } else { EmitAddNewColumn(dc); } } }
private void _writeSqlToFile(SsisEmitterContext context, out string fileName, out string filePath) { fileName = Name + Properties.Resources.ExtensionSQLFile; filePath = Path.Combine(context.Package.PackageFolder, fileName); try { TextWriter sqlFileWriter = new StreamWriter(filePath, false, Encoding.Unicode); sqlFileWriter.Write(Body); sqlFileWriter.Close(); } catch (PathTooLongException e) { throw new PathTooLongException(String.Format(CultureInfo.InvariantCulture, "{0}: {1}", filePath, e.Message), e); } context.Package.SsisProject.MiscFiles.Add(fileName); }
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; } } } }
public override void Emit(SsisEmitterContext context) { int sortKey = 0; if (_astSortNode.AutoPassthrough) { foreach (string inputColumnName in GetVirtualInputColumns(0)) { SetInputColumnUsage(0, inputColumnName, DTSUsageType.UT_READONLY, false); } } foreach (AstSortColumnNode sc in _astSortNode.InputColumns) { if (sc.InputColumnUsageType == SortColumnUsageType.SortColumn || sc.InputColumnUsageType == SortColumnUsageType.Passthrough) { IDTSInputColumn100 input = SetInputColumnUsage(0, sc.Name, DTSUsageType.UT_READONLY, false); IDTSOutputColumn100 output = Component.OutputCollection[0].OutputColumnCollection[input.Name]; int comparisonFlags = 0; int sortKeyPosition = 0; if (sc.InputColumnUsageType == SortColumnUsageType.SortColumn) { ////uint comparisonFlags = (uint)ProcessSortType(sc.ComparisonFlags); comparisonFlags = (int)ProcessSortType(sc.ComparisonFlags); sortKeyPosition = ++sortKey; output.SortKeyPosition = sortKey; output.ComparisonFlags = (int)comparisonFlags; if (!String.IsNullOrEmpty(sc.OutputAs)) { output.Name = sc.OutputAs; } } input.CustomPropertyCollection["NewSortKeyPosition"].Value = sortKeyPosition; input.CustomPropertyCollection["NewComparisonFlags"].Value = comparisonFlags; } else { SetInputColumnUsage(0, sc.Name, DTSUsageType.UT_IGNORED, true); } } }
public override void Initialize(SsisEmitterContext context) { if (!IsInitialized) { if (context.Package.DtsPackage.Connections.Contains(Name)) { _connectionManager = context.Package.DtsPackage.Connections[Name]; ReusedExisting = true; } else { _connectionManager = context.Package.DtsPackage.Connections.Add(ConnectionType); _connectionManager.Name = Name; _connectionManager.ConnectionString = ConnectionString; } // Get reinitialized connection string. ConnectionString = _connectionManager.ConnectionString; } IsInitialized = true; }
public VulcanEngine.IR.IIR Execute(VulcanEngine.IR.IIR predecessorIR) { var physicalIR = predecessorIR as PhysicalIR; if (physicalIR != null) { int emittablesCount = 0; foreach (PhysicalObject root in physicalIR.EmittableNodes) { emittablesCount += root.Count; foreach (PhysicalObject emittable in root.Children) { var package = emittable as Package; if (package != null) { package.ClearProjectDirectory(); } } } // TODO: Progress bar is whacky. int emittablesProcessed = 0; var context = new SsisEmitterContext(); foreach (PhysicalObject root in physicalIR.EmittableNodes) { MessageEngine.UpdateProgress(emittablesProcessed / (double)emittablesCount); foreach (ISsisEmitter emittable in root.Children) { emittable.Initialize(context); emittable.Emit(context); } emittablesProcessed += root.Count; MessageEngine.UpdateProgress(emittablesProcessed / (double)emittablesCount); } } return(null); }
public override void Emit(SsisEmitterContext context) { try { _sequenceContainer = (DTS.Sequence)context.ParentContainer.AppendExecutable(Moniker); context.ParentContainer.ProcessTaskBinding(this); _sequenceContainer.Name = Name; _sequenceContainer.TransactionOption = (DTSTransactionOption)Enum.Parse(typeof(DTSTransactionOption), TransactionMode); base.Emit(context); } catch (DtsException e) { if (e.ErrorCode == -1073659647) { MessageEngine.Trace(AstNamedNode, Severity.Error, "V1050", "Attempted to reuse the name '{0}' within an SSIS package, which is illegal. Use a unique name.", Name); } else { throw; } } }
public override void Emit(SsisEmitterContext context) { Initialize(context); if (!ReusedExisting) { string connectionString = ConnectionString; ConnectionManager.ConnectionString = connectionString; SetProperty("RetainSameConnection", RetainSameConnection); // Need to unwind this and split it out logically. const string DtsConfigHeader = @"<DTSConfiguration> <DTSConfigurationHeading><DTSConfigurationFileInfo /></DTSConfigurationHeading>"; const string DtsPropertyConfig = @"<Configuration ConfiguredType=""Property"" Path=""\Package.Connections[{0}].Properties[{1}]"" ValueType=""String""> <ConfiguredValue>{2}</ConfiguredValue> </Configuration>"; const string DtsConfigFooter = "</DTSConfiguration>"; string configDirectory = PathManager.GetTargetSubpath(Properties.Settings.Default.SubpathPackageConfigurationProjectLocation); string configFile = PathManager.AddSubpath(configDirectory, String.Format(CultureInfo.InvariantCulture, "{0}.{1}", Name, Properties.Resources.ExtensionDtsConfigurationFile)); // Need to create the Target Directory :) Directory.CreateDirectory(configDirectory); using (var sw = new StreamWriter(configFile, false, Encoding.Unicode)) { sw.Write(DtsConfigHeader); sw.Write(DtsPropertyConfig, Name, "ConnectionString", OriginalConnectionString); sw.Write(DtsConfigFooter); sw.Flush(); sw.Close(); } var pc = new PackageConfiguration(Name); pc.Emit(context); } }
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(); }
public override void Initialize(SsisEmitterContext context) { base.Initialize(context); int accessMode; string xmlData = string.Empty; string xmlDataVariable = string.Empty; switch (_astXmlSourceNode.XmlDataAccessMode) { case XmlSourceDataAccessMode.XmlFileLocation: accessMode = 0; xmlData = _astXmlSourceNode.XmlData; break; case XmlSourceDataAccessMode.XmlFileFromVariable: accessMode = 1; xmlDataVariable = _astXmlSourceNode.XmlData; break; case XmlSourceDataAccessMode.XmlDataFromVariable: accessMode = 2; xmlDataVariable = _astXmlSourceNode.XmlData; break; default: throw new NotImplementedException(String.Format(CultureInfo.InvariantCulture, "XmlSource: Data Access Mode Type {0} Not Implemented", _astXmlSourceNode.XmlDataAccessMode)); } Instance.SetComponentProperty("XMLData", xmlData); Instance.SetComponentProperty("XMLDataVariable", xmlDataVariable); Instance.SetComponentProperty("XMLSchemaDefinition", _astXmlSourceNode.XmlSchemaDefinition); Instance.SetComponentProperty("UseInlineSchema", _astXmlSourceNode.UseInlineSchema); Instance.SetComponentProperty("AccessMode", accessMode); Flush(); }
public override void Emit(SsisEmitterContext context) { if (_astQuerySourceNode.Query.QueryType == QueryType.Expression) { Instance.SetComponentProperty("AccessMode", 3); Instance.SetComponentProperty("SqlCommandVariable", SqlCommandVarName); } else { Instance.SetComponentProperty("AccessMode", 2); Instance.SetComponentProperty("SqlCommand", _astQuerySourceNode.Query.Body.Trim()); } Flush(); var paramBuilder = new StringBuilder(); foreach (string index in _paramDictionary.Keys) { paramBuilder.AppendFormat("\"{0}\",{1};", index, _paramDictionary[index].DtsVariable.ID); } Instance.SetComponentProperty("ParameterMapping", paramBuilder.ToString()); }
public override void Emit(SsisEmitterContext context) { }
public override void Initialize(SsisEmitterContext context) { }