예제 #1
0
        public void SetUrl()
        {
            // Never update XenCenter node tabs once loaded
            if (Browser.Url != null && Browser.Url.AbsoluteUri != "about:blank" && XenCenterOnly)
            {
                return;
            }

            BrowserState state;

            if (SelectedXenObject == null)
            {
                // XenCenter node is selected, the placeholder code will sub in "null" for all placeholders
                // After this point we will never update this url again for this node, so there is no need to store a browser state
                state = new BrowserState(Placeholders.SubstituteUri(Url, SelectedXenObject), SelectedXenObject, Browser);
            }
            else if (BrowserStates.ContainsKey(SelectedXenObject))
            {
                state      = BrowserStates[SelectedXenObject];
                state.Uris = Placeholders.SubstituteUri(Url, SelectedXenObject);
            }
            else
            {
                state = new BrowserState(Placeholders.SubstituteUri(Url, SelectedXenObject), SelectedXenObject, Browser);
                BrowserStates[SelectedXenObject] = state;
            }

            try
            {
                if (state.ObjectForScripting != null)
                {
                    if (Credentials)
                    {
                        state.ObjectForScripting.LoginSession();
                    }
                    Browser.ObjectForScripting = state.ObjectForScripting;
                }

                lastBrowserState = state;

                Browser.DocumentText = string.Empty;
                Application.DoEvents();

                lastBrowserState.IsError = false;
                ShowStatus(string.Format(Messages.WEB_BROWSER_WAITING, ShortUri(state.Uris[0])));
                Browser.Navigate(state.Uris[0]);
            }
            catch (Exception e)
            {
                log.Error(string.Format("Failed to set TabPage url to '{0}' for plugin '{1}'",
                                        string.Join(",", state.Uris.ConvertAll(u => u.ToString()).ToArray()), PluginDescriptor.Name), e);
            }
        }
예제 #2
0
        private void SetUrl()
        {
            if (UrlIsLoaded && XenCenterOnly) // Never update XenCenter node tabs.
            {
                return;
            }

            BrowserState state;

            if (selectedXenObject == null)
            {
                // XenCenter node is selected, the placeholder code will sub in "null" for all placeholders
                // After this point we will never update this url again for this node, so there is no need to store a browser state
                state = new BrowserState(Placeholders.SubstituteUri(Url, selectedXenObject), selectedXenObject, Browser);
            }
            else if (BrowserStates.ContainsKey(selectedXenObject) && !BrowserStates[selectedXenObject].IsError)
            {
                // if there wasn't an error with navigation then use the stored browser-state. Otherwise try again.
                state = BrowserStates[selectedXenObject];
            }
            else
            {
                state = new BrowserState(Placeholders.SubstituteUri(Url, selectedXenObject), selectedXenObject, Browser);
                BrowserStates[selectedXenObject] = state;
            }

            if (lastBrowserState == state)
            {
                return;
            }

            try
            {
                if (state.ObjectForScripting != null)
                {
                    if (Credentials)
                    {
                        state.ObjectForScripting.LoginSession();
                    }
                    Browser.ObjectForScripting = state.ObjectForScripting;
                }
                Browser.Navigate(state.Urls);

                lastBrowserState = state;
            }
            catch (Exception e)
            {
                log.Error(string.Format("Failed to set TabPage url to '{0}' for plugin '{1}'", string.Join(",", state.Urls.ConvertAll(u => u.ToString()).ToArray()), PluginDescriptor.Name), e);
            }
        }