Beispiel #1
0
        public IEnumerable <IFreeDocument> Execute(IEnumerable <IFreeDocument> documents)
        {
            foreach (var document in documents)
            {
                var doc = MappingDocument(document);
                if (AddTask)
                {
                    var name = doc[Column];
                    ControlExtended.UIInvoke(() =>
                    {
                        var task = TemporaryTask <FreeDocument> .AddTempTaskSimple("ETL" + name, func(new List <IFreeDocument> {
                            doc
                        }),
                                                                                   d => d.LastOrDefault());
                        processManager.CurrentProcessTasks.Add(task);
                    });
                }
                else
                {
                    var r = func(new List <IFreeDocument> {
                        doc
                    }).ToList();
                }

                yield return(document);
            }
        }
Beispiel #2
0
        public void FeelLucky()
        {
            if (string.IsNullOrEmpty(this.URLHTML))
            {
                this.VisitUrlAsync();
            }
            isBusy = true;
            var crawTargets = new List <XPathAnalyzer.CrawTarget>();
            ICollection <CrawlItem> existItems = CrawlItems;

            if (IsMultiData == ScriptWorkMode.One)
            {
                existItems = new List <CrawlItem> {
                    new CrawlItem {
                        Name = "temp", XPath = SelectXPath
                    }
                }
            }
            ;
            var task = TemporaryTask <XPathAnalyzer.CrawTarget> .AddTempTaskSimple(GlobalHelper.Get("key_659"),
                                                                                   HtmlDoc.DocumentNode.SearchPropertiesSmart(IsMultiData, existItems, RootXPath, RootFormat, IsAttribute),
                                                                                   crawTarget =>
            {
                crawTargets.Add(crawTarget);
                //var datas =
                //    HtmlDoc.DocumentNode.GetDataFromXPath(crawTarget.CrawItems, IsMultiData, crawTarget.RootXPath,
                //        RootFormat).ToList();
                //crawTarget.Datas = datas;
            }, d =>
            {
                isBusy = false;
                if (crawTargets.Count == 0)
                {
                    XLogSys.Print.Warn(GlobalHelper.Get("key_660"));
                    return;
                }

                var luckModel    = new FeelLuckyModel(crawTargets, HtmlDoc, IsMultiData);
                var view         = PluginProvider.GetObjectInstance <ICustomView>(GlobalHelper.Get("key_657")) as UserControl;
                view.DataContext = luckModel;

                var name   = GlobalHelper.Get("feellucky");
                var window = new Window {
                    Title = name
                };
                window.WindowState = WindowState.Maximized;
                window.Content     = view;
                luckModel.SetView(view, window);
                window.Activate();
                window.ShowDialog();
                if (window.DialogResult == true)

                {
                    var crawTarget = luckModel.CurrentTarget;
                    if (string.IsNullOrEmpty(RootXPath))
                    {
                        RootFormat = SelectorFormat.XPath;
                    }
                    RootXPath = crawTarget.RootXPath;


                    CrawlItems.AddRange(crawTarget.CrawItems.Where(r => r.IsEnabled && CrawlItems.FirstOrDefault(d2 => d2.XPath == r.XPath) == null));
                }
            });

            SysProcessManager.CurrentProcessTasks.Add(task);
        }