修改采集地址页

This commit is contained in:
j4587698 2020-02-10 22:30:27 +08:00
parent 5308a31cc8
commit 514b2ddfe2
5 changed files with 234 additions and 99 deletions

3
.gitignore vendored
View File

@ -338,3 +338,6 @@ ASALocalRun/
# BeatPulse healthcheck temp database # BeatPulse healthcheck temp database
healthchecksdb healthchecksdb
/CMS/JXCMS.CMS.Movie/test
*mono_crash.mem.*.blob
test

View File

@ -1,3 +1,4 @@
using System.Linq;
using JXCMS.CMS.Attribute; using JXCMS.CMS.Attribute;
using JXCMS.CMS.Movie.Entity; using JXCMS.CMS.Movie.Entity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -8,11 +9,14 @@ namespace JXCMS.CMS.Admin.Controllers
[AdminAuthentication] [AdminAuthentication]
public class CollectionController : Controller public class CollectionController : Controller
{ {
public IActionResult Index() public IActionResult Index(int pageNumber = 1, int pageSize = 20)
{ {
ViewBag.title = "采集地址"; ViewBag.title = "采集地址";
var website = WebSiteEntity.Select.ToList(); var website = WebSiteEntity.Select.Count(out long count).Page(pageNumber, pageSize).ToList();
ViewBag.website = website; ViewBag.website = website;
ViewBag.count = count;
ViewBag.pageNumber = pageNumber;
ViewBag.totlePage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
return View(); return View();
} }
@ -25,6 +29,27 @@ namespace JXCMS.CMS.Admin.Controllers
public IActionResult DeleteWebSite(int id) 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")); return Redirect(Url.Action("Index"));
} }
@ -43,5 +68,7 @@ namespace JXCMS.CMS.Admin.Controllers
} }
return View(webSiteEntity); return View(webSiteEntity);
} }
} }
} }

View File

@ -25,15 +25,16 @@
</div> </div>
</form> </form>
<div class="toolbar-btn-action"> <div class="toolbar-btn-action">
<a href="@Url.Action("WebSiteDialog", "Collection", new {id=0})" class="btn btn-primary m-r-5" id="new" data-toggle="modal" data-target="#exampleModal"><i class="mdi mdi-plus"></i> 新增</a> <a data-src="@Url.Action("WebSiteDialog", "Collection", new {id = 0})" class="btn btn-primary m-r-5" id="new" data-toggle="modal" data-target="#exampleModal"><i class="mdi mdi-plus"></i> 新增</a>
<a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a> <a class="btn btn-success m-r-5" onclick="enableWebsiteBatch()"><i class="mdi mdi-check"></i> 启用</a>
<a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a> <a class="btn btn-warning m-r-5" onclick="disableWebsiteBatch()"><i class="mdi mdi-block-helper"></i> 禁用</a>
<a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a> <a class="btn btn-danger" onclick="delWebsiteBatch()"><i class="mdi mdi-window-close"></i> 删除</a>
</div> </div>
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="table-responsive"> <div class="table-responsive">
<form id="batchForm" action="#" method="post">
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr> <tr>
@ -55,21 +56,21 @@
<tr> <tr>
<td> <td>
<label class="lyear-checkbox checkbox-primary"> <label class="lyear-checkbox checkbox-primary">
<input type="checkbox" name="ids[]" value="1"><span></span> <input type="checkbox" name="ids[]" value="@webSiteEntity.Id"><span></span>
</label> </label>
</td> </td>
<td>@webSiteEntity.WebSiteName</td> <td>@webSiteEntity.WebSiteName</td>
<td>@webSiteEntity.ApiUrl</td> <td>@webSiteEntity.ApiUrl</td>
<td>@webSiteEntity.Cron</td> <td>@webSiteEntity.Cron</td>
<td> <td>
<span class="text-success">@(webSiteEntity.IsEnable ? "正常": "已禁用")</span> <span class="text-success">@(webSiteEntity.IsEnable ? "正常" : "已禁用")</span>
</td> </td>
<td> <td>
<div class="btn-group"> <div class="btn-group">
<a class="btn btn-xs btn-default" href="@Url.Action("WebSiteDialog", "Collection", new {id = webSiteEntity.Id})" title="编辑" data-toggle="modal" data-target="#exampleModal"> <a class="btn btn-xs btn-default" data-src="@Url.Action("WebSiteDialog", "Collection", new {id = webSiteEntity.Id})" title="编辑" data-toggle="modal" data-target="#exampleModal">
<i class="mdi mdi-pencil"></i> <i class="mdi mdi-pencil"></i>
</a> </a>
<a class="btn btn-xs btn-default" href="#!" title="删除" onclick="delWebsite(@webSiteEntity.Id)"> <a class="btn btn-xs btn-default" href="#!" title="删除" onclick="delWebsite(@webSiteEntity.Id, '@webSiteEntity.WebSiteName')">
<i class="mdi mdi-window-close"></i> <i class="mdi mdi-window-close"></i>
</a> </a>
</div> </div>
@ -79,47 +80,41 @@
</tbody> </tbody>
</table> </table>
</form>
</div> </div>
<ul class="pagination"> <ul class="pagination">
<li class="disabled"> @if (ViewBag.pageNumber != 1)
<span>«</span> {
<li>
<a href="@Url.Action("Index", "Collection")">&lt;&lt;</a>
</li> </li>
}
@for (int i = ViewBag.pageNumber - 3; i < ViewBag.pageNumber + 3; i++)
{
if (i < 1 || i > ViewBag.totlePage)
{
continue;
}
if (i == ViewBag.pageNumber)
{
<li class="active"> <li class="active">
<span>1</span> <span>@i</span>
</li> </li>
}
else
{
<li> <li>
<a href="#1">2</a> <a href="@Url.Action("Index", "Collection", new {pageNumber = i})">@i</a>
</li> </li>
}
}
@if (ViewBag.pageNumber < ViewBag.totlePage)
{
<li> <li>
<a href="#1">3</a> <a href="@Url.Action("Index", "Collection", new {pageNumber = ViewBag.totlePage})">&gt;&gt;</a>
</li>
<li>
<a href="#1">4</a>
</li>
<li>
<a href="#1">5</a>
</li>
<li>
<a href="#1">6</a>
</li>
<li>
<a href="#1">7</a>
</li>
<li>
<a href="#1">8</a>
</li>
<li class="disabled">
<span>...</span>
</li>
<li>
<a href="#!">14452</a>
</li>
<li>
<a href="#!">14453</a>
</li>
<li>
<a href="#!">»</a>
</li> </li>
}
</ul> </ul>
</div> </div>
@ -134,7 +129,11 @@
</div> </div>
</div> </div>
</div> </div>
<form id="delForm" action="@Url.Action("DeleteWebSite")" method="post">
<input type="hidden" name="id" id="delId"/>
</form>
</div> </div>
@section style @section style
{ {
<link rel="stylesheet" href="@Url.ContentAdmin("js/jconfirm/jquery-confirm.min.css")"> <link rel="stylesheet" href="@Url.ContentAdmin("js/jconfirm/jquery-confirm.min.css")">
@ -147,27 +146,92 @@
<script type="text/javascript" src="@Url.ContentAdmin("js/Validate.js")"></script> <script type="text/javascript" src="@Url.ContentAdmin("js/Validate.js")"></script>
<script src="@Url.ContentAdmin("js/jconfirm/jquery-confirm.min.js")"></script> <script src="@Url.ContentAdmin("js/jconfirm/jquery-confirm.min.js")"></script>
<script> <script>
$('#exampleModal').on('hidden.bs.modal', function(event) { $('#exampleModal').on('show.bs.modal', function(event) {
$('#exampleModal').modal('dispose') var button = $(event.relatedTarget); // Button that triggered the modal
var recipient = button.data('src'); // Extract info from data-* attributes
var content = $(this).find(".modal-content");
content.html("正在加载,请稍后...");
$.get(recipient, function(data, status) {
if (status === "success") {
content.html(data)
} else{
content.html("发生错误,请重试")
}
})
}); });
function delWebsite(id) { function delWebsite(id, name) {
$.alert({ $.alert({
title: '嗨', title: '删除采集地址' + name,
content: '这是对用户的简单提示框。 <br> 一些 <strong>HTML</strong> <em>内容</em>' + id, content: '是否删除' + name + '?该操作不可恢复',
buttons: { buttons: {
confirm: { confirm: {
text: '确认', text: '',
btnClass: 'btn-primary', btnClass: 'btn-primary',
action: function(){ action: function(){
$.alert('你点击了确认!'); $('#delId').val(id);
$('#delForm').submit();
} }
}, },
cancel: { cancel: {
text: '取消', text: '否'
action: function () {
$.alert('你点击了取消!');
} }
} }
});
}
function delWebsiteBatch() {
$.alert({
title: '批量删除采集地址',
content: '是否要批量删除选中的采集地址?该操作不可恢复',
buttons: {
confirm: {
text: '是',
btnClass: 'btn-primary',
action: function(){
$('#batchForm').attr('action', '@Url.Action("DeleteWebSiteBatch")').submit();
}
},
cancel: {
text: '否'
}
}
});
}
function enableWebsiteBatch() {
$.alert({
title: '批量启用采集地址',
content: '是否要批量启用选中的采集地址?',
buttons: {
confirm: {
text: '是',
btnClass: 'btn-primary',
action: function(){
$('#batchForm').attr('action', '@Url.Action("EnableWebSiteBatch")').submit();
}
},
cancel: {
text: '否'
}
}
});
}
function disableWebsiteBatch() {
$.alert({
title: '批量禁用采集地址',
content: '是否要禁用删除选中的采集地址?',
buttons: {
confirm: {
text: '是',
btnClass: 'btn-primary',
action: function(){
$('#batchForm').attr('action', '@Url.Action("DisableWebSiteBatch")').submit();
}
},
cancel: {
text: '否'
}
} }
}); });
} }

View File

@ -19,6 +19,7 @@
<PackageReference Include="FreeSql.Provider.SqlServer" Version="0.11.20" /> <PackageReference Include="FreeSql.Provider.SqlServer" Version="0.11.20" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="0.3.1" /> <PackageReference Include="McMaster.NETCore.Plugins" Version="0.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" /> <PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.2-dev-00824" /> <PackageReference Include="Serilog.Sinks.Console" Version="3.1.2-dev-00824" />

View File

@ -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<bool> 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;
}
}
}