Пример #1
0
        internal void ShowRule(Models.ScrapingRule rule)
        {
            var window = App.Current.Windows
                         .OfType <Views.ScrapingRuleWindow>()
                         .FirstOrDefault(_ => _.ViewModel.Rule.Id == rule.Id);

            if (window != null)
            {
                window.Activate(); return;
            }

            window = new Views.ScrapingRuleWindow(rule)
            {
                Owner = MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
            };

            window.Show();

            try
            {
                App.Instance.ScraperCollection.Save();
            }
            catch
            {
                // アプリ終了時にクラッシュするケースを握りつぶす(v1.4 追加
            }
        }
Пример #2
0
        public void TestRule(Models.ScrapingRule rule)
        {
            var window = new Views.ScrapingTestWindow(rule)
            {
                Owner = MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
            };

            window.Loaded += async(s, a) => await window.ViewModel.TestAsync();

            window.ShowDialog();
        }
Пример #3
0
        internal void DeleteRule(Models.ScrapingRule rule)
        {
            var window = new Views.DeleteScrapingRuleWindow(rule)
            {
                Owner = MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
            };

            if (window.ShowDialog() == true)
            {
                if (window.ViewModel.IsDeleteData)
                {
                    Directory.Delete(rule.Location, true);
                }

                App.Instance.ScraperCollection.Remove(rule);
                App.Instance.ScraperCollection.Save();
            }
        }
Пример #4
0
        public void NotifyErrorDetected(Models.ScrapingRule scraper, Models.ScrapingResult result)
        {
            Instance.ShowInformation($"{scraper.Name} is failed.");

            ErrorDetected?.Invoke(this, new DetectedEventArgs(scraper, result));
        }
Пример #5
0
 public DetectedEventArgs(Models.ScrapingRule scraper, Models.ScrapingResult result)
 {
     Scraper = scraper;
     Result  = result;
 }
Пример #6
0
 public ScrapingResult(ScrapingRule scraper) : this()
 {
     ScraperId = scraper.Id;
 }