Exemplo n.º 1
0
        ///<summary>
        /// TestStepBase.Execute() implementation
        ///</summary>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        ///<exception cref="ApplicationException"></exception>
        public override void Execute(Context context)
        {
            context.LogInfo("Executing SSIS package: {0}", PackageLocation);

            var ssisRuntime = new Microsoft.SqlServer.Dts.Runtime.Application();
            using (var package = ssisRuntime.LoadPackage(PackageLocation, null))
            {
                var variables = package.Variables;

                foreach (var variable in Variables)
                {
                    context.LogInfo("Adding variable: {0}, value: {1}", variable.Name, variable.Value);
                    variables[variable.Name].Value = variable.Value;
                }

                var result = package.Execute();

                var errors = package.Errors;
                foreach (var error in errors)
                {
                    context.LogError(error.Description);
                }

                if (Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success != result || 0 < errors.Count)
                {
                    throw new ApplicationException("Package execution failed.");
                }

                context.LogInfo("Package executed successfully.");
            }
        }
Exemplo n.º 2
0
        ///<summary>
        /// TestStepBase.Execute() implementation
        ///</summary>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        ///<exception cref="ApplicationException"></exception>
        public override void Execute(Context context)
        {
            context.LogInfo("Executing SSIS package: {0}", PackageLocation);

            var ssisRuntime = new Microsoft.SqlServer.Dts.Runtime.Application();

            using (var package = ssisRuntime.LoadPackage(PackageLocation, null))
            {
                var variables = package.Variables;

                foreach (var variable in Variables)
                {
                    context.LogInfo("Adding variable: {0}, value: {1}", variable.Name, variable.Value);
                    variables[variable.Name].Value = variable.Value;
                }

                var result = package.Execute();

                var errors = package.Errors;
                foreach (var error in errors)
                {
                    context.LogError(error.Description);
                }

                if (Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success != result || 0 < errors.Count)
                {
                    throw new ApplicationException("Package execution failed.");
                }

                context.LogInfo("Package executed successfully.");
            }
        }
    public void Main()
    {
        List <SSISVariable> _coll = new List <SSISVariable>();

        Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
        Package   pkg     = app.LoadPackage(PackageLocation, Null);
        Variables pkgVars = pkg.Variables;

        foreach (Variable pkgVar in pkgVars)
        {
            if (pkgVar.Namespace.ToString() == "User")
            {
                _coll.Add(new SSISVariable()
                {
                    Name = pkgVar.Name.ToString(),
                    Val  = pkgVar.Value.ToString()
                });
            }
        }
        InsertIntoTable(_coll);
        Dts.TaskResult = (int)ScriptResults.Success;
    }