示例#1
0
 /// <summary>
 /// 开始探测元素。
 /// </summary>
 public void Detect()
 {
     //HtmlElementCollection elements = _browser.Document.All;
     if (_browser.InvokeRequired)
     {
         Action action = findElement;
         _browser.Invoke(action);
     }
     else
     {
         findElement();
     }
     //findElement((_browser.Document.Body.DomElement as IHTMLElement).children);
 }
示例#2
0
文件: FillBase.cs 项目: qwdingyu/C-
        /// <summary>
        /// 使用指定的form名称查找form元素。
        /// </summary>
        /// <param formName="ele">form名称。</param>
        /// <param name="ownerFormIndex">form在当前document中的索引。</param>
        /// <returns></returns>
        public IHTMLElement FindForm(string frameId, string formName)
        {
            HtmlDocument document = null;

            if (string.IsNullOrEmpty(frameId))
            {
                document = _doc;
            }
            else
            {
                _browser.Invoke((Action)(() =>
                {
                    HtmlWindow window = _doc.Window.Frames[frameId];
                    document = window == null ? null : window.Document;
                }));
            }
            if (document == null)
            {
                return(null);
            }
            InstallScript(document);
            return(InvokeScriptSync(document, "findForm", new object[] { formName }) as IHTMLElement);
        }
示例#3
0
        public override void BeginFill()
        {
            _fillTable.Clear();
            _uris = this.GetUris();
            _data = base.DataProvider.ProvideData(null) as Hashtable;
            // 获取数据转换器
            converter = this.DataProvider.GetConverter() as WebValueConverter;
            // 从配置文件中获取是否进行数据转换
            if (FileHelper.GetIsUseConverter(this.Version, this.FillType))
            {
                converter.DataFilePath = string.IsNullOrEmpty(base.DataProvider.DataSourceFile) ? "" : System.IO.Directory.GetParent(base.DataProvider.DataSourceFile).FullName;
                string converterFile = FileHelper.GetConverterFile(this.FillType);
                _data = converter.Convert(converterFile, this.FillType, _data);
            }
            _browser.Invoke((Action)(() =>
            {
                // 监听浏览器事件,确定填报线程的执行顺序。
                _browser.Navigating += Browser_Navigating;
                _browser.DocumentCompleted += Browser_DocumentCompleted;
                _browser.NewWindow3 += Browser_NewWindow3;
                _openedBrowser.Add(_browser);

                if (_browser.IsBusy == false && _browser.Document != null)
                {
                    HtmlDocument doc = FindFillDocument(_browser.Document);
                    if (doc == null || CanFill(doc.Url) == false)
                    {
                        return;
                    }
                    _currentFill = CreateFillInner(doc.Url, _browser);
                    _currentFill.FillIndexes = _fillIndexes;
                    if (_currentFill != null)
                    {
                        _currentFill.BeginFill();
                    }
                }
            }));
        }