Ejemplo n.º 1
0
        private void GoUrl()
        {
            string url = this.txtUrl.Text;

            SHDocVw.WebBrowser wb = CreateNewWebBrowser();


            // Return if nowhere to go
            if (url == "")
            {
                return;
            }

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                Object o = null;
                wb.Navigate(url, ref o, ref o, ref o, ref o);
            }
            finally
            {
                int i = this.txtUrl.Items.IndexOf(url);
                if (i == -1)
                {
                    this.txtUrl.Items.Add(url);
                }

                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 2
0
 private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 {
     if (mainUrl.StartsWith("http://www.watchever.de/player/") && webBrowser1.Document.Body.InnerHtml.Contains("<DIV class=einloggen>"))
     {
         FormLogin formLogin = new FormLogin();
         formLogin.ShowDialog();
         ASCIIEncoding Encode      = new ASCIIEncoding();
         byte[]        post        = Encode.GetBytes("login="******"&password="******"&remember=rememberMe");
         string        url         = "http://www.watchever.de/CN/";
         string        PostHeaders = "Content-Type: application/x-www-form-urlencoded";
         webBrowser1.DocumentCompleted -= webBrowser1_DocumentCompleted;
         nativeBrowser.Navigate(url, null, null, post, PostHeaders);
     }
     if (e.Url.AbsolutePath == webBrowser1.Url.AbsolutePath)
     {
         System.Threading.Thread.Sleep(100);
         ((SHDocVw.WebBrowser)webBrowser1.ActiveXInstance).ExecWB(SHDocVw.OLECMDID.OLECMDID_OPTICAL_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, zoom, IntPtr.Zero);
         webBrowser1.DocumentCompleted -= webBrowser1_DocumentCompleted;
         webBrowser1.Navigate("javascript:window.scrollBy(0,-500);");
     }
 }
        /// <summary>
        /// This method used to Display SFDC in Browser window
        /// </summary>
        /// <param name="URL"></param>
        /// <param name="browserType"></param>
        /// <param name="addressBar"></param>
        /// <param name="statusBar"></param>
        /// <returns></returns>
        public string PopupURL(string URL, string browserType, bool addressBar, bool statusBar)
        {
            try
            {
                this._logger.Info("PopupURL : URL to popup is " + URL);

                if (!String.IsNullOrEmpty(browserType) && browserType.Trim().ToLower().Equals("ie"))
                {
                    this._logger.Info("PopupURL : Popup SFDC URL using Internet Explorer ");
                    this._logger.Info("PopupURL : Display AddressBar : " + addressBar.ToString());
                    this._logger.Info("PopupURL : Display StatusBar : " + statusBar.ToString());
                    SFDCbrowser            = new SHDocVw.InternetExplorer() as SHDocVw.WebBrowser;
                    SFDCbrowser.AddressBar = addressBar;
                    SFDCbrowser.StatusBar  = statusBar;
                    SFDCbrowser.Navigate(URL);
                    SFDCbrowser.Visible = true;
                    SFDCbrowser.OnQuit += SFDCbrowser_OnQuit;
                    IsIEWindowClosed    = false;
                }
                else
                {
                    this._logger.Info("PopupURL : Popup SFDC using Chrome browser ");
                    string PopupUrl      = URL;
                    string chromeCommand = string.Empty;
                    string directoryName = string.Empty;
                    if (!String.IsNullOrEmpty(Settings.SFDCOptions.ChromeBrowserCommand))
                    {
                        this._logger.Info("PopupURL : Chrome browser command : " + Settings.SFDCOptions.ChromeBrowserCommand);
                        chromeCommand = Settings.SFDCOptions.ChromeBrowserCommand;
                    }
                    else
                    {
                        this._logger.Info("PopupURL : Chrome browser command is Null or Empty, Adapter will use default Command ");
                        if (Settings.SFDCOptions.SFDCConnectPort != 0)
                        {
                            chromeCommand = "--unsafely-treat-insecure-origin-as-secure=http://localhost:" + Settings.SFDCOptions.SFDCConnectPort + " --test-type --user-data-dir=";
                        }
                        else
                        {
                            chromeCommand = "--unsafely-treat-insecure-origin-as-secure=http://localhost:" + Settings.SFDCOptions.SFDCConnectPort + " --test-type --user-data-dir=";
                            this._logger.Warn("PopupURL : Using default Chrome Command but SFDC Connection Port is null");
                        }
                    }
                    if (!String.IsNullOrEmpty(Settings.SFDCOptions.ChromeBrowserTempDirectory))
                    {
                        if (!Directory.Exists(Settings.SFDCOptions.ChromeBrowserTempDirectory))
                        {
                            this._logger.Info("PopupURL : Chrome User Data directory is not Exists, Directory Name : " + Settings.SFDCOptions.ChromeBrowserTempDirectory);
                            this._logger.Info("PopupURL : Creating directory " + Settings.SFDCOptions.ChromeBrowserTempDirectory);
                            try
                            {
                                Directory.CreateDirectory(Settings.SFDCOptions.ChromeBrowserTempDirectory);
                                directoryName = Settings.SFDCOptions.ChromeBrowserTempDirectory;
                            }
                            catch (Exception generalException)
                            {
                                this._logger.Error("PopupURL : Exception occurred while creating chrome user data temp directory :" + generalException.ToString() + generalException.StackTrace);
                            }
                        }
                        else
                        {
                            this._logger.Info("PopupURL : Chrome User Data directory is already Exists, Directory Name : " + Settings.SFDCOptions.ChromeBrowserTempDirectory);
                            directoryName = Settings.SFDCOptions.ChromeBrowserTempDirectory;
                        }
                    }
                    else
                    {
                        try
                        {
                            if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"\Genesys Telecommunication\InteractionWorkspace\Temp_Chrome")))
                            {
                                Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"\Genesys Telecommunication\InteractionWorkspace\Temp_Chrome"));
                            }

                            directoryName = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Genesys Telecommunication\InteractionWorkspace\Temp_Chrome";
                        }
                        catch (Exception generalException)
                        {
                            this._logger.Error("PopupURL : Exception occurred while creating chrome user data temp directory :" + generalException.ToString() + generalException.StackTrace);
                        }
                    }

                    if (!String.IsNullOrWhiteSpace(chromeCommand) && !String.IsNullOrWhiteSpace(directoryName) && !String.IsNullOrWhiteSpace(URL))
                    {
                        PopupUrl = chromeCommand + "\"" + directoryName + "\" " + URL;
                        this._logger.Info("PopupURL : Chrome popup using command " + PopupUrl);
                        browserProcess = Process.Start("chrome.exe", PopupUrl);
                        URL            = PopupUrl;
                    }
                    else
                    {
                        this._logger.Warn("PopupURL : Chrome Browser not loaded becase Chrome command or directory name or Salesforce Login URL is null or empty");
                    }
                }
            }
            catch (Exception generalException)
            {
                try
                {
                    this._logger.Info("PopupURL : Browser Type : " + browserType);
                    this._logger.Error("PopupURL : Error Occurred while popuping SFDC Browser Window, Error Message : " + generalException.Message);
                    if (generalException.Message == "The system cannot find the file specified")
                    {
                        browserProcess = Process.Start(URL);
                    }
                }
                catch (Exception generalException1)
                {
                    return("PopupURL : Error in opening salesforce url Error message: " + generalException1.Message);
                }
            }
            return(URL + "  URL launched Successfully");
        }
 public void NavigateWeb(string uri)
 {
     xBrowser.Navigate(uri);
 }