Ejemplo n.º 1
0
        public void EditProperty()
        {
            var crawTargets = new List <XPathAnalyzer.CrawTarget>();

            crawTargets.Add(new XPathAnalyzer.CrawTarget(CrawlItems.Select(d => d.Clone()).ToList(), RootXPath,
                                                         RootFormat)
            {
                RootNode = this.HtmlDoc.DocumentNode, WorkMode = IsMultiData
            });
            var luckModel = new FeelLuckyModel(crawTargets, HtmlDoc, IsMultiData);

            luckModel.CanChange = false;
            var view = PluginProvider.GetObjectInstance <ICustomView>(GlobalHelper.Get("key_657")) as UserControl;

            view.DataContext = luckModel;

            var name   = GlobalHelper.Get("key_658");
            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)
            {
                CrawlItems.Clear();
                RootXPath = luckModel.CurrentTarget.RootXPath;
                CrawlItems.AddRange(luckModel.CurrentTarget.CrawItems);
            }
        }
Ejemplo n.º 2
0
        public void FeelLucky()
        {
            isBusy = true;
            var crawTargets = new List <XPathAnalyzer.CrawTarget>();
            var task        = TemporaryTask.AddTempTask("网页结构计算中",
                                                        HtmlDoc.SearchPropertiesSmart(CrawlItems, RootXPath, IsAttribute), crawTarget =>
            {
                crawTargets.Add(crawTarget);
                var datas        = HtmlDoc.GetDataFromXPath(crawTarget.CrawItems, IsMultiData, crawTarget.RootXPath);
                crawTarget.Datas = datas;
            }, d =>
            {
                isBusy = false;
                if (crawTargets.Count == 0)
                {
                    CrawTarget = null;
                    XLogSys.Print.Warn("没有检查到任何可选的列表页面");
                    return;
                }

                var luckModel    = new FeelLuckyModel(crawTargets, HtmlDoc);
                var view         = PluginProvider.GetObjectInstance <ICustomView>("手气不错面板") as UserControl;
                view.DataContext = luckModel;

                var name   = "手气不错";
                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;
                    RootXPath      = crawTarget.RootXPath;
                    CrawlItems.Clear();
                    CrawlItems.AddRange(crawTarget.CrawItems.Where(r => r.IsEnabled));
                }
            });

            SysProcessManager.CurrentProcessTasks.Add(task);
        }
Ejemplo n.º 3
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);
        }