Пример #1
0
        public static void AddExecPackageTask(Executable exe, string TaskName, string connectionKey)
        {
            TaskHost th = exe as TaskHost;

            th.Name = TaskName;
            IDTSExecutePackage100 exePkgTask = th.InnerObject as IDTSExecutePackage100;

            exePkgTask.Connection = connectionKey;
        }
        private void CheckExecutePackageTask(TaskHost taskHost, TreeNode parent)
        {
            // We have a reference to Microsoft.SqlServer.ExecPackageTaskWrap.dll
            // Only ever use interfaces which are consistent between versions of SSIS, cannot use reflection because task is native, not managed code.
            IDTSExecutePackage100 task = taskHost.InnerObject as IDTSExecutePackage100;

            // Potential issue because of multiple version support in SQL Server 2016+. Is the reference to the correct version?
            if (task == null)
            {
                // Task is null following cast to IDTSExecutePackage100, therefore we have the wrong Microsoft.SqlServer.ExecPackageTaskWrap reference
                // Produce a false found variable for feedback to the UI, else a null referece exception will break the search
                VariableFoundEventArgs info = new VariableFoundEventArgs();
                info.Match = "Invalid IDTSExecutePackage100 reference";
                OnRaiseVariableFound(info);
                AddNode(parent, info.Match, GetImageIndex(IconKeyError), new DisplayProperty("InvalidIDTSExecutePackage100", info.Match), true);
                return;
            }

            TreeNode parameterAssignments = AddFolder("ParameterAssignments", parent);

            // IDTSParameterAssignment doesn't support foreach enumeration, so use for loop instead.
            // Why? ParameterAssignments -> IDTSParameterAssignments -> IEnumerable
            for (int i = 0; i < task.ParameterAssignments.Count; i++)
            {
                IDTSParameterAssignment assignment = task.ParameterAssignments[i];

                string match;
                string value = assignment.BindedVariableOrParameterName;
                if (!string.IsNullOrEmpty(value) && PropertyMatchEval(value, out match))
                {
                    VariableFoundEventArgs info = new VariableFoundEventArgs();
                    info.Match = match;
                    OnRaiseVariableFound(info);
                    AddNode(parameterAssignments, assignment.ParameterName.ToString(), GetImageIndex(IconKeyProperty), assignment, true);
                }
            }
        }