From 90636a4033eab3977e514f5cc134301b2d64bf89 Mon Sep 17 00:00:00 2001 From: 13476573407 <1062424570@qq.com> Date: Fri, 29 Jul 2022 09:59:55 +0800 Subject: [PATCH 1/5] =?UTF-8?q?Quartz.NET.Web\Utility\FileHelper.cs=20?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=BC=82=E6=AD=A5=E6=96=87=E4=BB=B6=E5=86=99?= =?UTF-8?q?=E5=85=A5=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Quartz.NET.Web/Utility/FileHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quartz.NET.Web/Utility/FileHelper.cs b/Quartz.NET.Web/Utility/FileHelper.cs index 1af2685..e27c5f7 100644 --- a/Quartz.NET.Web/Utility/FileHelper.cs +++ b/Quartz.NET.Web/Utility/FileHelper.cs @@ -95,7 +95,7 @@ namespace Quartz.NET.Web.Utility { Directory.CreateDirectory(path); } - using (FileStream stream = File.Open(path + fileName, FileMode.OpenOrCreate, FileAccess.Write)) + using (FileStream stream = File.Open(path + fileName, FileMode.OpenOrCreate, FileAccess.Write,FileShare.ReadWrite)) { byte[] by = Encoding.Default.GetBytes(content); if (appendToLast) -- Gitee From 143e640a1cc4b2c4086261b26fb876583018441e Mon Sep 17 00:00:00 2001 From: 13476573407 <1062424570@qq.com> Date: Fri, 29 Jul 2022 10:09:24 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=97=B6=EF=BC=8C=E9=92=88=E5=AF=B9=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E6=97=A5=E5=BF=97=E6=B6=88=E6=81=AF=E5=8C=85=E5=90=AB?= =?UTF-8?q?"=5F"=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Quartz.NET.Web/Utility/FileQuartz.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Quartz.NET.Web/Utility/FileQuartz.cs b/Quartz.NET.Web/Utility/FileQuartz.cs index 88905e4..50db305 100644 --- a/Quartz.NET.Web/Utility/FileQuartz.cs +++ b/Quartz.NET.Web/Utility/FileQuartz.cs @@ -70,7 +70,8 @@ namespace Quartz.NET.Web.Utility continue; if (arr.Length != 3) { - list.Add(new TaskLog() { Msg = item }); + //list.Add(new TaskLog() { Msg = item }); + list.Add(new TaskLog() { BeginDate = arr[0], EndDate = arr[1], Msg = String.Join('_', arr[^2..]) });//针对返回消息包含"_"的消息 continue; } list.Add(new TaskLog() { BeginDate = arr[0], EndDate = arr[1], Msg = arr[2] }); -- Gitee From d2dcdc8ab97fb3e50db3cdba82776e6ee23a8845 Mon Sep 17 00:00:00 2001 From: 13476573407 <1062424570@qq.com> Date: Fri, 29 Jul 2022 10:10:52 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E4=B8=BA40=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Quartz.NET.Web/Utility/HttpManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Quartz.NET.Web/Utility/HttpManager.cs b/Quartz.NET.Web/Utility/HttpManager.cs index be274c2..6457865 100644 --- a/Quartz.NET.Web/Utility/HttpManager.cs +++ b/Quartz.NET.Web/Utility/HttpManager.cs @@ -44,6 +44,7 @@ namespace Quartz.NET.Web.Utility { var client = httpClientFactory.CreateClient(); + client.Timeout = TimeSpan.FromSeconds(40 * 60); var content = new StringContent(""); // content.Headers.ContentType = new MediaTypeHeaderValue(contentType); var request = new HttpRequestMessage(method, url) -- Gitee From 7cd89779526aeb459e7005a5e9416d10fc0c57be Mon Sep 17 00:00:00 2001 From: 13476573407 <1062424570@qq.com> Date: Fri, 29 Jul 2022 10:13:24 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Id=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=8C=E5=AE=9E=E7=8E=B0=E5=AF=B9=E4=BB=BB=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Quartz.NET.Web/Extensions/QuartzNETExtension.cs | 3 ++- Quartz.NET.Web/Models/TaskOptions.cs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Quartz.NET.Web/Extensions/QuartzNETExtension.cs b/Quartz.NET.Web/Extensions/QuartzNETExtension.cs index bc5674f..b4e3aab 100644 --- a/Quartz.NET.Web/Extensions/QuartzNETExtension.cs +++ b/Quartz.NET.Web/Extensions/QuartzNETExtension.cs @@ -107,6 +107,7 @@ namespace Quartz.NET.Web.Extensions list.Add(taskOptions); } } + list = list.OrderBy(o=>o.Id).ToList(); } catch (Exception ex) { @@ -318,7 +319,7 @@ namespace Quartz.NET.Web.Extensions errorMsg = $"未找到分组[{groupName}]"; return new { status = false, msg = errorMsg }; } - JobKey jobKey = jobKeys.Where(s => scheduler.GetTriggersOfJob(s).Result.Any(x => (x as CronTriggerImpl).Name == taskName)).FirstOrDefault(); + JobKey jobKey = jobKeys.Where(s => scheduler.GetTriggersOfJob(s).Result.Any(x => (x as CronTriggerImpl)?.Name == taskName)).FirstOrDefault(); if (jobKey == null) { errorMsg = $"未找到触发器[{taskName}]"; diff --git a/Quartz.NET.Web/Models/TaskOptions.cs b/Quartz.NET.Web/Models/TaskOptions.cs index 692b2cd..6e97569 100644 --- a/Quartz.NET.Web/Models/TaskOptions.cs +++ b/Quartz.NET.Web/Models/TaskOptions.cs @@ -4,6 +4,7 @@ namespace Quartz.NET.Web.Models { public class TaskOptions { + public int Id { get; set; } public string TaskName { get; set; } public string GroupName { get; set; } public string Interval { get; set; } -- Gitee From e6465a87444955776a5fa404c0ee5fd812d36894 Mon Sep 17 00:00:00 2001 From: 13476573407 <1062424570@qq.com> Date: Fri, 29 Jul 2022 10:28:02 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E4=BB=BB=E5=8A=A1=EF=BC=8C=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4=E3=80=81=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E3=80=81=E6=9A=82=E5=81=9C=E7=AD=89=20=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=85=A8=E9=80=89=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Views/TaskBackGround/Index.cshtml | 6 +- Quartz.NET.Web/wwwroot/js/task-index.js | 185 ++++++++++++++++-- 2 files changed, 173 insertions(+), 18 deletions(-) diff --git a/Quartz.NET.Web/Views/TaskBackGround/Index.cshtml b/Quartz.NET.Web/Views/TaskBackGround/Index.cshtml index 89aaa1f..db04f1a 100644 --- a/Quartz.NET.Web/Views/TaskBackGround/Index.cshtml +++ b/Quartz.NET.Web/Views/TaskBackGround/Index.cshtml @@ -59,11 +59,11 @@ 暂停任务 开启任务 立即执行 - 修改任务 - 删除任务 + @*修改任务*@ + 删除任务 刷新数据 - + diff --git a/Quartz.NET.Web/wwwroot/js/task-index.js b/Quartz.NET.Web/wwwroot/js/task-index.js index bfb7723..0e21722 100644 --- a/Quartz.NET.Web/wwwroot/js/task-index.js +++ b/Quartz.NET.Web/wwwroot/js/task-index.js @@ -28,7 +28,7 @@ var $taskVue = new Vue({ modelMessage: '任务管理', activedIndex: 0, taskValidate: { - taskName: '', groupName: '', interval: '', apiUrl: '', authKey: '', authValue: + id: '', taskName: '', groupName: '', interval: '', apiUrl: '', authKey: '', authValue: '', describe: '', requestType: '' }, ruleValidate: { @@ -58,15 +58,24 @@ var $taskVue = new Vue({ key: 'id', width: 120 }, + { + title: '序号', + key: 'id', + width: 70, + align: 'center', + fixed: 'left' + }, { type: 'selection', width: 60, - align: 'center' + align: 'center', + fixed: 'left' }, { title: '作业名称', key: 'taskName', - width: 150 + width: 150, + fixed: 'left' }, { title: '分组', key: 'groupName', @@ -135,7 +144,7 @@ var $taskVue = new Vue({ { title: '描述', key: 'describe', - minWidth: 200 + minWidth: 180 }, { title: 'ApiUrl', @@ -150,23 +159,92 @@ var $taskVue = new Vue({ { title: '操作', key: 'operat', - width: 100, + width: 580, render: (h, params) => { - var style = { 'font-size': '12px' }; + var style = { 'font-size': '12px', 'marginRight': '5px' }; return h('div', [ h('i-button', { props: { //type: 'error', size: 'small' - }, style: style, on: { click: function () { $taskVue.getJobRunLog(params); + console.log(params); + } + } + }, '执行记录'), + h('i-button', { + props: { + type: 'success', + size: 'small', + icon: 'ios-power' + }, style: style, + on: { + click: function () { + $taskVue.tiggerActionLine('pause', params.row); + } + } + }, '暂停任务'), + h('i-button', { + props: { + type: 'warning', + size: 'small', + icon: 'md-arrow-dropright' + }, style: style, + on: { + click: function () { + $taskVue.tiggerActionLine('start', params.row); + } + } + }, '开启任务'), + h('i-button', { + props: { + type: 'primary', + size: 'small', + icon: 'md-open' + }, style: style, + on: { + click: function () { + $taskVue.tiggerActionLine('run', params.row); + } + } + }, '立即执行'), + h('i-button', { + props: { + type: 'error', + size: 'small', + icon: 'md-construct' + }, style: style, + on: { + click: function () { + $taskVue.updateLine(params.row); + } + } + }, '修改任务'), + h('i-button', { + props: { + //type: 'primary', + size: 'small', + icon: 'md-close' + }, style: style, + on: { + click: function () { + $taskVue.$Modal.confirm({ + title: 'Title', + content: '

删除确认

', + onOk: () => { + $taskVue.tiggerActionLine('remove', params.row); + }, + onCancel: () => { + $taskVue.$Message.info('取消操作'); + } + }); } } - }, '执行记录') + }, '删除任务') ]); } } @@ -188,11 +266,10 @@ var $taskVue = new Vue({ return columns; }, selectRow: function (selection, row) { - if (row) { - this.select.currentRow = row; - } else if (selection && selection.length) { - this.select.currentRow = selection[0]; - } + this.select.currentRow = row; + this.select.rows = selection; + }, + selectChange: function (selection) { this.select.rows = selection; }, first: function () { @@ -249,11 +326,36 @@ var $taskVue = new Vue({ this.setFormClass(false); this.model = true; }, + //批量操作 tiggerAction: function (action) { - if (!this.select.rows.length) + if (!this.select.rows.length) { return $taskVue.$Message.success('请选择作业!'); + } + this.ajaxAll('/TaskBackGround/' + action, this.select.rows); + }, + //批量删除 + tiggerActionRemove: function (action) { + if (!this.select.rows.length) { + return $taskVue.$Message.success('请选择作业!'); + } + $taskVue.$Modal.confirm({ + title: 'Title', + content: '

删除确认

', + onOk: () => { + this.ajaxAll('/TaskBackGround/' + action, this.select.rows); + }, + onCancel: () => { + $taskVue.$Message.info('取消操作'); + } + }); + }, + //行内操作 + tiggerActionLine: function (action, row) { + if (!row) { + return $taskVue.$Message.success('请选择作业!'); + } this.ajax('/TaskBackGround/' + action, - this.select.rows[0], function (data) { + row, function (data) { if (data.status) { $taskVue.refresh(true); } @@ -272,6 +374,31 @@ var $taskVue = new Vue({ this.setFormClass(true); //this.taskForm[0] }, + //多行编辑(未改造完成) + updateMulti: function () { + // this.tiggerAction('update'); + if (!this.select.rows.length) + return $taskVue.$Message.success('请选择作业!'); + this.model = true; + //this.taskValidate = this.select.rows.slice(0, 1)[0]; + for (var key in this.select.rows[0]) { + this.taskValidate[key] = this.select.rows[0][key]; + } + this.setFormClass(true); + //this.taskForm[0] + }, + //行内编辑 + updateLine: function (row) { + if (!row) + return $taskVue.$Message.success('请选择作业!'); + this.model = true; + //this.taskValidate = this.select.rows.slice(0, 1)[0]; + for (var key in row) { + this.taskValidate[key] = row[key]; + } + this.setFormClass(true); + //this.taskForm[0] + }, refresh: function (_init) { this.select.currentRow = []; this.select.rows = {}; @@ -293,6 +420,7 @@ var $taskVue = new Vue({ if (!valid) { return this.$Message.error('数据填写不完整!'); } + this.taskValidate.id = this.rows.length; this.ajax("/TaskBackGround/" + (this.isAdd ? 'add' : 'update'), this.taskValidate, function (data) { $taskVue.$Message.success(data.msg || '保存成功'); if (data.status) { @@ -327,6 +455,33 @@ var $taskVue = new Vue({ $taskVue.$Message.success('出错啦!'); console.log(error); }); + }, + ajaxAll: function (url, params) { + let Axioses = []; + params.forEach(param => { + Axioses.push( + axios({ + method: 'post', + url: url, + params: param, + headers: { 'X-Requested-With': 'XMLHttpRequest' }, + timeout: 40 * 60 * 1000 + }) + ); + }); + axios.all(Axioses) + .then(axios.spread((...result) => { + let results = [...result]; + $taskVue.refresh(true); + results.forEach(item => $taskVue.$Message.success(item.data.msg)) + })) + .catch(function (error) { + if (error.response.status === 401) { + return window.location.href = '/home/index'; + } + $taskVue.$Message.success('出错啦!'); + console.log(error); + }); } }, created: function () { this.refresh(true); -- Gitee