Exemple #1
0
        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;
                }
            }
        }
        void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            DataGridView d = (DataGridView)sender;

            // Se si sta per modificare il valore del parametro...
            if (e.ColumnIndex == 2)
            {
                ParamBinding b = (ParamBinding)Enum.Parse(typeof(ParamBinding), d.Rows[e.RowIndex].Cells[1].Value.ToString());
                // Se la riga corrente si riferisce ad un parametro variable-bound, fai in modo che si apra il popup della scelta delle variabili.
                if (b == ParamBinding.Variable)
                {
                    // Mostra il dialog di scelta delle variabili
                    VariableChooser vc = new VariableChooser(_vars);
                    DialogResult    dr = vc.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        Microsoft.SqlServer.Dts.Runtime.Variable v = vc.GetResult();
                        d.Rows[e.RowIndex].Cells[2].Value = v.QualifiedName;
                        e.Cancel = true;
                        //d.EndEdit();
                    }
                }
                else if (b == ParamBinding.InputField)
                {
                    if (_input_options == null || _input_options.Length < 1)
                    {
                        MessageBox.Show("There is no input attached to this lane. First attach an input, then you'll be able to select a vale from this box.");
                        e.Cancel = true;
                    }
                }
            }
        }
Exemple #3
0
        private void SetComponentProperties(OLEDBSource source)
        {
            switch (source.AccessMode)
            {
            case DataFlowSourceQueryAccessMode.SQLCOMMAND:
                _instance.SetComponentProperty("AccessMode", 2);
                _instance.SetComponentProperty("SqlCommand", source.Body);
                Flush();
                break;

            case DataFlowSourceQueryAccessMode.SQLCOMMANDFROMVARIABLE:
                _instance.SetComponentProperty("AccessMode", 3);

                DTS.Variable sqlCommandVariable = SsisPackage.CurrentPackage.DTSPackage.Variables.Add(
                    ("var" + Guid.NewGuid().ToString()).Replace("-", string.Empty)
                    , false
                    , "User"
                    , string.Empty);
                sqlCommandVariable.EvaluateAsExpression = true;
                sqlCommandVariable.Expression           = source.Body;
                _instance.SetComponentProperty("SqlCommandVariable", sqlCommandVariable.Name);
                Flush();
                break;

            default:
                MessageEngine.Global.Trace(Severity.Error, "Unknown Source Data Access Mode Type of {0}", source.AccessMode);
                break;
            }
        }
Exemple #4
0
        public string BuildRelativeExpression(string rootPathVariableName, params string[] pathNodes)
        {
            StringBuilder sb = new StringBuilder();

            //"@[User::varRootDir] + \"" + VulcanPackage._pathSlightlyDirtier(pathRelativeToVarRootDir) + "\"";
            if (!_vulcanPackage.DTSPackage.Variables.Contains(rootPathVariableName))
            {
                Message.Trace(Severity.Alert, "Root path variable {0} does not exist. Creating {0} with type {1}", rootPathVariableName, TypeCode.String);
                _vulcanPackage.AddVariable(rootPathVariableName, Resources.Placeholder);
            }
            else if (_vulcanPackage.DTSPackage.Variables[rootPathVariableName].DataType != TypeCode.String)
            {
                Message.Trace(Severity.Error, "Variable {0} is not of type {1}", rootPathVariableName, TypeCode.String);
            }
            DTS.Variable rootVar = _vulcanPackage.DTSPackage.Variables[rootPathVariableName];

            sb.AppendFormat("@[{0}] + \"", rootVar.QualifiedName);
            foreach (string s in pathNodes)
            {
                sb.AppendFormat(@"\\{0}", EscapeBackslashes(PathCleaner(s)));
            }
            sb.AppendFormat("\"");

            return(sb.ToString());
        }
Exemple #5
0
        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;
                }
            }
        }
Exemple #6
0
 private void BindParameter(DTS.Variable variable, DTSTasks.ExecuteSQLTask.ParameterDirections direction, string parameterName, int dataType, int size)
 {
     DTSTasks.ExecuteSQLTask.IDTSParameterBinding binding = SSISTask.ParameterBindings.Add();
     binding.DtsVariableName    = variable.QualifiedName;
     binding.ParameterDirection = direction;
     binding.ParameterName      = parameterName;
     binding.ParameterSize      = size;
     binding.DataType           = dataType;
 }
Exemple #7
0
 public void Delete()
 {
     if (null != _parentContainer && null != _dtsVariable)
     {
         _parentContainer.Variables.Remove(_dtsVariable.ID);
         _dtsVariable     = null;
         _parentContainer = null;
     }
 }
Exemple #8
0
 public void BindParameter(DTS.Variable variable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections direction, string parameterName, int dataType, int size)
 {
     DTSTasks.ExecuteSQLTask.IDTSParameterBinding binding = ExecuteSQLTask.ParameterBindings.Add();
     binding.DtsVariableName    = variable.QualifiedName;
     binding.ParameterDirection = direction;
     binding.ParameterName      = parameterName;
     binding.ParameterSize      = size;
     binding.DataType           = dataType;
 }
Exemple #9
0
 public void Delete()
 {
     if (null != _parentContainer && null != _dtsVariable)
     {
         _parentContainer.Variables.Remove(_dtsVariable.ID);
         _dtsVariable = null;
         _parentContainer = null;
     }
 }
Exemple #10
0
        private void button3_Click(object sender, EventArgs e)
        {
            IDtsVariableService vservice = (IDtsVariableService)_sp.GetService(typeof(IDtsVariableService));

            Microsoft.SqlServer.Dts.Runtime.Variable vv = vservice.PromptAndCreateVariable(this, null, "COOKIES_" + this.Name, "User", typeof(object));
            if (vv != null)
            {
                cookieVarTb.Text = vv.QualifiedName;
            }
        }
Exemple #11
0
 public SsisVariable(string name, object value, DTS.DtsContainer parentContainer)
 {
     if (null == parentContainer)
     {
         this._parentContainer = (DTS.DtsContainer)SsisPackage.CurrentPackage.DTSPackage;
     }
     else
     {
         this._parentContainer = parentContainer;
     }
     _dtsVariable = _addVariable(name, value, _parentContainer);
 }
Exemple #12
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string firstOrLast = patternNavigator.SelectSingleNode("@FirstOrLast").Value;
                string status      = patternNavigator.SelectSingleNode("@Status").Value;
                string notes       = patternNavigator.SelectSingleNode("@Notes").Value;

                Connection tableConnection =
                    Connection.GetExistingConnection(VulcanPackage, LogtainerPattern.CurrentLog.TableConnectionName);

                string          execSqlTaskName = LogtainerPattern.CurrentLog.LogName + Resources.Seperator + firstOrLast + Guid.NewGuid();
                TemplateEmitter te = new TemplateEmitter(VulcanPackage.TemplateManager["LogSelectQuery"]);
                if (
                    LogtainerPattern.CurrentLog.SourceColumn == null ||
                    LogtainerPattern.CurrentLog.DestinationColumn == null ||
                    LogtainerPattern.CurrentLog.TableConnectionName == null ||
                    LogtainerPattern.CurrentLog.Table == null)
                {
                    Message.Trace(Severity.Error,
                                  "Could not perform LogUpdate (On Log: {0}), Parent Logtainer does not contain all of the necessary information.  Needs SourceColumn, DestinationColumn, TableConnectionName, and Table attributes.", LogtainerPattern.CurrentLog.LogName);
                    return;
                }

                te.SetNamedParameter("Source", LogtainerPattern.CurrentLog.SourceColumn);
                te.SetNamedParameter("Destination", LogtainerPattern.CurrentLog.DestinationColumn);
                te.SetNamedParameter("Table", LogtainerPattern.CurrentLog.Table);
                te.SetNamedParameter("Status", status);
                te.SetNamedParameter("Notes", notes);
                te.SetNamedParameter("SourceConvertStyle", "21");
                te.SetNamedParameter("DestinationConvertStyle", "21");

                string query;
                te.Emit(out query);

                SQLTask readForLogTask = new SQLTask(VulcanPackage, execSqlTaskName, execSqlTaskName, ParentContainer, tableConnection);
                readForLogTask.TransmuteToExpressionTask(String.Format("\"{0}\"", query));
                readForLogTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_SingleRow;

                DTS.Variable sourceVar = LogtainerPattern.CurrentLog[firstOrLast + "SourceRecord"];
                DTS.Variable destVar   = LogtainerPattern.CurrentLog[firstOrLast + "DestinationRecord"];
                DTS.Variable statusVar = LogtainerPattern.CurrentLog["Status"];
                DTS.Variable notesVar  = LogtainerPattern.CurrentLog["Notes"];

                readForLogTask.BindResult("0", sourceVar.QualifiedName);
                readForLogTask.BindResult("1", destVar.QualifiedName);
                readForLogTask.BindResult("2", statusVar.QualifiedName);
                readForLogTask.BindResult("3", notesVar.QualifiedName);

                this.FirstExecutableGeneratedByPattern = readForLogTask.SQLTaskHost;
                this.LastExecutableGeneratedByPattern  = this.FirstExecutableGeneratedByPattern;
            }
        }
Exemple #13
0
 private void addButton_Click(object sender, EventArgs e)
 {
     if (variableR.Checked)
     {
         IDtsVariableService vservice = (IDtsVariableService)_sp.GetService(typeof(IDtsVariableService));
         Microsoft.SqlServer.Dts.Runtime.Variable vv = vservice.PromptAndCreateVariable(this, null, null, "User", typeof(string));
         if (vv != null)
         {
             uiWebURL.Text = vv.QualifiedName;
         }
     }
 }
Exemple #14
0
 public SsisVariable(string name, object value, DTS.DtsContainer parentContainer)
 {
     if (null == parentContainer)
     {
         this._parentContainer = (DTS.DtsContainer)SsisPackage.CurrentPackage.DTSPackage;
     }
     else
     {
         this._parentContainer = parentContainer;
     }
     _dtsVariable = _addVariable(name, value, _parentContainer);
 }
Exemple #15
0
 public DTS.Variable AddVariable(string name, object value)
 {
     if (!DTSPackage.Variables.Contains(name))
     {
         Message.Trace(Severity.Alert, "Creating variable {0} with value {1}", name, value);
         DTS.Variable var = _package.Variables.Add(name, false, "User", value);
         return(var);
     }
     else
     {
         return(DTSPackage.Variables[name]);
     }
 }
Exemple #16
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);
        }
Exemple #17
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);
        }
Exemple #18
0
        private void button4_Click(object sender, EventArgs e)
        {
            VariableChooser vc = new VariableChooser(_vars, new TypeCode[] { TypeCode.Object }, null);
            DialogResult    dr = vc.ShowDialog();

            if (dr == DialogResult.OK)
            {
                Microsoft.SqlServer.Dts.Runtime.Variable v = vc.GetResult();
                if (v.DataType != TypeCode.Object)
                {
                    MessageBox.Show("The cookie variable MUST be of type \"Object\".");
                    return;
                }
                cookieVarTb.Text = v.QualifiedName;
            }
        }
Exemple #19
0
        private DTS.Variable _addVariable(string name, object value, DTS.DtsContainer dtsContainer)
        {
            _name = name;

            SetVariablePath(dtsContainer);

            if (!dtsContainer.Variables.Contains(name))
            {
                MessageEngine.Global.Trace(Severity.Alert, "Creating variable {0} with value {1} in Container {2}", name, value, dtsContainer.Name);
                DTS.Variable var = dtsContainer.Variables.Add(name, false, "User", value);
                _dtsVariable = var;
                return var;
            }
            else
            {
                _dtsVariable = dtsContainer.Variables[name];
                return dtsContainer.Variables[name];
            }
        }
Exemple #20
0
        private DTS.Variable _addVariable(string name, object value, DTS.DtsContainer dtsContainer)
        {
            _name = name;

            SetVariablePath(dtsContainer);

            if (!dtsContainer.Variables.Contains(name))
            {
                MessageEngine.Global.Trace(Severity.Alert, "Creating variable {0} with value {1} in Container {2}", name, value, dtsContainer.Name);
                DTS.Variable var = dtsContainer.Variables.Add(name, false, "User", value);
                _dtsVariable = var;
                return(var);
            }
            else
            {
                _dtsVariable = dtsContainer.Variables[name];
                return(dtsContainer.Variables[name]);
            }
        }
Exemple #21
0
        private void SetParameterMapping(IList <DataFlowSourceQueryParameter> parameters, DTS.Variables variables)
        {
            StringBuilder parameterBuilder = new StringBuilder();

            foreach (DataFlowSourceQueryParameter param in parameters)
            {
                if (variables.Contains(param.VariableName))
                {
                    DTS.Variable variable = variables[param.VariableName];
                    parameterBuilder.AppendFormat("\"{0}\",{1};", param.Name, variable.ID);
                }
                else
                {
                    MessageEngine.Global.Trace(Severity.Error, Resources.DTSVariableNotExists, param.VariableName);
                }
            }

            _instance.SetComponentProperty("ParameterMapping", parameterBuilder.ToString());
        }
Exemple #22
0
 private void browseButton_Click(object sender, EventArgs e)
 {
     // If variable is selected, open the variable browser, otherwise open the file browser
     if (variableR.Checked)
     {
         VariableChooser vc = new VariableChooser(_vars, new TypeCode[] { TypeCode.String }, null);
         DialogResult    dr = vc.ShowDialog();
         if (dr == DialogResult.OK)
         {
             Microsoft.SqlServer.Dts.Runtime.Variable v = vc.GetResult();
             uiWebURL.Text = v.QualifiedName;
         }
     }
     else
     {
         var res = openFileDialog1.ShowDialog(this);
         if (res == DialogResult.OK)
         {
             // Update the textedit with the file path
             uiWebURL.Text = openFileDialog1.FileName;
         }
     }
 }
Exemple #23
0
 public void BindParameter(DTS.Variable variable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections direction, int dataType)
 {
     BindParameter(variable, direction, dataType, -1);
 }
Exemple #24
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            // Reloads invalidate the ParentContainer, so we should do it much later.
            string etlName =
                patternNavigator.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;

            Message.Trace(Severity.Notification, "{0}", etlName);
            bool delayValidation = patternNavigator.SelectSingleNode("@DelayValidation").ValueAsBoolean;

            string sourceName = patternNavigator.SelectSingleNode("rc:SourceConnection/@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;

            Connection sourceConnection =
                Connection.GetExistingConnection(
                    VulcanPackage,
                    patternNavigator.SelectSingleNode("rc:SourceConnection/@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value
                    );

            if (sourceConnection != null)
            {
                string query = patternNavigator.SelectSingleNode("rc:Query", VulcanPackage.VulcanConfig.NamespaceManager).Value.Trim();

                // Add the Data Flow Task to the Package.
                DTS.TaskHost pipeHost = (DTS.TaskHost)ParentContainer.Executables.Add("STOCK:PipelineTask");
                pipeHost.Properties["DelayValidation"].SetValue(pipeHost, delayValidation);
                MainPipe dataFlowTask = (MainPipe)pipeHost.InnerObject;
                pipeHost.Name = etlName;

                // Add the Source (this is temporary and will be replaced with a new style of Source element)
                IDTSComponentMetaData90 sourceDataComponent = dataFlowTask.ComponentMetaDataCollection.New();
                sourceDataComponent.ComponentClassID = "DTSAdapter.OleDbSource.1";

                // IMPORTANT! If you do not Instantiate() and ProvideComponentProperties first,
                // the component names do not get set... this is bad.
                CManagedComponentWrapper oleInstance = sourceDataComponent.Instantiate();
                oleInstance.ProvideComponentProperties();

                sourceDataComponent.Name = etlName + " Source";

                if (sourceDataComponent.RuntimeConnectionCollection.Count > 0)
                {
                    sourceDataComponent.RuntimeConnectionCollection[0].ConnectionManager =
                        DTS.DtsConvert.ToConnectionManager90(
                            sourceConnection.ConnectionManager
                            );
                    sourceDataComponent.RuntimeConnectionCollection[0].ConnectionManagerID =
                        sourceConnection.ConnectionManager.ID;
                }

                oleInstance.SetComponentProperty("AccessMode", 2);
                oleInstance.SetComponentProperty("SqlCommand", query);

                try
                {
                    oleInstance.AcquireConnections(null);
                    oleInstance.ReinitializeMetaData();
                    oleInstance.ReleaseConnections();
                }
                catch (System.Runtime.InteropServices.COMException ce)
                {
                    Message.Trace(Severity.Error, ce, "OLEDBSource:{0}: {1}: Source {2}: Query {3}", sourceDataComponent.GetErrorDescription(ce.ErrorCode), ce.Message, sourceConnection.ConnectionManager.Name, query);
                }
                catch (Exception e)
                {
                    Message.Trace(Severity.Error, e, "OLEDBSource:{0}: Source {1}: Query {2}", e.Message, sourceConnection.ConnectionManager.Name, query);
                }

                //Map parameter variables:

                StringBuilder parameterBuilder = new StringBuilder();
                foreach (XPathNavigator paramNav in patternNavigator.Select("rc:Parameter", VulcanPackage.VulcanConfig.NamespaceManager))
                {
                    string name    = paramNav.SelectSingleNode("@Name").Value;
                    string varName = paramNav.SelectSingleNode("@VariableName").Value;

                    if (VulcanPackage.DTSPackage.Variables.Contains(varName))
                    {
                        DTS.Variable variable = VulcanPackage.DTSPackage.Variables[varName];
                        parameterBuilder.AppendFormat("\"{0}\",{1};", name, variable.ID);
                    }
                    else
                    {
                        Message.Trace(Severity.Error, "DTS Variable {0} does not exist", varName);
                    }
                }

                oleInstance.SetComponentProperty("ParameterMapping", parameterBuilder.ToString());

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

                XPathNavigator destNav = patternNavigator.SelectSingleNode("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, parentComponent, 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 nav in destNav.Select("rc:Map", VulcanPackage.VulcanConfig.NamespaceManager))
                    {
                        string source = nav.SelectSingleNode("@Source").Value;
                        string destination;
                        bool   unMap = false;

                        if (nav.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;
            } //END sourceConnection != null
            else
            {
                Message.Trace(Severity.Error, "Source Connection {0} does not exist in {1}", sourceName, etlName);
            }
        } //END function Emit
Exemple #25
0
 public void BindParameter(DTS.Variable variable, Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ParameterDirections direction, int dataType, int size)
 {
     BindParameter(variable, direction, _parameterIndex.ToString(), dataType, size);
     _parameterIndex++;
 }