登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
登录
注册
代码拉取完成,页面将自动刷新
开源项目
>
WEB应用开发
>
后台管理框架
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
13.3K
Star
15.9K
Fork
3.5K
zuohuaijun
/
Admin.NET
代码
Issues
5
Pull Requests
2
Wiki
统计
流水线
服务
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
1885
修复定时任务无法正常更新的临时解决方案
已关闭
NOBB:v2
zuohuaijun:v2
NOBB
创建于 2025-08-28 00:33
克隆/下载
HTTPS
SSH
复制
下载 Email Patch
下载 Diff 文件
1. 修复定时任务无法正常更新的临时解决方案(加一个定时任务示例文件) --- ### 该 Pull Request 关联的 Issue 无 ### 修改描述 我看定时任务 不管是 sqllite 还是pg ,都有同样的问题,每次我都更新了定时任务,我想测试,`RunOnStart = false` 或者`Minutely` 还是修改任何的描述,发现数据库根本就不变, 最新的 Furion 框架不是最新的似乎已经修复了(更新引用后到 Furion4.9.112 并没有解决),见下文 定时任务示例文件: ```c# namespace Admin.NET.Core; /// <summary> /// 有道云笔记签到作业任务 /// </summary> // [DailyAt] //每天特定小时开始作业触发器特性 [JobDetail("job_Demo", Description = "Demo定时任务", GroupName = "HeMaCup", Concurrent = false)] [Daily(TriggerId = "trigger_Demo", Description = "Demo定时任务", RunOnStart = false)] // [Minutely(TriggerId = "trigger_panda", Description = "签到")] // [Cron("3,7,8 * * * * ?", CronStringFormat.WithSeconds)] public class DemoJob(IServiceScopeFactory scopeFactory, ILoggerFactory loggerFactory) : IJob { private readonly ILogger _logger = loggerFactory.CreateLogger(CommonConst.SysLogCategoryName); public Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken) { using var serviceScope = scopeFactory.CreateScope(); var db = serviceScope.ServiceProvider.GetRequiredService<ISqlSugarClient>().CopyNew(); var sysConfigService = serviceScope.ServiceProvider.GetRequiredService<SysConfigService>(); string msg = $"【{DateTime.Now}】签到成功"; var originColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(msg); Console.ForegroundColor = originColor; // 自定义日志 _logger.LogInformation(msg); _logger.LogInformation($"【{DateTime.Now}】签到成功"); return Task.CompletedTask; } } ``` 在看了日志后,发现应该是Furion框架内部的更新机制 日志如下: ```shell-script _ _ _ _ ______ _______ /\ | | (_) | \ | | ____|__ __| / \ __| |_ __ ___ _ _ __ | \| | |__ | | / /\ \ / _` | '_ ` _ \| | '_ \ | . ` | __| | | / ____ \ (_| | | | | | | | | | |_| |\ | |____ | | /_/ \_\__,_|_| |_| |_|_|_| |_(_)_| \_|______| |_| 让.NET更简单、更通用、更流行! info: 2025-08-27 23:36:40(+08:00) Wednesday L System.Logging.TaskQueueService[0] #1 TaskQueue hosted service is running. info: 2025-08-27 23:36:40(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 Schedule hosted service is running. info: 2025-08-27 23:36:40(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 Schedule hosted service is preloading... info: 2025-08-27 23:36:40(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The <trigger_Demo> trigger for scheduler of <job_Demo> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The scheduler of <job_Demo> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The scheduler of <job_EnumToDictJob> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The <trigger_log> trigger for scheduler of <job_log> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The scheduler of <job_log> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The <trigger_onlineUser> trigger for scheduler of <job_onlineUser> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The scheduler of <job_onlineUser> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The scheduler of <SyncDingTalkRoleJob> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The <SyncDingTalkUserTrigger> trigger for scheduler of <SyncDingTalkUserJob> successfully appended to the schedule. info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 The scheduler of <SyncDingTalkUserJob> successfully appended to the schedule. warn: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.ScheduleService[0] #1 Schedule hosted service preload completed, and a total of <10> schedulers are appended. 【2025/8/27 23:36:41】系统枚举转换字典 【2025/8/27 23:36:41】系统枚举转换字典的枚举类名称必须以Enum结尾: JobState (JobState) 【2025/8/27 23:36:41】清理在线用户成功!服务已重启... info: 2025-08-27 23:36:41(+08:00) Wednesday L System.Logging.LoggingMonitor[0] #19 【2025/8/27 23:36:41】清理在线用户成功!服务已重启... AutoVersionUpdate 中间件运行 当前版本:1.0.0 历史版本:1.0.0,更新时间:2025-08-27 23:30:24,是否已执行True 当前版本号与历史版本号相同,且已执行过脚本,不再执行 【2025/8/27 23:36:41】系统枚举类转字典类型数据: 插入0条, 更新37条, 共37条。 【2025/8/27 23:36:42】系统枚举项转字典值数据: 插入0条, 更新436条, 共436条。 ``` 看了最新的 Furion4.9.112 的代码后,发现在 `322行 338行` 写的是 `_logger.LogInformation("The <{triggerId}> trigger for scheduler of <{jobId}> successfully {triggerOperation} to the schedule.", triggerId, jobId, triggerOperation);` 写的是 `appended and updated` 但是 Admin.Net 写的只有 `Append` 我在数据库初始化时候 在sqlsugar 的 `Admin.NET\Admin.NET.Core\SqlSugar\SqlSugarSetup.cs"` 的 `InitDatabase` 中添加(临时方案,后续更新Furion版本应该会解决) ```c# // 使用 SqlSugar 的 Truncate 方法 dbProvider.DbMaintenance.TruncateTable("SysJobDetail"); dbProvider.DbMaintenance.TruncateTable("SysJobTrigger"); // Log.Information("已清空 SysJobDetail, SysJobTrigger 表"); ``` 最新有几个commit 是关于 定时任务的,我将依赖中的108版本更新到了112,还是一样的问题,提示 Furion版本修复估计还得一阵 代码如下: ```c# // Furion-v4\framework\Furion.Pure\Schedule\Factories\SchedulerFactory.Exports.cs /// <summary> /// 保存作业 /// </summary> /// <param name="schedulerBuilder">作业计划构建器</param> /// <param name="scheduler">作业计划</param> /// <param name="immediately">是否立即通知作业调度器重新载入</param> /// <returns><see cref="ScheduleResult"/></returns> public ScheduleResult TrySaveJob(SchedulerBuilder schedulerBuilder, out IScheduler scheduler, bool immediately = true) { /* 其他代码 */ // 将作业触发器运行信息写入持久化 foreach (var (triggerId, trigger) in finalScheduler.Triggers) { // 如果作业已删除标记作业触发器为已删除状态 if (isRemoved) trigger.Behavior = PersistenceBehavior.Removed; Shorthand(finalScheduler.JobDetail, trigger, trigger.Behavior); // 输出日志 var triggerOperation = Penetrates.SetFirstLetterCase(trigger.Behavior.ToString(), false); // 处理作业调度器初始化未完成时做更新操作情况 if (!PreloadCompleted && trigger.Behavior == PersistenceBehavior.Updated) { triggerOperation = "appended and updated"; } _logger.LogInformation("The <{triggerId}> trigger for scheduler of <{jobId}> successfully {triggerOperation} to the schedule.", triggerId, jobId, triggerOperation); // 确保作业触发器合法性 EnsureLegalOfTrigger(trigger, nowTime); } // 取消作业调度器休眠状态(强制唤醒) if (immediately) CancelSleep(); // 输出日志 var jobOperation = Penetrates.SetFirstLetterCase(schedulerBuilder.Behavior.ToString(), false); // 处理作业调度器初始化未完成时做更新操作情况 if (!PreloadCompleted && isUpdated) { jobOperation = "appended and updated"; } _logger.LogInformation("The scheduler of <{JobId}> successfully {jobOperation} to the schedule.", jobId, jobOperation); scheduler = finalScheduler; return ScheduleResult.Succeed; } ```
此 Pull Request 需要通过一些审核项
类型
指派人员
状态
审查
zuohuaijun
IMaster
skywolf627
写意
喵你个汪
进行中
(0/1人)
测试
zuohuaijun
IMaster
skywolf627
写意
喵你个汪
进行中
(0/1人)
怎样手动合并此 Pull Request
git checkout v2
git pull https://gitee.com/nobb2333/Admin.NET.git v2
git push origin v2
评论
3
提交
2
文件
2
检查
代码问题
0
批量操作
展开设置
折叠设置
审查
Code Owner
审查人员
写意
xjj_0906
skywolf627
skywolf627
IMaster
orzmaster
喵你个汪
jasondom
zuohuaijun
zuohuaijun
未设置
最少人数
1
测试
写意
xjj_0906
skywolf627
skywolf627
IMaster
orzmaster
喵你个汪
jasondom
zuohuaijun
zuohuaijun
未设置
最少人数
1
优先级
不指定
严重
主要
次要
不重要
标签
标签管理
未设置
关联 Issue
未关联
Pull Request 合并后将关闭上述关联 Issue
里程碑
未关联里程碑
参与者
(2)
C#
1
https://gitee.com/zuohuaijun/Admin.NET.git
git@gitee.com:zuohuaijun/Admin.NET.git
zuohuaijun
Admin.NET
Admin.NET
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册