Esempio n. 1
0
        private void Procedure(Uri uri, GeckoWindow window, String file)
        {
            try
            {
                Action <FlowModelData> action;
                String next;
                Action <FlowModelData> callback;
                flow.Procedure(uri, out action, out next, out callback);
                if (window != null)
                {
                    GeckoElement script = this.Document.CreateElement("script");
                    script.SetAttribute("type", "text/javascript");
                    script.TextContent = "window.alert = function(){};";
                    window.Document.OwnerDocument.Head.AppendChild(script);
                    using (AutoJSContext context = new AutoJSContext(this.Window))
                    {
                        string result;
                        context.EvaluateScript("window.alert = function(){};", (nsISupports)window.DomWindow, out result);
                    }
                    flowModelData.Document = window.Document.OwnerDocument;
                }
                flowModelData.Uri          = uri;
                flowModelData.NextUrl      = next;
                flowModelData.CallBack     = callback;
                flowModelData.IsNextScrap  = true;
                flowModelData.IsSkipAction = false;
                if (file != null)
                {
                    flowModelData.File = new FileInfo(file);
                }
                action(flowModelData);
                if (flowModelData.IsSkipAction)
                {
                    return;
                }
                if (flowModelData.CallBack != null)
                {
                    flowModelData.CallBack(flowModelData);
                }
                if (!String.IsNullOrEmpty(flowModelData.NextUrl))
                {
                    this.Navigate(flowModelData.NextUrl);
                }
                if (!flowModelData.IsNextScrap)
                {
                    //resultParameter.Endtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                    flow.End(flowModelData);
                    Scraper.Exit();
                }
            }
            catch (Exception ex)
            {
                //resultParameter.ResultCD = "9999";
                //resultParameter.ResultMSG = ex.ToString();

                flow.Error(ex);
                logger.Error(ex.ToString());
                Scraper.Exit();
            }
        }