protected override void Dispose(bool disposing)
 {
     context.log("onDisconnection - ");
     _bConnected = false;
     context     = null;
     base.Dispose(disposing);
 }
Example #2
0
        public Config(Launcher addIn, DynaTrace.CodeLink.Context context)
        {
            _addIn = addIn;
            InitializeComponent();

            string link = "http://www.dynatrace.com";

            linkLabel1.Links.Add(0, link.Length, link);
            string linkHelp = "https://community.dynatrace.com/community/display/DL/Visual+Studio+2015+Extension";

            linkLabelHelp.Links.Add(0, linkHelp.Length, linkHelp);

            this.context  = context;
            startUpConfig = new DynaTrace.CodeLink.DynatraceConfig(context.Config);

            this.tbAgentName.Text       = addIn.CustomAgentName;
            this.tbServerName.Text      = addIn.ServerName;
            this.tbServerPort.Text      = addIn.ServerPort.ToString();
            this.cbBuild.Checked        = addIn.BuildBeforeLaunch;
            this.tbClientRestPort.Text  = context.Config.ClientPort.ToString();
            this.tbWaitTimeBrowser.Text = addIn.WaitForBrowserTime.ToString();
            //if (_addIn.AgentGuid == "{79B3AFB5-500F-4950-91F1-B5486984099E}") // 2.6
            //    this.cbVersion.SelectedIndex = 0;
            //if (_addIn.AgentGuid == "{EED96696-27C0-45F1-B406-E79C92C3F372}") // 3.0
            //    this.cbVersion.SelectedIndex = 1;
            //if (_addIn.AgentGuid == "{E39D7032-0104-49f7-A694-F7FDB39ABCE0}") // 3.1
            //    this.cbVersion.SelectedIndex = 2;
            //if (_addIn.AgentGuid == "{00AADF80-D8CA-45B6-AF1C-7BC09077B44F}") // 3.2
            //    this.cbVersion.SelectedIndex = 3;
            //if (_addIn.AgentGuid == "{4C9739F3-FD77-4ee8-83FF-D7888B2277A9}") // 3.5
            //    this.cbVersion.SelectedIndex = 4;
            //if (_addIn.AgentGuid == "{E1F00E4B-4010-4a1c-8E9B-6DFA7E802D15}") // 3.5.1
            //    this.cbVersion.SelectedIndex = 5;
            //if (_addIn.AgentGuid == "{709179A4-5D87-4c2e-9EE6-90A8CFCC37FF}") // 3.5.2
            //    this.cbVersion.SelectedIndex = 6;
            //if (_addIn.AgentGuid == "{333A026A-B413-486f-91A6-A33D8C9874D6}") // 4.0.0
            //    this.cbVersion.SelectedIndex = 7;
            //if (_addIn.AgentGuid == "{DA7CFC47-3E35-4c4e-B495-534F93B28683}") // 4.1.0
            //    this.cbVersion.SelectedIndex = 8;

            //TODO fetch agent GUIDs from https://wiki.dynatrace.local/display/DEV/.NET+GUIDs

            //this.cbVSTestHost.Checked = addIn.EnableVSTestHost;

            DynaTrace.CodeLink.ConfigFormCode.Load(context, this);
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            DTE2 dte = (DTE2)FirstPackage.GetGlobalService(typeof(DTE));

            if (context == null)
            {
                context = new DynaTrace.CodeLink.Context(dte);
            }

            context.log("onConnection - Initialize");

            context.log(DynaTrace.CodeLink.Context.LOG_INFO + "CodeLink Version: " + context.VersionString);

            //from MS-Code only UISetup is necessary, but we need Startup because we have troubles with VS05 (show the menu item)
            // if (connectMode == ext_ConnectMode.ext_cm_UISetup || connectMode == ext_ConnectMode.ext_cm_Startup) {

            if (!_bConnected)
            {
                object[] contextGUIDS = new object[] { };

                string toolsMenuName;
                // if ((!found && connectMode == ext_ConnectMode.ext_cm_Startup) || (connectMode == ext_ConnectMode.ext_cm_UISetup)) {
                bool found = false;
                if (!found)
                {
                    try
                    {
                        ResourceManager resourceManager = new ResourceManager("DynaTrace.CodeLink.CommandBar", Assembly.GetExecutingAssembly());
                        CultureInfo     cultureInfo     = new System.Globalization.CultureInfo(dte.LocaleID);
                        string          resourceName    = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools");
                        toolsMenuName = resourceManager.GetString(resourceName);
                    }
                    catch
                    {
                        //We tried to find a localized version of the word Tools, but one was not found.
                        //  Default to the en-US word, which may work for the current culture.
                        toolsMenuName = "Tools";
                    }

                    // Place the command on the tools menu.
                    // Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
                    Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar =
                        ((Microsoft.VisualStudio.CommandBars.CommandBars)dte.CommandBars)["MenuBar"];

                    // Find the Tools command bar on the MenuBar command bar:
                    CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
                    CommandBarPopup   toolsPopup   = (CommandBarPopup)toolsControl;

                    //// Create the menu entry for dynaTrace Configuration Dialog
                    //try
                    //{
                    //    try
                    //    {
                    //        _commandSetup = (Command)commands.Item(COMMAND_NAME + ".Setup", 0);
                    //    }
                    //    catch (Exception) { /* context.log("INFO " + e.ToString()); */}

                    //    if (_commandSetup == null)
                    //        _commandSetup = commands.AddNamedCommand2(_addInInstance, "Setup", "dynaTrace Configuration",
                    //            "Opens the configuration dialog for CodeLink & Launcher", false, 1,
                    //            ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                    //            (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
                    //    else
                    //        _commandSetup = null;
                    //}
                    //catch (Exception e)
                    //{
                    //    //If we are here, then the exception is probably because a command with that name
                    //    //  already exists. If so there is no need to recreate the command and we can
                    //    //  safely ignore the exception.
                    //    context.log(Context.LOG_ERROR + e.ToString());
                    //}

                    //// Create the menu entry for the dynaTrace Launcher
                    //try
                    //{
                    //    try
                    //    {
                    //        _commandLauncher = (Command)commands.Item(COMMAND_NAME + ".dynaTraceLauncher", 0);
                    //    }
                    //    catch (System.Exception) { /* context.log("INFO " + e.ToString()); */}

                    //    //Add a command to the Commands collection:
                    //    if (_commandLauncher == null)
                    //        _commandLauncher = commands.AddNamedCommand2(_addInInstance, "dynaTraceLauncher", "dynaTrace Launcher", "Launches the startup project with dynaTrace Support", false, 1 /*59*/, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
                    //    else
                    //        _commandLauncher = null; // already there - therefore dont add it again to the tools menu
                    //}
                    //catch (System.Exception e)
                    //{
                    //    context.log(Context.LOG_ERROR + e.ToString());
                    //}

                    ////Add to tools menu
                    //if (toolsPopup != null)
                    //{
                    //    try
                    //    {
                    //        if (_commandSetup != null)
                    //            _commandSetup.AddControl(toolsPopup.CommandBar, 1);
                    //        if (_commandLauncher != null)
                    //            _commandLauncher.AddControl(toolsPopup.CommandBar, 1);
                    //    }
                    //    catch (Exception e)
                    //    {
                    //        context.log(Context.LOG_ERROR + e.ToString());
                    //    }
                    //}
                }
                _bConnected = true;
            }

            // create the launcher implementation class
//            if (_launcher == null)
//            {
//                _launcher = new dynaTraceLauncher.LauncherConnect(_applicationObject, _addInInstance);
//                _launcher.Context = context;
//            }
//            // In VS2010 also create the WebTestPlugin
//#if (VS_2010)
//            try
//            {
//                dynaTrace.VSTS.WebResultAddin.WebTestConnect webTestConnect = new dynaTrace.VSTS.WebResultAddin.WebTestConnect();
//                webTestConnect.OnConnection(application, connectMode, addInInst, ref custom);
//            }
//            catch (Exception e) {context.log(Context.LOG_ERROR + e.ToString());}
//#endifs

            if (context.Config.PluginEnabled)
            {
                context.connect();
            }

            LaunchCommand.Initialize(this);
            LaunchCommand.Instance.Launcher = new Launcher(dte, context);
            ConfigCommand.Initialize(this);
            ConfigCommand.Instance.Context  = context;
            ConfigCommand.Instance.Launcher = LaunchCommand.Instance.Launcher;
            RunTestsMenu.Initialize(this);
        }