diff --git a/.gitignore b/.gitignore index 4ce6fdd..15b6fe3 100755 --- a/.gitignore +++ b/.gitignore @@ -337,4 +337,7 @@ ASALocalRun/ .localhistory/ # BeatPulse healthcheck temp database -healthchecksdb \ No newline at end of file +healthchecksdb +/CMS/JXCMS.CMS.Movie/test +*mono_crash.mem.*.blob +test diff --git a/CMS/JXCMS.CMS.Movie/Admin/Controllers/CollectionController.cs b/CMS/JXCMS.CMS.Movie/Admin/Controllers/CollectionController.cs index d1bd04d..c77f2a5 100644 --- a/CMS/JXCMS.CMS.Movie/Admin/Controllers/CollectionController.cs +++ b/CMS/JXCMS.CMS.Movie/Admin/Controllers/CollectionController.cs @@ -1,3 +1,4 @@ +using System.Linq; using JXCMS.CMS.Attribute; using JXCMS.CMS.Movie.Entity; using Microsoft.AspNetCore.Mvc; @@ -8,11 +9,14 @@ namespace JXCMS.CMS.Admin.Controllers [AdminAuthentication] public class CollectionController : Controller { - public IActionResult Index() + public IActionResult Index(int pageNumber = 1, int pageSize = 20) { ViewBag.title = "采集地址"; - var website = WebSiteEntity.Select.ToList(); + var website = WebSiteEntity.Select.Count(out long count).Page(pageNumber, pageSize).ToList(); ViewBag.website = website; + ViewBag.count = count; + ViewBag.pageNumber = pageNumber; + ViewBag.totlePage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1; return View(); } @@ -25,6 +29,27 @@ namespace JXCMS.CMS.Admin.Controllers public IActionResult DeleteWebSite(int id) { + WebSiteEntity.Find(id).Delete(); + return Redirect(Url.Action("Index")); + } + + public IActionResult DeleteWebSiteBatch(int[] ids) + { + WebSiteEntity.Where(x => ids.Contains(x.Id)).ToDelete().ExecuteAffrows(); + return Redirect(Url.Action("Index")); + } + + public IActionResult EnableWebSiteBatch(int[] ids) + { + WebSiteEntity.Where(x => ids.Contains(x.Id)).ToUpdate() + .Set(y => y.IsEnable, true).ExecuteAffrows(); + return Redirect(Url.Action("Index")); + } + + public IActionResult DisableWebSiteBatch(int[] ids) + { + WebSiteEntity.Where(x => ids.Contains(x.Id)).ToUpdate() + .Set(y => y.IsEnable, false).ExecuteAffrows(); return Redirect(Url.Action("Index")); } @@ -43,5 +68,7 @@ namespace JXCMS.CMS.Admin.Controllers } return View(webSiteEntity); } + + } } \ No newline at end of file diff --git a/CMS/JXCMS.CMS.Movie/Admin/Views/Collection/Index.cshtml b/CMS/JXCMS.CMS.Movie/Admin/Views/Collection/Index.cshtml index d808921..b0c74b3 100644 --- a/CMS/JXCMS.CMS.Movie/Admin/Views/Collection/Index.cshtml +++ b/CMS/JXCMS.CMS.Movie/Admin/Views/Collection/Index.cshtml @@ -25,101 +25,96 @@
- 新增 - 启用 - 禁用 - 删除 + 新增 + 启用 + 禁用 + 删除
- - - - - - - - - - - - - @foreach (WebSiteEntity webSiteEntity in ViewBag.website) - { + +
- - 网站名称网站url采集cron状态操作
+ - - - - - + + + + + + - } - - -
+ - - @webSiteEntity.WebSiteName@webSiteEntity.ApiUrl@webSiteEntity.Cron - @(webSiteEntity.IsEnable ? "正常": "已禁用") - - - 网站名称网站url采集cron状态操作
+ + + @foreach (WebSiteEntity webSiteEntity in ViewBag.website) + { + + + + + @webSiteEntity.WebSiteName + @webSiteEntity.ApiUrl + @webSiteEntity.Cron + + @(webSiteEntity.IsEnable ? "正常" : "已禁用") + + + + + + } + + + +
@@ -134,7 +129,11 @@ +
+ +
+ @section style { @@ -143,33 +142,98 @@ @section script { - + } \ No newline at end of file diff --git a/Core/JXCMS.Core/JXCMS.Core.csproj b/Core/JXCMS.Core/JXCMS.Core.csproj index c872ce4..37b5684 100755 --- a/Core/JXCMS.Core/JXCMS.Core.csproj +++ b/Core/JXCMS.Core/JXCMS.Core.csproj @@ -19,6 +19,7 @@ + diff --git a/Core/JXCMS.Core/TimingTask/QuartzTask.cs b/Core/JXCMS.Core/TimingTask/QuartzTask.cs new file mode 100644 index 0000000..d558a1f --- /dev/null +++ b/Core/JXCMS.Core/TimingTask/QuartzTask.cs @@ -0,0 +1,40 @@ +using System; +using System.Threading.Tasks; +using Quartz; +using Quartz.Impl; + +namespace JXCMS.Core.TimingTask +{ + public class QuartzTask + { + private ISchedulerFactory _schedulerFactory; + private IScheduler _scheduler; + + private QuartzTask() + { + _schedulerFactory = new StdSchedulerFactory(); + _scheduler = _schedulerFactory.GetScheduler().Result; + _scheduler.Start(); + } + + private static QuartzTask _instance; + + public static QuartzTask Instance() + { + if (_instance == null) + { + _instance = new QuartzTask(); + } + + return _instance; + } + + public async Task AddTask(Type jobType, string cron, string jobName, string jobGroup = "default") + { + var job = JobBuilder.Create(jobType).WithIdentity("job", "job").Build(); + var trigger = TriggerBuilder.Create().WithIdentity(jobName + "tigger").StartNow().WithCronSchedule(cron).Build(); + await _scheduler.ScheduleJob(job, trigger); + return true; + } + } +} \ No newline at end of file