Exemplo n.º 1
0
 public override void DoCheck(CodeClass codeClass)
 {
     //ApplicationObject.Find.FindWhat(codeClass.Name);
     ApplicationObject.Find.SearchPath = "Entire Solution";
     ApplicationObject.ExecuteCommand("Edit.FindinFiles", codeClass.Name);
     Window findSymbolResultWindow = ApplicationObject.Windows.Item(Constants.vsWindowKindFindResults1);
     string results = findSymbolResultWindow.Caption.ToString();
 }
Exemplo n.º 2
0
        public override void Exec()
        {
            try
            {
                UIHierarchy solExplorer = this.ApplicationObject.ToolWindows.SolutionExplorer;
                if (((System.Array)solExplorer.SelectedItems).Length != 1)
                {
                    return;
                }

                UIHierarchyItem hierItem = ((UIHierarchyItem)((System.Array)solExplorer.SelectedItems).GetValue(0));
                ProjectItem     pi       = (ProjectItem)hierItem.Object;

                if (System.Windows.Forms.MessageBox.Show("Are you sure you want to reset the GUIDs for all tasks, connection managers, configurations,\r\nevent handlers, and variables in package " + pi.Name + "?", "BIDS Helper - Reset GUIDs?", System.Windows.Forms.MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                {
                    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));
                Package      package = win.PropertiesLinkComponent as Package;
                if (package == null)
                {
                    return;
                }


                //capture list of GUIDs to replace
                _listGuidsToReplace = new List <string>();
                AddGuid(package.ID);
                RecurseExecutablesAndCaptureGuids(package);
                foreach (DtsEventHandler h in package.EventHandlers)
                {
                    AddGuid(h.ID);
                    RecurseExecutablesAndCaptureGuids(h);
                }
                foreach (ConnectionManager cm in package.Connections)
                {
                    AddGuid(cm.ID);
                }
                foreach (Microsoft.SqlServer.Dts.Runtime.Configuration conf in package.Configurations)
                {
                    AddGuid(conf.ID);
                }

                //open package XML
                ApplicationObject.ExecuteCommand("View.ViewCode", String.Empty);

                // Loop through GUIDs captured and replace
                foreach (string sOldGuid in _listGuidsToReplace)
                {
                    ApplicationObject.Find.FindWhat          = sOldGuid;
                    ApplicationObject.Find.ReplaceWith       = "{" + System.Guid.NewGuid().ToString().ToUpper() + "}";
                    ApplicationObject.Find.Target            = vsFindTarget.vsFindTargetCurrentDocument;
                    ApplicationObject.Find.MatchCase         = false;
                    ApplicationObject.Find.MatchWholeWord    = true;
                    ApplicationObject.Find.MatchInHiddenText = false;
                    ApplicationObject.Find.Action            = vsFindAction.vsFindActionReplaceAll;
                    ApplicationObject.Find.PatternSyntax     = vsFindPatternSyntax.vsFindPatternSyntaxLiteral;

                    if (ApplicationObject.Find.Execute() == vsFindResult.vsFindResultNotFound)
                    {
                        System.Diagnostics.Debug.WriteLine("couldn't find " + sOldGuid);
                        System.Windows.Forms.MessageBox.Show("Resetting GUIDs did NOT complete successfully as the package has changed.\r\n\r\nThis may have happened if you did not have the latest version from source control before running the Reset GUIDs command.", "BIDS Helper - Problem Resetting GUIDs");
                        return;
                    }
                }

                ApplicationObject.ActiveWindow.Close(vsSaveChanges.vsSaveChangesNo); //close the package XML
                ApplicationObject.ActiveDocument.Save(null);
                w.Close(vsSaveChanges.vsSaveChangesNo);                              //close the designer

                w = pi.Open(BIDSViewKinds.Designer);                                 //opens the designer
                w.Activate();
                //that was the quick and easy way to get the expression highlighter up to date
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message + " " + ex.StackTrace);
            }
        }