private void Init() { IList <NoticeSource> list = new List <NoticeSource>(); using (IDbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Default"].ConnectionString)) { list = conn.GetList <NoticeSource>().ToList(); } foreach (var source in list) { RecurringJob.AddOrUpdate(source.Name, () => NoticeSpider.Run(source), Cron.Minutely); } }
public ActionResult SaveSource(NoticeSource source) { using (IDbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Default"].ConnectionString)) { if (source.Id == 0) { source.RegexRule = HttpUtility.HtmlEncode(source.RegexRule); var result = conn.Insert(source); } else { conn.Update(source); } } RecurringJob.AddOrUpdate(source.Name, () => NoticeSpider.Run(source), Cron.Minutely); return(RedirectToAction("Sources")); }