예제 #1
0
        protected void Navi(string url)
        {
            if (!GetWebBrowser().InvokeRequired)
            {
                pWB.WBDOCDOWNLOADCTLFLAG = (int)m_DLCtlFlags;
                pWB.Navigate(url);
            }

            else
            {
                //清空重定向URL容器
                m_RedirectUrl.Clear();
                //设置连接状态
                m_IsNavigationCompleted = false;
                m_IsNavigationError     = false;
                m_IEErrorCode           = 0;
                //设置时间戳
                m_NavigatingStartTimepoint = DateTime.Now;

                pWB.Invoke(new CsEXWBNaviInvoker(Navi), new object[] { url });
                lock (navigatelocker)
                {
                    Monitor.Wait(navigatelocker, NAVIGATINGOUTOFSECOND * 1000);
                }

                Thread.Sleep(200);
            }
        }
예제 #2
0
        private void AjaxWatch()
        {
            //设置时间戳
            m_ScriptStartTimepoint = DateTime.Now;
            m_AjaxStartTimepoint   = DateTime.Now;
            log.Debug("AJAX Detection Start...");

            while (m_ScriptStartTimepoint.AddSeconds(AJAXDELAYSECOND) > DateTime.Now)
            {
                System.Threading.Thread.Sleep(300);

                if (m_AjaxStartTimepoint.AddSeconds(AJAXOUTOFSECOND) < DateTime.Now)
                {
                    if (IsWebFilled())
                    {
                        log.Debug("Navigation Done(Out of Time Through) In AJAX");
                    }
                    else
                    {
                        log.Debug("Navigation Out Of Time In AJAX");
                        m_IsNavigationError = true;
                        m_IEErrorCode       = WinInetErrors.ERROR_INTERNET_TIMEOUT;
                    }
                    break;
                }

                if (m_IsRedirctionEnable && m_RedirectUrl.Count > 0)
                {
                    log.Debug("Navigation Stopped In AJAX Because Of Redirection");
                    break;
                }
            }
            log.Debug("AJAX Detection End...");
        }
예제 #3
0
 public WebBrowserNavigateErrorEventArgs(
     String url, String frame, Int32 statusCode, Boolean cancel)
 {
     urlValue        = url;
     frameValue      = frame;
     statusCodeValue = (WinInetErrors)statusCode;
     cancelValue     = cancel;
 }
예제 #4
0
 private void VBACsEXWB_NavigateError(object sender, NavigateErrorEventArgs e)
 {
     m_IEErrorCode       = e.statuscode;
     m_IsNavigationError = true;
     //lock (navigatelocker)
     //{
     //    Monitor.Pulse(navigatelocker);
     //}
 }
예제 #5
0
        /// <summary>
        /// VBA方法:转到目标网址
        /// </summary>
        public virtual void Navigate(string url)
        {
            bool isredirect;

            GetWebBrowser().NavToBlank();

            //向联网控制中心注册
            CWBPool.NavigationBegin();

            do
            {
                isredirect = false;

                Navi(url);

                //判断是否含有AJAX
                if (DownloadScripts && m_IsNavigationCompleted)
                {
                    AjaxWatch();
                }

                //判断是否有重定向
                isredirect = (m_IsRedirctionEnable && m_RedirectUrl.Count > 0);

                if (isredirect)
                {
                    log.Debug("Navigation-Redirection:" + url + " >>>> " + m_RedirectUrl.Peek());
                    url = m_RedirectUrl.Pop();
                }
            } while (isredirect);

            if (!m_IsNavigationCompleted && !IsWebFilled())
            {
                log.Debug("Navigation Out Of Time");
                m_IsNavigationError = true;
                m_IEErrorCode       = WinInetErrors.ERROR_INTERNET_TIMEOUT;
            }

            //向联网控制中心注销
            CWBPool.NavigationEnd();
        }
예제 #6
0
        private void VBACsEXWB_WBSecurityProblem(object sender, SecurityProblemEventArgs e)
        {
            //处理一般安全提示
            if ((e.problem == WinInetErrors.HTTP_REDIRECT_NEEDS_CONFIRMATION) ||
                (e.problem == WinInetErrors.ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR) ||
                (e.problem == WinInetErrors.ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR) ||
                (e.problem == WinInetErrors.ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR) ||
                (e.problem == WinInetErrors.ERROR_INTERNET_MIXED_SECURITY))
            {
                e.handled  = true;
                e.retvalue = Hresults.S_FALSE;
                return;
            }

            //非正常安全提示
            log.Debug("WBSecurityProblem==>" + e.problem.ToString());
            m_IsNavigationError = true;
            m_IEErrorCode       = e.problem;
            //lock (navigatelocker)
            //{
            //    Monitor.Pulse(navigatelocker);
            //}
        }
예제 #7
0
 public void SetParameters(int Problem)
 {
     this.handled = false;
     this.problem = (WinInetErrors)Problem;
     this.retvalue = Hresults.S_FALSE; //1
 }
예제 #8
0
 public void SetParameters(object Browser, string Url, string TargetFrame, int StatusCode)
 {
     this.browser = Browser;
     this.url = Url;
     this.targetframe = TargetFrame;
     this.statuscode = (WinInetErrors)StatusCode;
     this.Cancel = false;
 }
예제 #9
0
        protected void Navi(string url)
        {
            if (!GetWebBrowser().InvokeRequired)
            {
                pWB.WBDOCDOWNLOADCTLFLAG = (int)m_DLCtlFlags;
                pWB.Navigate(url);
            }

            else
            {
                //清空重定向URL容器
                m_RedirectUrl.Clear();
                //设置连接状态
                m_IsNavigationCompleted = false;
                m_IsNavigationError = false;
                m_IEErrorCode = 0;
                //设置时间戳
                m_NavigatingStartTimepoint = DateTime.Now;

                pWB.Invoke(new CsEXWBNaviInvoker(Navi), new object[] { url });
                lock (navigatelocker)
                {
                    Monitor.Wait(navigatelocker, NAVIGATINGOUTOFSECOND * 1000);
                }

                Thread.Sleep(200);
            }

        }
예제 #10
0
        /// <summary>
        /// VBA方法:转到目标网址
        /// </summary>  
        public virtual void Navigate(string url)
        {
            bool isredirect;

            GetWebBrowser().NavToBlank();

            //向联网控制中心注册
            CWBPool.NavigationBegin();

            do
            {
                isredirect = false;

                Navi(url);

                //判断是否含有AJAX
                if (DownloadScripts && m_IsNavigationCompleted)
                    AjaxWatch();

                //判断是否有重定向
                isredirect = (m_IsRedirctionEnable && m_RedirectUrl.Count > 0);

                if (isredirect)
                {
                    log.Debug("Navigation-Redirection:" + url + " >>>> " + m_RedirectUrl.Peek());
                    url = m_RedirectUrl.Pop();
                }

            } while (isredirect);

            if (!m_IsNavigationCompleted && !IsWebFilled())
            {
                log.Debug("Navigation Out Of Time");
                m_IsNavigationError = true;
                m_IEErrorCode = WinInetErrors.ERROR_INTERNET_TIMEOUT;
            }

            //向联网控制中心注销
            CWBPool.NavigationEnd();
        }
예제 #11
0
 private void VBACsEXWB_NavigateError(object sender, NavigateErrorEventArgs e)
 {
     m_IEErrorCode = e.statuscode;
     m_IsNavigationError = true;
     //lock (navigatelocker)
     //{
     //    Monitor.Pulse(navigatelocker);
     //}
 }
예제 #12
0
        private void VBACsEXWB_WBSecurityProblem(object sender, SecurityProblemEventArgs e)
        {
            //处理一般安全提示
            if ((e.problem == WinInetErrors.HTTP_REDIRECT_NEEDS_CONFIRMATION) ||
                (e.problem == WinInetErrors.ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR) ||
                (e.problem == WinInetErrors.ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR) ||
                (e.problem == WinInetErrors.ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR) ||
                (e.problem == WinInetErrors.ERROR_INTERNET_MIXED_SECURITY))
            {
                e.handled = true;
                e.retvalue = Hresults.S_FALSE;
                return;
            }

            //非正常安全提示
            log.Debug("WBSecurityProblem==>" + e.problem.ToString());
            m_IsNavigationError = true;
            m_IEErrorCode = e.problem;
            //lock (navigatelocker)
            //{
            //    Monitor.Pulse(navigatelocker);
            //}
        }
예제 #13
0
        private void AjaxWatch()
        {
            //设置时间戳
            m_ScriptStartTimepoint = DateTime.Now;
            m_AjaxStartTimepoint = DateTime.Now;
            log.Debug("AJAX Detection Start...");

            while (m_ScriptStartTimepoint.AddSeconds(AJAXDELAYSECOND) > DateTime.Now)
            {
                System.Threading.Thread.Sleep(300);

                if (m_AjaxStartTimepoint.AddSeconds(AJAXOUTOFSECOND) < DateTime.Now)
                {
                    if (IsWebFilled())
                    {
                        log.Debug("Navigation Done(Out of Time Through) In AJAX");                        
                    }
                    else
                    {
                        log.Debug("Navigation Out Of Time In AJAX");
                        m_IsNavigationError = true;
                        m_IEErrorCode = WinInetErrors.ERROR_INTERNET_TIMEOUT;
                    }
                    break;
                }

                if (m_IsRedirctionEnable && m_RedirectUrl.Count > 0)
                {
                    log.Debug("Navigation Stopped In AJAX Because Of Redirection");
                    break;
                }
            }
            log.Debug("AJAX Detection End...");
        }