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); }
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); }