From 816eda3af352c389a36be59fef5312cfa9c37857 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Mon, 15 May 2023 14:45:44 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=BB=E5=8A=A1=E8=B0=83?=
=?UTF-8?q?=E5=BA=A6=20=E8=BF=98=E6=9C=89=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Listener/GenerateSpotInspectionPlanTimeWorker.cs | 11 +++++++++++
taskschedule/Tnb.TaskScheduler/TimeTaskService.cs | 8 +++++---
2 files changed, 16 insertions(+), 3 deletions(-)
create mode 100644 taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
new file mode 100644
index 00000000..b124ee33
--- /dev/null
+++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
@@ -0,0 +1,11 @@
+namespace JNPF.TaskScheduler.Listener
+{
+ public class GenerateSpotInspectionPlanTimeWorker : ISpareTimeWorker
+ {
+ [SpareTime("0 45 14 * * ? *", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
+ public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
+ {
+ Console.WriteLine("hello world");
+ }
+ }
+}
\ No newline at end of file
diff --git a/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs b/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs
index 651711b5..fb492e0f 100644
--- a/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs
+++ b/taskschedule/Tnb.TaskScheduler/TimeTaskService.cs
@@ -377,14 +377,16 @@ public class TimeTaskService : ITimeTaskService, IDynamicApiController, ITransie
///
private async Task> GetTaskMethods()
{
- var taskMethods = await _cacheManager.GetAsync>(CommonConst.CACHEKEYTIMERJOB);
- if (taskMethods != null) return taskMethods;
+ // var taskMethods = await _cacheManager.GetAsync>(CommonConst.CACHEKEYTIMERJOB);
+ // if (taskMethods != null) return taskMethods;
+
+ List taskMethods = null;
// 获取所有本地任务方法,必须有spareTimeAttribute特性
taskMethods = App.EffectiveTypes
.Where(u => u.IsClass && !u.IsInterface && !u.IsAbstract && typeof(ISpareTimeWorker).IsAssignableFrom(u))
.SelectMany(u => u.GetMethods(BindingFlags.Public | BindingFlags.Instance)
- .Where(m => m.IsDefined(typeof(SpareTimeAttribute), false) &&
+ .Where(m => m.GetCustomAttributes(typeof(SpareTimeAttribute), false).ToString().Contains("SpareTime") &&
m.GetParameters().Length == 2 &&
m.GetParameters()[0].ParameterType == typeof(SpareTimer) &&
m.GetParameters()[1].ParameterType == typeof(long) && m.ReturnType == typeof(void))