public bool ChangeRuleStatus(string ids, string status) { var changeIds = ids.Split(',').Select(i => Convert.ToInt32(i)).ToArray(); var statusEnum = (Status)Enum.Parse(typeof(Status), status.ToUpper()); return(RuleLiteDb.StatusChange(changeIds, statusEnum)); }
public void TestMatchRule() { TestLock(20); var rules = RuleLiteDb.Match("http://www.ruijihg.com/2018/05/24/json-net-%e5%8f%8d%e5%ba%8f%e5%88%97%e5%8c%96%e6%8e%a5%e5%8f%a3%e9%9b%86%e5%90%88/"); Assert.True(rules.Count > 0); }
public object MatchUrlRule(string url, bool useBlock = false) { if (useBlock) { return(RuleLiteDb.Match(url).Select(m => new ExtractFeatureBlock(JsonConvert.DeserializeObject <ExtractBlock>(m.BlockExpression), m.Feature)).ToList()); } else { return(RuleLiteDb.Match(url).Select(m => new ExtractFeatureBlock(RuiJiBlockParser.ParserBlock(m.RuiJiExpression), m.Feature)).ToList()); } }
public object Rules(int offset, int limit, string key, string type, string status) { var node = ServerManager.Get(Request.Host.Value); var paging = new Paging(); paging.CurrentPage = (offset / limit) + 1; paging.PageSize = limit; return(new { rows = RuleLiteDb.GetModels(paging, key, type, status), total = paging.Count }); }
public void TestCreateRule() { //RuleLiteDB.Remove(1); var rule = new RuleModel(); rule.Url = "http://www.ruijihg.com/2018/05/24/json-net-%e5%8f%8d%e5%ba%8f%e5%88%97%e5%8c%96%e6%8e%a5%e5%8f%a3%e9%9b%86%e5%90%88/"; rule.Domain = new Uri(rule.Url).GetDomain(); rule.Expression = "http://www.ruijihg.com/????/??/??/*"; var block = new ExtractBlock() { Selectors = new List <ISelector> { new CssSelector("#main", CssTypeEnum.INNERHTML) }, Metas = new ExtractMetaCollection() }; block.Metas.AddMeta("time", new List <ISelector> { new CssSelector("time", CssTypeEnum.TEXT) }); block.Metas.AddMeta("author", new List <ISelector> { new CssSelector(".author", CssTypeEnum.TEXT) }); block.Metas.AddMeta("content", new List <ISelector> { new CssSelector(".entry-content", CssTypeEnum.INNERHTML) }); rule.BlockExpression = JsonConvert.SerializeObject(block); //rule.Id = 1; RuleLiteDb.AddOrUpdate(rule); Assert.True(rule.Id > 0); }
public bool RemoveRule(string ids) { var removes = ids.Split(',').Select(m => Convert.ToInt32(m)).ToArray(); return(RuleLiteDb.Remove(removes)); }
public object GetRule(int id) { var feed = RuleLiteDb.Get(id); return(feed); }
public void UpdateRule([FromBody] RuleModel rule) { RuleLiteDb.AddOrUpdate(rule); }
public void UpdateRule(RuleModel rule) { RuleLiteDb.AddOrUpdate(rule); }