/// <summary> /// Save /// </summary> private void button1_Click(object sender, RoutedEventArgs e) { this.attr.getType = (IntelliScraper.Db.xpathSingleAttributesGetType)Enum.Parse(typeof(IntelliScraper.Db.xpathSingleAttributesGetType), (string)cmbGetType.SelectedValue); this.attr.xpath = txtXpath.Text; this.attr.id = txtId.Text; this.attr.attributeName = txtAttrName.Text; if (listBox1.Items.Count > 0) { this.attr.postProcessTrigger = new IntelliScraper.Db.postProcessCollection(); foreach (string i in listBox1.Items) { int index = i.IndexOf('('); if (index > 0) { string _type = i.Substring(index).Replace("(", "").Replace(")", "").Trim(); string id = i.Substring(0, index).Replace("(", "").Replace(")", "").Trim(); if (_type.Contains("regular")) _type = "regex"; IntelliScraper.Db.postProcess pp = new IntelliScraper.Db.postProcess(); pp.id = id; pp.type = (IntelliScraper.Db.postProcessType)Enum.Parse(typeof(IntelliScraper.Db.postProcessType),_type); this.attr.postProcessTrigger.Add(pp); } } } if (listBox2.Items.Count > 0) { this.attr.postProcessGroupId = new string[listBox2.Items.Count]; for (int i = 0; i < listBox2.Items.Count; i++) this.attr.postProcessGroupId[i] = (string)listBox2.Items[i]; } foreach (var a in this.rule.attributes) { if (a.id == attr.id) { attr = a; break; } } Factory.Instance.Save(); load(); }
private void button1_Click(object sender, RoutedEventArgs e) { if (listBox1.Items.Count > 0) { //this.rule.postProcessTriggerGroup = new IntelliScraper.Db.xpathSinglePostProcessTriggerGroupCollection(); IntelliScraper.Db.xpathSinglePostProcessTriggerGroup gr = (from x in this.rule.postProcessTriggerGroup where x.id == this.attrId select x).FirstOrDefault(); gr.postProcessTrigger = new IntelliScraper.Db.postProcessCollection(); foreach (string i in listBox1.Items) { int index = i.IndexOf('('); if (index > 0) { string _type = i.Substring(index).Replace("(", "").Replace(")", "").Trim(); string id = i.Substring(0, index).Replace("(", "").Replace(")", "").Trim(); IntelliScraper.Db.postProcess pp = new IntelliScraper.Db.postProcess(); pp.id = id; if (_type.ToLower() == "regularexpression") _type = "regex"; pp.type = (IntelliScraper.Db.postProcessType)Enum.Parse(typeof(IntelliScraper.Db.postProcessType), _type); gr.postProcessTrigger.Add(pp); } } Factory.Instance.Save(); } }