예제 #1
0
        protected void HighlightDdsDiagramObjectIcon(DdsDiagramHostControl diagram, object managedShape, bool bHasExpression, bool bHasConfiguration)
        {
            try
            {
                System.Diagnostics.Debug.WriteLine("called HighlightDdsDiagramObjectIcon " + (diagram == null ? "Null, " : "NotNull, ") + (managedShape == null ? "Null, " : "NotNull, ") + bHasExpression + ", " + bHasConfiguration);
                if (managedShape != null)
                {
                    System.Drawing.Bitmap icon = (System.Drawing.Bitmap)TYPE_MANAGED_BASE_SHAPE.InvokeMember("Icon", getflags | System.Reflection.BindingFlags.Public, null, managedShape, null);
                    if (!bHasExpression && !bHasConfiguration && icon.Tag != null)
                    {
                        //reset the icon because this one doesn't have an expression anymore
                        System.Reflection.BindingFlags setflags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
                        TYPE_MANAGED_BASE_SHAPE.InvokeMember("Icon", setflags, null, managedShape, new object[] { icon.Tag });
                        icon.Tag = null;
                        diagram.Invalidate(true); //TODO: just invalidate object?

                        System.Diagnostics.Debug.WriteLine("un-highlighted object");
                    }
                    else if ((bHasExpression || bHasConfiguration))
                    {
                        //save what the icon looked like originally so we can go back if they remove the expression
                        if (icon.Tag == null)
                        {
                            icon.Tag = icon.Clone();
                        }

                        //now update the icon to note this one has an expression
                        if (bHasExpression && !bHasConfiguration)
                        {
                            ModifyIcon(icon, expressionColor);
                        }
                        else if (bHasConfiguration && !bHasExpression)
                        {
                            ModifyIcon(icon, configurationColor);
                        }
                        else
                        {
                            ModifyIcon(icon, expressionColor, configurationColor);
                        }
                        diagram.Invalidate(true);
                        System.Diagnostics.Debug.WriteLine("highlighted object");
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error highlighting: " + ex.Message + " " + ex.StackTrace);
            }
        }
예제 #2
0
        private Package GetCurrentPackage()
        {
            #if DENALI || SQL2014
            // This seems to simple, but it appears to work (Green)
            return((Package)win.PropertiesLinkComponent);
            #else
            Control viewControl = (Control)win.SelectedView.GetType().InvokeMember("ViewControl", getflags, null, win.SelectedView, null);

            // Get the package, but may have to walk up the object hierarchy.
            // We need to start at the top with the Package in the worker thread,
            // otherwise string path functions fail and stuff gets missed.
            DtsContainer container = null;

            if (win.SelectedIndex == 0) //Control Flow
            {
                // Parent of Control Flow diagram is the Package
                DdsDiagramHostControl diagram = (DdsDiagramHostControl)viewControl.Controls["panel1"].Controls["ddsDiagramHostControl1"];
                container = (DtsContainer)diagram.ComponentDiagram.RootComponent;
            }
            else if (win.SelectedIndex == 1) // Data flow
            {
                // Parent of Data Flow diagram is a Task
                DdsDiagramHostControl diagram = (DdsDiagramHostControl)viewControl.Controls["panel2"].Controls["pipelineDetailsControl"].Controls["PipelineTaskView"];
                TaskHost taskHost             = (TaskHost)diagram.ComponentDiagram.RootComponent;
                container = (DtsContainer)taskHost.Parent; // container is Package
            }
            else if (win.SelectedIndex == 2)               //Event Handlers
            {
                // Parent of Event Handlers diagram is a DtsEventHandler
                DdsDiagramHostControl diagram = (DdsDiagramHostControl)viewControl.Controls["panel1"].Controls["panelDiagramHost"].Controls["EventHandlerView"];
                container = (DtsContainer)diagram.ComponentDiagram.RootComponent;
            }
            else
            {
                return(null);
            }

            // Get the root container, i.e the Package
            return(GetPackageFromContainer(container));
            #endif
        }
예제 #3
0
        private ConnectionManager GetSelectedConnectionManager(IDesignerHost designer, out Package package)
        {
            package = null;

            System.Reflection.BindingFlags getflags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance;
            EditorWindow win         = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator));
            Control      viewControl = (Control)win.SelectedView.GetType().InvokeMember("ViewControl", getflags, null, win.SelectedView, null);

#if DENALI || SQL2014
            Control lvwConnMgrs = null;
            package = (Package)win.PropertiesLinkComponent;

            if (win.SelectedIndex == (int)SSISHelpers.SsisDesignerTabIndex.ControlFlow)
            {
                //it's now a Microsoft.DataTransformationServices.Design.Controls.DtsConnectionsListView object which doesn't inherit from ListView and which is internal
                lvwConnMgrs = (Control)viewControl.Controls["controlFlowTrayTabControl"].Controls["controlFlowConnectionsTabPage"].Controls["controlFlowConnectionsListView"];
            }
            else if (win.SelectedIndex == (int)SSISHelpers.SsisDesignerTabIndex.DataFlow)
            {
                lvwConnMgrs = (Control)viewControl.Controls["dataFlowsTrayTabControl"].Controls["dataFlowConnectionsTabPage"].Controls["dataFlowConnectionsListView"];
            }
            else if (win.SelectedIndex == (int)SSISHelpers.SsisDesignerTabIndex.EventHandlers)
            {
                lvwConnMgrs = (Control)viewControl.Controls["controlFlowTrayTabControl"].Controls["controlFlowConnectionsTabPage"].Controls["controlFlowConnectionsListView"];
            }
            else
            {
                return(null);
            }

            Microsoft.SqlServer.IntegrationServices.Designer.ConnectionManagers.ConnectionManagerUserControl  cmControl   = (Microsoft.SqlServer.IntegrationServices.Designer.ConnectionManagers.ConnectionManagerUserControl)lvwConnMgrs.GetType().InvokeMember("m_connectionManagerUserControl", System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.FlattenHierarchy | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic, null, lvwConnMgrs, null);
            Microsoft.SqlServer.IntegrationServices.Designer.ConnectionManagers.ConnectionManagerModelElement connModelEl = cmControl.SelectedItem as Microsoft.SqlServer.IntegrationServices.Designer.ConnectionManagers.ConnectionManagerModelElement;
            if (connModelEl == null)
            {
                return(null);
            }
            ConnectionManager conn = connModelEl.ConnectionManager;
#else
            ListView              lvwConnMgrs = null;
            IDTSSequence          container   = null;
            TaskHost              taskHost    = null;
            DdsDiagramHostControl diagram     = null;
            if (win.SelectedIndex == 0) //Control Flow
            {
                diagram     = (DdsDiagramHostControl)viewControl.Controls["panel1"].Controls["ddsDiagramHostControl1"];
                lvwConnMgrs = (ListView)viewControl.Controls["controlFlowTrayTabControl"].Controls["controlFlowConnectionsTabPage"].Controls["controlFlowConnectionsListView"];
                container   = (IDTSSequence)diagram.ComponentDiagram.RootComponent;
            }
            else if (win.SelectedIndex == 1) //Data Flow
            {
                diagram     = (DdsDiagramHostControl)viewControl.Controls["panel2"].Controls["pipelineDetailsControl"].Controls["PipelineTaskView"];
                taskHost    = (TaskHost)diagram.ComponentDiagram.RootComponent;
                container   = (IDTSSequence)taskHost.Parent;
                lvwConnMgrs = (ListView)viewControl.Controls["dataFlowsTrayTabControl"].Controls["dataFlowConnectionsTabPage"].Controls["dataFlowConnectionsListView"];
            }
            else if (win.SelectedIndex == 2) //Event Handlers
            {
                diagram     = (DdsDiagramHostControl)viewControl.Controls["panel1"].Controls["panelDiagramHost"].Controls["EventHandlerView"];
                lvwConnMgrs = (ListView)viewControl.Controls["controlFlowTrayTabControl"].Controls["controlFlowConnectionsTabPage"].Controls["controlFlowConnectionsListView"];
                container   = (IDTSSequence)diagram.ComponentDiagram.RootComponent;
            }
            else
            {
                return(null);
            }

            if (lvwConnMgrs.SelectedItems.Count != 1)
            {
                return(null);
            }
            package = GetPackageFromContainer((DtsContainer)container);

            ListViewItem      lviConn = lvwConnMgrs.SelectedItems[0];
            ConnectionManager conn    = FindConnectionManager(package, lviConn.Text);
#endif

            return(conn);
        }
예제 #4
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);

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