Esempio n. 1
0
        protected virtual IEnumerable <PackageInfo.ExecutionValueParameterSet> Parameterize(IEnumerable <EtlParameter> overridenParameters, PackageInfo package, string packageName)
        {
            var existingParameters = package.Parameters;

            if (package.Parent != null && package.Parent.Parameters != null)
            {
                foreach (var projectParam in package.Parent.Parameters)
                {
                    existingParameters.Add(projectParam);
                }
            }

            foreach (var param in overridenParameters)
            {
                if (!existingParameters.Contains(param.Name))
                {
                    var existingParameterList = String.Join("', '", existingParameters.Select(n => string.Format("{0} ({1})", n.Name, n.ObjectType)));
                    throw new ArgumentOutOfRangeException("overridenParameters", string.Format("No parameter named '{0}' found in the package {1}, can't override its value for execution. List of existing parameters '{2}'", param.Name, packageName, existingParameterList));
                }

                var existingParam = existingParameters[param.Name];
                var execParam     = new PackageInfo.ExecutionValueParameterSet()
                {
                    ObjectType     = existingParam.ObjectType,
                    ParameterName  = param.Name,
                    ParameterValue = DefineValue(param.StringValue, existingParam.DataType)
                };
                yield return(execParam);
            }
        }
Esempio n. 2
0
        private static string ScriptSetParameterValue(this PackageInfo @this, PackageInfo.ExecutionValueParameterSet parameterSet, int counter)
        {
            StringBuilder stringBuilder = new StringBuilder();
            Type          type          = parameterSet.ParameterValue.GetType();
            TypeCode      typeCode      = Type.GetTypeCode(type);
            string        arg           = Helpers.TypeCodeToSqlTypeString(typeCode);

            stringBuilder.AppendFormat("DECLARE @var{0} {1} = {2}\n", counter, arg, Helpers.FormatSqlVariant(parameterSet.ParameterValue));
            SfcTsqlProcFormatter sfcTsqlProcFormatter = new SfcTsqlProcFormatter();

            sfcTsqlProcFormatter.Procedure = string.Format(CultureInfo.InvariantCulture, "[{0}].[catalog].[set_execution_parameter_value] @execution_id, ", new object[]
            {
                @this.Parent.Parent.Parent.Name
            });

            List <SfcTsqlProcFormatter.RuntimeArg> list = new List <SfcTsqlProcFormatter.RuntimeArg>();

            SfcTsqlProcFormatter.RuntimeArg item = new SfcTsqlProcFormatter.RuntimeArg(typeof(short), parameterSet.ObjectType);
            list.Add(item);
            sfcTsqlProcFormatter.Arguments.Add(new SfcTsqlProcFormatter.SprocArg("object_type", true));
            item = new SfcTsqlProcFormatter.RuntimeArg(typeof(string), parameterSet.ParameterName);
            list.Add(item);
            sfcTsqlProcFormatter.Arguments.Add(new SfcTsqlProcFormatter.SprocArg("parameter_name", true));
            item = new SfcTsqlProcFormatter.RuntimeArg(typeof(object), "@var" + counter.ToString(CultureInfo.InvariantCulture));
            list.Add(item);
            sfcTsqlProcFormatter.Arguments.Add(new SfcTsqlProcFormatter.SprocArg("parameter_value", true));
            stringBuilder.Append(sfcTsqlProcFormatter.GenerateScript(@this, list));
            return(stringBuilder.ToString());
        }
Esempio n. 3
0
        protected virtual IEnumerable <PackageInfo.ExecutionValueParameterSet> Parameterize(IEnumerable <EtlParameter> overridenParameters, PackageInfo package)
        {
            var existingParameters = new List <ParameterInfo>();

            existingParameters.AddRange(package.Parameters);

            if (package?.Parent?.Parameters != null)
            {
                existingParameters.AddRange(package.Parent.Parameters);
            }

            foreach (var param in overridenParameters)
            {
                var existingParam = existingParameters.SingleOrDefault(x => x.Name == param.Name);
                if (existingParam == null)
                {
                    var existingParameterList = String.Join("', '", existingParameters.Select(n => $"\r\n - {n.Name} ({n.ObjectType})"));
                    throw new ArgumentOutOfRangeException(nameof(overridenParameters), $"No parameter named '{param.Name}' found in the package {package.Name}, can't override its value for execution. List of existing parameters:{existingParameterList}");
                }

                var execParam = new PackageInfo.ExecutionValueParameterSet()
                {
                    ObjectType     = (existingParam as ParameterInfo).ObjectType,
                    ParameterName  = param.Name,
                    ParameterValue = DefineValue(param.StringValue, (existingParam as ParameterInfo).DataType)
                };
                yield return(execParam);
            }
        }
Esempio n. 4
0
        protected virtual IEnumerable <PackageInfo.ExecutionValueParameterSet> Parameterize(IEnumerable <EtlParameter> overridenParameters, ParameterCollection existingParameters, string packageName)
        {
            foreach (var param in overridenParameters)
            {
                if (!existingParameters.Contains(param.Name))
                {
                    throw new ArgumentOutOfRangeException("overridenParameters", string.Format("No parameter named '{0}' found in the package {1}, can't override its value for execution.", param.Name, packageName));
                }

                var existingParam = existingParameters[param.Name];
                var execParam     = new PackageInfo.ExecutionValueParameterSet()
                {
                    ObjectType     = existingParam.ObjectType,
                    ParameterName  = param.Name,
                    ParameterValue = DefineValue(param.StringValue, existingParam.DataType)
                };
                yield return(execParam);
            }
        }
Esempio n. 5
0
        protected virtual IEnumerable<PackageInfo.ExecutionValueParameterSet> Parameterize(IEnumerable<EtlParameter> overridenParameters, ParameterCollection existingParameters, string packageName)
        {
            foreach (var param in overridenParameters)
            {
                if (!existingParameters.Contains(param.Name))
                    throw new ArgumentOutOfRangeException("overridenParameters", string.Format("No parameter named '{0}' found in the package {1}, can't override its value for execution.", param.Name, packageName));

                var existingParam = existingParameters[param.Name];
                var execParam = new PackageInfo.ExecutionValueParameterSet()
                {
                    ObjectType = existingParam.ObjectType,
                    ParameterName = param.Name,
                    ParameterValue = DefineValue(param.StringValue, existingParam.DataType)
                };
                yield return execParam;
            }
        }