Beispiel #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;
                }
            }
        }
Beispiel #2
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;
                }
            }
        }
Beispiel #3
0
 public void Delete()
 {
     if (null != _parentContainer && null != _dtsVariable)
     {
         _parentContainer.Variables.Remove(_dtsVariable.ID);
         _dtsVariable     = null;
         _parentContainer = null;
     }
 }
Beispiel #4
0
 public void Delete()
 {
     if (null != _parentContainer && null != _dtsVariable)
     {
         _parentContainer.Variables.Remove(_dtsVariable.ID);
         _dtsVariable = null;
         _parentContainer = null;
     }
 }
 public void SetSSISObjectBaseProperties(SSIS.DtsContainer container)
 {
     container.Name        = Name;
     container.Description = Description;
     if (container.GetType() != typeof(SSIS.Package))
     {
         container.FailPackageOnFailure = true;
         container.FailParentOnFailure  = true;
     }
 }
Beispiel #6
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);
 }
Beispiel #7
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);
 }
Beispiel #8
0
        private static void SetVariablePath(DTS.DtsContainer dtsContainer)
        {
            var path = new StringBuilder(dtsContainer.Name);

            while (dtsContainer.Parent != null)
            {
                dtsContainer = dtsContainer.Parent;
                path.Insert(0, "/");
                path.Insert(0, dtsContainer.Name);
            }

            path.Insert(0, "/Root/");
        }
Beispiel #9
0
        private void SetVariablePath(DTS.DtsContainer dtsContainer)
        {
            StringBuilder sPath = new StringBuilder(dtsContainer.Name);

            while (dtsContainer.Parent != null)
            {
                dtsContainer = dtsContainer.Parent;
                sPath.Insert(0, "/");
                sPath.Insert(0, dtsContainer.Name);
            }

            sPath.Insert(0, "/Root/");
            _path = sPath.ToString();
        }
Beispiel #10
0
        public static string EvaluateSSISExpression(string expression, DTS.DtsContainer container)
        {
            var dtsVariable =
                container.Variables.Add("__" + Guid.NewGuid().ToString("N"), false, "User", null);

            dtsVariable.EvaluateAsExpression = true;
            dtsVariable.Expression           = expression;

            string retval = dtsVariable.Value.ToString();

            container.Variables.Remove(dtsVariable.ID);

            return(retval);
        }
Beispiel #11
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]);
            }
        }
Beispiel #12
0
        public string GetVariablePathXML()
        {
            DTS.DtsContainer dtsContainer = _parentContainer;

            StringBuilder sPath = new StringBuilder();

            sPath.AppendFormat("<{0}></{1}>", dtsContainer.Name, dtsContainer.Name);

            while (dtsContainer.Parent != null)
            {
                dtsContainer = dtsContainer.Parent;
                sPath.Insert(0, ">");
                sPath.Insert(0, dtsContainer.Name);
                sPath.Insert(0, "<");
                sPath.AppendFormat("</{0}>", dtsContainer.Name);
            }

            sPath.Insert(0, "'<Root>");
            sPath.Append("</Root>'");
            return(sPath.ToString());
        }