Пример #1
0
 public static void TaskModelInit()
 {
     var repo = DependencyResolver.Current.GetService(typeof(IMongoRepo<TaskModel>)) as MongoRepo<TaskModel>;
     if (!repo.Collection.AsQueryable<TaskModel>().Any(d => d.Name == "DoubanOne")) {
         var douban = new TaskModel {
             Name = "DoubanOne",
             Act = (int)eAct.Normal,
             ArticleType = (int)eArticleType.AdianboVideo,
             Site = "douban",
             UrlTemp = "http://movie.douban.com/subject/{0}/",
             CommandType = (int)eCommandType.One,
             UrlParams = new List<string>() { "1"}
         };
         repo.Collection.Insert(douban);
     }
     if (!repo.Collection.AsQueryable<TaskModel>().Any(d => d.Name == "ImdbOne")) {
         var imdb = new TaskModel {
             Name = "ImdbOne",
             Act = (int)eAct.Normal,
             ArticleType = (int)eArticleType.AdianboVideo,
             Site = "imdb",
             UrlTemp = "http://www.imdb.com/title/{0}/",
             UrlParams = new List<string>() { "1" }
         };
         repo.Collection.Insert(imdb);
     }
 }
Пример #2
0
 public ActionResult Creattask(TaskModel model, string urlParams)
 {
     model.UrlParams = urlParams.Split('\n').Select(d => d.Trim()).ToList();
     TaskQueue.tasks.AddRange(model.GenerateSpiderTask());
     if (TaskQueue.masterhub != null)
         TaskQueue.masterhub.BroadcastRanderTask();
     SiteList();
     return View();
 }
 public ActionResult Create(TaskModel model, string urlParams)
 {
     if (!ModelState.IsValid) {
         ModelState.AddModelError("", "表单验证失败。");
         return View(model);
     }
     model.UrlParams = urlParams.Split('\n').Select(d => d.Trim()).ToList();
     model.UrlParams.ForEach(d => d.Trim());
     taskModelCollection.Insert(model);
     TaskQueue.Instance.ModelTimerReBuild();
     return RedirectToAction("Index");
 }
Пример #4
0
 public void GenerateTask(TaskModel model)
 {
     tasks.AddRange(model.GenerateSpiderTask());
     if (masterhub != null)
         masterhub.BroadcastRanderTask();
 }