Example #1
0
        /// <summary>
        /// 当前页与预定值比较相似度
        /// 非提交数据页面,类似页面后台需要找一个有特点标签生成xpath作为相似度比较依据
        /// 提交数据页面比较input标签xpath的hashcode
        /// </summary>
        /// <param name="source">返回相同数目</param>
        /// <returns></returns>
        public bool SimilartyCompare(ScriptObject so)
        {
            //logger.Info("current thread is :" + System.Threading.Thread.CurrentThread.ManagedThreadId);
            PageRecognizeEnum pr = (PageRecognizeEnum)Convert.ToInt16(so.PageRecognize);

            try
            {
                return(Recognizer.Create(this.context, pr).Recognize(so));
            }
            catch (Exception ex)
            {
                //处理mshtml.HTMLDocumentClass.IHTMLDocument2_get_all()异常
                //System.Runtime.InteropServices.InvalidComObjectException: COM 对象与其基础 RCW 分开后就不能再使用
                //MyBrowser cb = context.CoreBrowser;
                //while (cb.Busy)
                //{
                //    System.Threading.Thread.Sleep(100);
                //}
                ////返回主线程执行脚本
                //if (cb.InvokeRequired)
                //{
                //    return (bool)cb.Invoke(new Func<ScriptObject, bool>(SimilartyCompare), so);
                //}
                logger.Fatal(ex);
                //返回false,则重新执行,直到超时
                return(false);
            }
        }