private void FindUnusedButtonClick()
        {
            try
            {
#if DENALI || SQL2014
                packageDesigner = (ComponentDesigner)variablesToolWindowControl.GetType().GetProperty("PackageDesigner", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance).GetValue(variablesToolWindowControl, null);
#else
                packageDesigner = (ComponentDesigner)variablesToolWindowControl.GetType().InvokeMember("PackageDesigner", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, variablesToolWindowControl, null);
#endif

                if (packageDesigner == null)
                {
                    return;
                }

                Package package = packageDesigner.Component as Package;
                if (package == null)
                {
                    return;
                }

                FindUnusedVariables dialog = new FindUnusedVariables(VariablesDisplayMode.Variables);
                if (dialog.Show(package) == DialogResult.OK)
                {
                    // Dialog result OK indicates we have deleted one or more variables
                    // Flag package as dirty
                    SSISHelpers.MarkPackageDirty(package);

                    // Refresh the grid
                    variablesToolWindowControl.GetType().InvokeMember("FillGrid", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance, null, variablesToolWindowControl, new object[] { });
                    SetButtonEnabled();
                    RefreshHighlights();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace);
            }
        }
예제 #2
0
            private void FindUnusedButtonClick()
            {
                try
                {
                    ComponentDesigner packageDesigner = (ComponentDesigner)variablesToolWindowControl.GetType().GetProperty("PackageDesigner", BindingFlags.NonPublic | BindingFlags.GetProperty | BindingFlags.FlattenHierarchy | BindingFlags.Instance).GetValue(variablesToolWindowControl, null);
                    if (packageDesigner == null)
                    {
                        return;
                    }

                    Package package = packageDesigner.Component as Package;
                    if (package == null)
                    {
                        return;
                    }

                    FindUnusedVariables dialog = new FindUnusedVariables(VariablesDisplayMode.PackageParameters);
                    dialog.Show(package);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace);
                }
            }