private void CheckBox_Checked(object sender, RoutedEventArgs e) { var checkBox = (sender as CheckBox); var grabType = checkBox.Tag.ToString(); var grabConfig = SpiderManager.CurrentConfigOfSpider.GrabConfigs.FirstOrDefault(c => c.GetGrabType().ToString() == grabType); if (grabConfig == null) { SpiderManager.CurrentConfigOfSpider.GrabConfigs.Add(IGrabConfig.GetGrabConfig((EGrabType)Enum.Parse(typeof(EGrabType), grabType), SpiderManager.CurrentConfigOfSpider)); } else { grabConfig.IsOn = checkBox.IsChecked.Value; } }
public void LoadConfig(ConfigOfSpider spiderConfig) { if (spiderConfig == null) { return; } //SpiderManager.CurrentConfigOfSpider = spiderConfig; //SpiderManager.ConfigOfSpiders.LatestSpiderConfigName = spiderConfig.SpiderName; //加载配置内容 //加载 RequestConfig ConfigOfRequest requestConfig = spiderConfig.RequestConfig; tb_SourceURL.Text = requestConfig.URL; //加载 ManageConfig ConfigOfProcess managerConfig = spiderConfig.ManageConfig; //加载 List<IGrabConfig> List <IGrabConfig> grabConfigs = new List <IGrabConfig>(); grabConfigs.AddRange(spiderConfig.GrabConfigs); var grabTypeStrings = Enum.GetNames(typeof(EGrabType)); foreach (var grabTypeString in grabTypeStrings) { if (!grabConfigs.Exists(c => c.GetGrabType().ToString() == grabTypeString)) { var grabType = (EGrabType)Enum.Parse(typeof(EGrabType), grabTypeString); if (grabType != EGrabType.None) { grabConfigs.Add(IGrabConfig.GetGrabConfig(grabType, spiderConfig)); } } } lb_GrabConfigs.ItemsSource = grabConfigs; //加载选中项 //cb_Solution.SelectedValue = SpiderManager.ConfigOfSpiders.LatestSpiderConfigName; cb_Solution.SelectedIndex = SpiderManager.ConfigOfSpiders.Configs.Select(c => c.SpiderName).ToList().IndexOf(SpiderManager.ConfigOfSpiders.LatestSpiderConfigName); }