public string save() { if (isNew) { IntelliScraper.Db.httpGet r = new IntelliScraper.Db.httpGet(); r.id = txtId.Text; r.customHttpHeadersInfo = httpHeaderInfo1.getHeaders(); r.customUserAgent = txtCustUserAgent.Text; r.urlType = (IntelliScraper.Db.httpGetUrlType)Enum.Parse(typeof(IntelliScraper.Db.httpGetUrlType), (string)cmbUrlType.SelectedValue); r.customUrl = txtCustomUrl.Text; if (Factory.Instance.i.rules.httpGet != null) Factory.Instance.i.rules.httpGet = new IntelliScraper.Db.httpGetCollection(); Factory.Instance.i.rules.httpGet.Add(r); Factory.Instance.Save(); return "Added " + txtId.Text; } else { string oldId = this.rule.id; this.rule.id = txtId.Text; this.rule.customHttpHeadersInfo = httpHeaderInfo1.getHeaders(); this.rule.customUserAgent = txtCustUserAgent.Text; this.rule.urlType = (IntelliScraper.Db.httpGetUrlType)Enum.Parse(typeof(IntelliScraper.Db.httpGetUrlType), (string)cmbUrlType.SelectedValue); this.rule.customUrl = txtCustomUrl.Text; this.rule.customHttpHeadersInfo = httpHeaderInfo1.getHeaders(); Factory.Instance.Save(); return "Updated " + oldId; } }
public RuleHttpGet(string id) { if (string.IsNullOrEmpty(id)) isNew = true; else { isNew = false; this.id = id; rule = (from x in Factory.Instance.i.rules.httpGet where x.id == id select x).FirstOrDefault(); } InitializeComponent(); load(); }
public HttpGet(IntelliScraper.Db.httpGet rule) { this.rule = rule; }