Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 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"));
 }