public void Init(EditorWindow parentWin, EditorWindow.EditorView view, ProjectItem pi, string DataFlowGUID)
        {
            this.parentWin   = parentWin;
            this.parentView  = view;
            this.projectItem = pi;

            //capture the project manager object
            sharedDataWarehouseInterfaces::Microsoft.DataWarehouse.Interfaces.IConfigurationSettings settings = (sharedDataWarehouseInterfaces::Microsoft.DataWarehouse.Interfaces.IConfigurationSettings)((System.IServiceProvider)pi.ContainingProject).GetService(typeof(sharedDataWarehouseInterfaces::Microsoft.DataWarehouse.Interfaces.IConfigurationSettings));
            this.projectManager = (Microsoft.DataWarehouse.Project.DataWarehouseProjectManager)settings.GetType().InvokeMember("ProjectManager", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy, null, settings, null);

            //capture the output window object
            IOutputWindowFactory service = ((System.IServiceProvider)pi.ContainingProject).GetService(typeof(IOutputWindowFactory)) as IOutputWindowFactory;

            this.standardOutputWindow = service.GetStandardOutputWindow(StandardOutputWindow.Debug);

            //run the package immediately
            if (DataFlowGUID == null)
            {
                ExecutePackage();
            }
            else
            {
                BreakdownPipelinePerformance(DataFlowGUID);
            }
        }
Example #2
0
            private void editorWindow_ActiveViewChanged(object sender, EventArgs e)
            {
                if (setupComplete)
                {
                    return;
                }

                // Get the EditorWindow, Microsoft.DataTransformationServices.Design.DtsPackageView
                editorWindow = sender as EditorWindow;

                if (editorWindow.Tag != this)
                {
                    Debug.Assert(false);
                }

                EditorWindow.EditorView view = editorWindow.SelectedView;
                if (view.Caption == "Parameters") // Microsoft.DataTransformationServices.Design.SR.PackageParametersViewCaption
                {
                    object      viewControl = view.GetType().InvokeMember("viewControl", getFieldFlags, null, view, null);
                    UserControl control     = (UserControl)viewControl; // PackageParametersControl
                    variablesToolWindowControl = (VariablesToolWindow)control.Controls[0];

                    SetupControl();
                }
            }
Example #3
0
        //they asked to pop up the Package Configurations dialog, so replace the Microsoft functionality so we can control the popup form
        void cmdEvent_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
        {
            if (Enabled)
            {
                try
                {
                    if (this.ApplicationObject.ActiveWindow == null || this.ApplicationObject.ActiveWindow.ProjectItem == null)
                    {
                        return;
                    }
                    ProjectItem pi = this.ApplicationObject.ActiveWindow.ProjectItem;
                    if (!pi.Name.ToLower().EndsWith(".dtsx"))
                    {
                        return;
                    }

                    IDesignerHost designer = this.ApplicationObject.ActiveWindow.Object as IDesignerHost;
                    if (designer == null)
                    {
                        return;
                    }
                    EditorWindow win     = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
                    Package      package = (Package)win.PropertiesLinkComponent;
                    this.packageForFixButton        = package;
                    this.pathForPackageForFixButton = pi.get_FileNames(1);

                    DtsConfigurationsForm form = new DtsConfigurationsForm(package);
                    if (win.SelectedIndex == 0)
                    {
                        //control flow
                        EditorWindow.EditorView        view     = win.SelectedView;
                        System.Reflection.BindingFlags getflags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
                        Control viewControl = (Control)view.GetType().InvokeMember("ViewControl", getflags, null, view, null);

                        IWin32Window parentWin;
                        #if DENALI || SQL2014
                        parentWin = viewControl;
                        #else
                        DdsDiagramHostControl diagram = viewControl.Controls["panel1"].Controls["ddsDiagramHostControl1"] as DdsDiagramHostControl;
                        if (diagram == null || diagram.DDS == null)
                        {
                            return;
                        }
                        parentWin = diagram.DDS;
                        #endif

                        Button  editSelectedButton = (Button)form.Controls["editSelectedConfiguration"];
                        Control packageConfigurationsGridControl1 = form.Controls["packageConfigurationsGridControl1"];
                        Button  btnRelativePaths = new Button();
                        btnRelativePaths.Text   = "Fix All Relative Paths";
                        btnRelativePaths.Width  = 140;
                        btnRelativePaths.Left   = packageConfigurationsGridControl1.Left;
                        btnRelativePaths.Top    = editSelectedButton.Top;
                        btnRelativePaths.Height = editSelectedButton.Height;
                        btnRelativePaths.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
                        btnRelativePaths.Click += new EventHandler(btnRelativePaths_Click);
                        form.Controls.Add(btnRelativePaths);

                        if (DesignUtils.ShowDialog((Form)form, parentWin, (IServiceProvider)package.Site) == DialogResult.OK)
                        {
                            SSISHelpers.MarkPackageDirty(package);
                        }

                        CancelDefault = true;
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
                }
            }
        }
        private bool IsContextMenuLocationValid(out string DataFlowGUID)
        {
            DataFlowGUID = null;
            try
            {
                if (this.ApplicationObject.ActiveWindow == null || this.ApplicationObject.ActiveWindow.ProjectItem == null)
                {
                    return(false);
                }
                ProjectItem pi = this.ApplicationObject.ActiveWindow.ProjectItem;
                if (!pi.Name.ToLower().EndsWith(".dtsx"))
                {
                    return(false);
                }

                if (pi.ContainingProject == null || pi.ContainingProject.Kind != BIDSProjectKinds.SSIS)
                {
                    return(false);                                                                                    //if the dtsx isn't in an SSIS project, or if you're editing the package standalone (not as a part of a project)
                }
                IDesignerHost designer = this.ApplicationObject.ActiveWindow.Object as IDesignerHost;
                if (designer == null)
                {
                    return(false);
                }
                EditorWindow win     = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
                Package      package = (Package)win.PropertiesLinkComponent;

                if (win.SelectedIndex == (int)SSISHelpers.SsisDesignerTabIndex.ControlFlow)
                {
                    //control flow
                    EditorWindow.EditorView view = win.SelectedView;
                    Control viewControl          = (Control)view.GetType().InvokeMember("ViewControl", getflags, null, view, null);

                    Microsoft.SqlServer.IntegrationServices.Designer.Model.ControlFlowGraphModelElement ctlFlowModel = (Microsoft.SqlServer.IntegrationServices.Designer.Model.ControlFlowGraphModelElement)viewControl.GetType().InvokeMember("GraphModel", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty, null, viewControl, null);
                    if (ctlFlowModel == null)
                    {
                        return(false);
                    }
                    Microsoft.SqlServer.IntegrationServices.Designer.Model.TaskModelElement taskModelEl = ctlFlowModel.SelectedItems[0] as Microsoft.SqlServer.IntegrationServices.Designer.Model.TaskModelElement;
                    if (taskModelEl == null)
                    {
                        return(false);
                    }
                    TaskHost task = taskModelEl.TaskHost;
                    if (task == null)
                    {
                        return(false);
                    }
                    if (!(task.InnerObject is MainPipe))
                    {
                        return(false);
                    }
                    DataFlowGUID = taskModelEl.LogicalID;
                    return(true);
                }
                else if (win.SelectedIndex == (int)SSISHelpers.SsisDesignerTabIndex.DataFlow)
                {
                    //data flow
                    EditorWindow.EditorView view = win.SelectedView;
                    Control viewControl          = (Control)view.GetType().InvokeMember("ViewControl", getflags, null, view, null);
                    Microsoft.DataTransformationServices.Design.Controls.PipelineComboBox pipelineComboBox = (Microsoft.DataTransformationServices.Design.Controls.PipelineComboBox)(viewControl.Controls["panel1"].Controls["pipelineComboBox"]);
                    foreach (Control c in viewControl.Controls["panel2"].Controls["pipelineDetailsControl"].Controls)
                    {
                        if (!c.Visible)
                        {
                            continue;
                        }

                        if (c.GetType().FullName != "Microsoft.DataTransformationServices.Design.PipelineTaskView")
                        {
                            continue;
                        }
                        object pipelineDesigner = c.GetType().InvokeMember("PipelineTaskDesigner", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty, null, c, null);
                        if (pipelineDesigner == null)
                        {
                            continue;
                        }
                        Microsoft.SqlServer.IntegrationServices.Designer.Model.DataFlowGraphModelElement dataFlowModel = (Microsoft.SqlServer.IntegrationServices.Designer.Model.DataFlowGraphModelElement)pipelineDesigner.GetType().InvokeMember("DataFlowGraphModel", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty, null, pipelineDesigner, null);
                        if (dataFlowModel == null)
                        {
                            continue;
                        }
                        DataFlowGUID = dataFlowModel.PipelineTask.ID;

                        return(true);
                    }
                }
            }
            catch (Exception ex) {
                package.Log.Exception("Error in PipelineComponentBreakdownPlugin.ShouldDisplay", ex);
            }
            return(false);
        }
        internal static void ExecutePackage(ProjectItem pi, string DataFlowGUID)
        {
            try
            {
                if (pi.DTE.Mode == vsIDEMode.vsIDEModeDebug)
                {
                    MessageBox.Show("Please stop the debugger first.");
                    return;
                }

                Window w = pi.Open(BIDSViewKinds.Designer); //opens the designer
                w.Activate();

                IDesignerHost designer = w.Object as IDesignerHost;
                if (designer == null)
                {
                    return;
                }
                EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
                if (win == null || (win.PropertiesLinkComponent as Package) == null)
                {
                    MessageBox.Show("Package designer is not open yet. Try again in a moment.");
                    return;
                }
                Package package = (Package)win.PropertiesLinkComponent;

                EditorWindow.EditorView view = null;
                if (PerformanceEditorViews.ContainsKey(win))
                {
                    PerformanceTab tab = PerformanceEditorViews[win];
                    view = tab.ParentEditorView;
                    if (tab.IsExecuting)
                    {
                        MessageBox.Show("You may not execute the package until the previous execution of the package completes.");
                    }
                    else
                    {
                        if (DataFlowGUID == null)
                        {
                            tab.ExecutePackage();
                        }
                        else
                        {
                            tab.BreakdownPipelinePerformance(DataFlowGUID);
                        }
                    }
                }
                else
                {
                    win.ActiveViewChanged += new EventHandler(win_ActiveViewChanged);

                    PerformanceTabControlDelegateContainer delegateContainer = new PerformanceTabControlDelegateContainer();
                    view = new EditorWindow.EditorView(new EditorViewLoadDelegate(delegateContainer.CreatePerformanceTabControl), "Performance", "Visualize SSIS package execution performance (BIDS Helper)", 0, BIDSHelper.Resources.Common.Performance);
                    delegateContainer.win          = win;
                    delegateContainer.view         = view;
                    delegateContainer.projectItem  = pi;
                    delegateContainer.DataFlowGUID = DataFlowGUID;
                    win.Views.Add(view);
                    win.EnsureViewIsLoaded(view); //delegate will be called here
                }
                win.SelectedView = view;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Example #6
0
        public void Init(EditorWindow parentWin, EditorWindow.EditorView view, ProjectItem pi, string DataFlowGUID)
        {
            this.parentWin = parentWin;
            this.parentView = view;
            this.projectItem = pi;

            //capture the project manager object
            Microsoft.DataWarehouse.Interfaces.IConfigurationSettings settings = (Microsoft.DataWarehouse.Interfaces.IConfigurationSettings)((System.IServiceProvider)pi.ContainingProject).GetService(typeof(Microsoft.DataWarehouse.Interfaces.IConfigurationSettings));
            this.projectManager = (Microsoft.DataWarehouse.Project.DataWarehouseProjectManager)settings.GetType().InvokeMember("ProjectManager", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.FlattenHierarchy, null, settings, null);

            //capture the output window object
            IOutputWindowFactory service = ((System.IServiceProvider)pi.ContainingProject).GetService(typeof(IOutputWindowFactory)) as IOutputWindowFactory;
            this.standardOutputWindow = service.GetStandardOutputWindow(StandardOutputWindow.Debug);

            //run the package immediately
            if (DataFlowGUID == null)
                ExecutePackage();
            else
                BreakdownPipelinePerformance(DataFlowGUID);
        }
        internal static void ExecutePackage(ProjectItem pi, string DataFlowGUID)
        {
            try
            {
                if (pi.DTE.Mode == vsIDEMode.vsIDEModeDebug)
                {
                    MessageBox.Show("Please stop the debugger first.");
                    return;
                }

                Window w = pi.Open(BIDSViewKinds.Designer); //opens the designer
                w.Activate();

                IDesignerHost designer = w.Object as IDesignerHost;
                if (designer == null) return;
                EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
                if (win == null || (win.PropertiesLinkComponent as Package) == null)
                {
                    MessageBox.Show("Package designer is not open yet. Try again in a moment.");
                    return;
                }
                Package package = (Package)win.PropertiesLinkComponent;

                EditorWindow.EditorView view = null;
                if (PerformanceEditorViews.ContainsKey(win))
                {
                    PerformanceTab tab = PerformanceEditorViews[win];
                    view = tab.ParentEditorView;
                    if (tab.IsExecuting)
                    {
                        MessageBox.Show("You may not execute the package until the previous execution of the package completes.");
                    }
                    else
                    {
                        if (DataFlowGUID == null)
                            tab.ExecutePackage();
                        else
                            tab.BreakdownPipelinePerformance(DataFlowGUID);
                    }
                }
                else
                {
                    win.ActiveViewChanged += new EventHandler(win_ActiveViewChanged);

                    PerformanceTabControlDelegateContainer delegateContainer = new PerformanceTabControlDelegateContainer();
                    view = new EditorWindow.EditorView(new EditorViewLoadDelegate(delegateContainer.CreatePerformanceTabControl), "Performance", "Visualize SSIS package execution performance (BIDS Helper)", 0, BIDSHelper.Resources.Common.Performance);
                    delegateContainer.win = win;
                    delegateContainer.view = view;
                    delegateContainer.projectItem = pi;
                    delegateContainer.DataFlowGUID = DataFlowGUID;
                    win.Views.Add(view);
                    win.EnsureViewIsLoaded(view); //delegate will be called here
                }
                win.SelectedView = view;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
            }
        }
        private bool IsContextMenuLocationValid(out string DataFlowGUID)
        {
            DataFlowGUID = null;
            try
            {
                if (this.ApplicationObject.ActiveWindow == null || this.ApplicationObject.ActiveWindow.ProjectItem == null)
                {
                    return(false);
                }
                ProjectItem pi = this.ApplicationObject.ActiveWindow.ProjectItem;
                if (!pi.Name.ToLower().EndsWith(".dtsx"))
                {
                    return(false);
                }

                if (pi.ContainingProject == null || pi.ContainingProject.Kind != BIDSProjectKinds.SSIS)
                {
                    return(false);                                                                                    //if the dtsx isn't in an SSIS project, or if you're editing the package standalone (not as a part of a project)
                }
                IDesignerHost designer = this.ApplicationObject.ActiveWindow.Object as IDesignerHost;
                if (designer == null)
                {
                    return(false);
                }
                EditorWindow win     = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
                Package      package = (Package)win.PropertiesLinkComponent;

                if (win.SelectedIndex == (int)SSISHelpers.SsisDesignerTabIndex.ControlFlow)
                {
                    //control flow
                    EditorWindow.EditorView view = win.SelectedView;
                    Control viewControl          = (Control)view.GetType().InvokeMember("ViewControl", getflags, null, view, null);

#if DENALI || SQL2014
                    Microsoft.SqlServer.IntegrationServices.Designer.Model.ControlFlowGraphModelElement ctlFlowModel = (Microsoft.SqlServer.IntegrationServices.Designer.Model.ControlFlowGraphModelElement)viewControl.GetType().InvokeMember("GraphModel", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty, null, viewControl, null);
                    if (ctlFlowModel == null)
                    {
                        return(false);
                    }
                    Microsoft.SqlServer.IntegrationServices.Designer.Model.TaskModelElement taskModelEl = ctlFlowModel.SelectedItems[0] as Microsoft.SqlServer.IntegrationServices.Designer.Model.TaskModelElement;
                    if (taskModelEl == null)
                    {
                        return(false);
                    }
                    TaskHost task = taskModelEl.TaskHost;
                    if (task == null)
                    {
                        return(false);
                    }
                    if (!(task.InnerObject is MainPipe))
                    {
                        return(false);
                    }
                    DataFlowGUID = taskModelEl.LogicalID;
                    return(true);
#else
                    DdsDiagramHostControl diagram = viewControl.Controls["panel1"].Controls["ddsDiagramHostControl1"] as DdsDiagramHostControl;
                    if (diagram == null || diagram.DDS == null)
                    {
                        return(false);
                    }
                    if (diagram.DDS.Selection.Count != 1)
                    {
                        return(false);
                    }
                    MSDDS.IDdsDiagramObject o = diagram.DDS.Selection.Item(0);
                    if (o.Type != DdsLayoutObjectType.dlotShape)
                    {
                        return(false);
                    }
                    MSDDS.IDdsExtendedProperty prop = o.IDdsExtendedProperties.Item("LogicalObject");
                    if (prop == null)
                    {
                        return(false);
                    }
                    string     sObjectGuid = prop.Value.ToString();
                    Executable exe         = ExpressionHighlighterPlugin.FindExecutable(package, sObjectGuid);
                    if (exe == null || !(exe is TaskHost))
                    {
                        return(false);
                    }
                    TaskHost task = (TaskHost)exe;
                    if (!(task.InnerObject is MainPipe))
                    {
                        return(false);
                    }
                    DataFlowGUID = task.ID;
                    return(true);
#endif
                }
                else if (win.SelectedIndex == (int)SSISHelpers.SsisDesignerTabIndex.DataFlow)
                {
                    //data flow
                    EditorWindow.EditorView view = win.SelectedView;
                    Control viewControl          = (Control)view.GetType().InvokeMember("ViewControl", getflags, null, view, null);
                    Microsoft.DataTransformationServices.Design.Controls.PipelineComboBox pipelineComboBox = (Microsoft.DataTransformationServices.Design.Controls.PipelineComboBox)(viewControl.Controls["panel1"].Controls["pipelineComboBox"]);
                    foreach (Control c in viewControl.Controls["panel2"].Controls["pipelineDetailsControl"].Controls)
                    {
                        if (!c.Visible)
                        {
                            continue;
                        }

#if DENALI || SQL2014
                        if (c.GetType().FullName != "Microsoft.DataTransformationServices.Design.PipelineTaskView")
                        {
                            continue;
                        }
                        object pipelineDesigner = c.GetType().InvokeMember("PipelineTaskDesigner", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty, null, c, null);
                        if (pipelineDesigner == null)
                        {
                            continue;
                        }
                        Microsoft.SqlServer.IntegrationServices.Designer.Model.DataFlowGraphModelElement dataFlowModel = (Microsoft.SqlServer.IntegrationServices.Designer.Model.DataFlowGraphModelElement)pipelineDesigner.GetType().InvokeMember("DataFlowGraphModel", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetProperty, null, pipelineDesigner, null);
                        if (dataFlowModel == null)
                        {
                            continue;
                        }
                        DataFlowGUID = dataFlowModel.PipelineTask.ID;
#else
                        DdsDiagramHostControl diagram = c as DdsDiagramHostControl;
                        if (diagram == null || diagram.DDS == null)
                        {
                            return(false);
                        }
                        if (diagram.DDS.Selection.Count != 0)
                        {
                            return(false);
                        }
                        TaskHost task = (TaskHost)diagram.ComponentDiagram.RootComponent;
                        DataFlowGUID = task.ID;
#endif

                        return(true);
                    }
                }
            }
            catch { }
            return(false);
        }