From 5c5c1d51b52691e1a3ca3e4fbdee572587e56b8d Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Fri, 31 May 2024 13:40:00 +0800 Subject: [PATCH] =?UTF-8?q?.net8=20=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebExtensions/IPRateExtension.cs | 27 ------------ Infrastructure/ZR.Infrastructure.csproj | 3 +- ZR.Admin.WebApi/DOAN.WebApi.csproj | 4 +- ZR.Admin.WebApi/Program.cs | 9 ++-- .../PublishProfiles/FolderProfile.pubxml | 4 +- ZR.CodeGenerator/ZR.CodeGenerator.csproj | 2 +- ZR.Common/ZR.Common.csproj | 2 +- ZR.Model/ZR.Model.csproj | 2 +- ZR.Repository/ZR.Repository.csproj | 2 +- ZR.Service/ZR.Service.csproj | 2 +- ZR.ServiceCore/ZR.ServiceCore.csproj | 2 +- ZR.Tasks/TaskScheduler/Job_Device_Execute.cs | 42 +++++++++++++++++++ ZR.Tasks/ZR.Tasks.csproj | 2 +- 13 files changed, 59 insertions(+), 44 deletions(-) delete mode 100644 Infrastructure/WebExtensions/IPRateExtension.cs create mode 100644 ZR.Tasks/TaskScheduler/Job_Device_Execute.cs diff --git a/Infrastructure/WebExtensions/IPRateExtension.cs b/Infrastructure/WebExtensions/IPRateExtension.cs deleted file mode 100644 index 2eccadf..0000000 --- a/Infrastructure/WebExtensions/IPRateExtension.cs +++ /dev/null @@ -1,27 +0,0 @@ -using AspNetCoreRateLimit; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using System; - -namespace ZR.Infrastructure.WebExtensions -{ - public static class IPRateExtension - { - public static void AddIPRate(this IServiceCollection services, IConfiguration configuration) - { - if (services == null) throw new ArgumentNullException(nameof(services)); - - //从appsettings.json中加载常规配置,IpRateLimiting与配置文件中节点对应 - services.Configure(configuration.GetSection("IpRateLimiting")); - - //从appsettings.json中加载Ip规则 - services.Configure(configuration.GetSection("IpRateLimitPolicies")); - //注入计数器和规则存储 - services.AddSingleton(); - services.AddSingleton(); - //配置(解析器、计数器密钥生成器) - services.AddSingleton(); - services.AddSingleton(); - } - } -} diff --git a/Infrastructure/ZR.Infrastructure.csproj b/Infrastructure/ZR.Infrastructure.csproj index f96d4e0..9043a76 100644 --- a/Infrastructure/ZR.Infrastructure.csproj +++ b/Infrastructure/ZR.Infrastructure.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 8632 @@ -20,7 +20,6 @@ - diff --git a/ZR.Admin.WebApi/DOAN.WebApi.csproj b/ZR.Admin.WebApi/DOAN.WebApi.csproj index 002f07c..c55744b 100644 --- a/ZR.Admin.WebApi/DOAN.WebApi.csproj +++ b/ZR.Admin.WebApi/DOAN.WebApi.csproj @@ -1,6 +1,6 @@  - net7.0 + net8.0 enable enable true @@ -25,7 +25,7 @@ - + diff --git a/ZR.Admin.WebApi/Program.cs b/ZR.Admin.WebApi/Program.cs index 13d0078..5fa733b 100644 --- a/ZR.Admin.WebApi/Program.cs +++ b/ZR.Admin.WebApi/Program.cs @@ -1,5 +1,6 @@ -using AspNetCoreRateLimit; + using Infrastructure.Converter; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; using NLog.Web; using System.Text.Json; @@ -31,7 +32,8 @@ builder.Services.AddDataProtection() //普通验证码 builder.Services.AddCaptcha(builder.Configuration); //IPRatelimit -builder.Services.AddIPRate(builder.Configuration); + + //builder.Services.AddSession(); builder.Services.AddHttpContextAccessor(); //绑定整个对象到Model上 @@ -123,8 +125,7 @@ if (builder.Environment.IsProduction()) //使用swagger app.UseSwagger(); //启用客户端IP限制速率 -app.UseIpRateLimiting(); -app.UseRateLimiter(); + //设置socket连接 app.MapHub("/msgHub"); diff --git a/ZR.Admin.WebApi/Properties/PublishProfiles/FolderProfile.pubxml b/ZR.Admin.WebApi/Properties/PublishProfiles/FolderProfile.pubxml index 009f7e3..800ee1b 100644 --- a/ZR.Admin.WebApi/Properties/PublishProfiles/FolderProfile.pubxml +++ b/ZR.Admin.WebApi/Properties/PublishProfiles/FolderProfile.pubxml @@ -10,11 +10,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121. Release Any CPU FileSystem - bin\Release\net7.0\publish\ + bin\Release\net8.0\publish\ FileSystem <_TargetId>Folder - net7.0 + net8.0 e5497bb4-b0c1-4794-9fae-163f626ec399 true Production diff --git a/ZR.CodeGenerator/ZR.CodeGenerator.csproj b/ZR.CodeGenerator/ZR.CodeGenerator.csproj index 620ceae..047f5f7 100644 --- a/ZR.CodeGenerator/ZR.CodeGenerator.csproj +++ b/ZR.CodeGenerator/ZR.CodeGenerator.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 diff --git a/ZR.Common/ZR.Common.csproj b/ZR.Common/ZR.Common.csproj index 9f75ddc..cfa82d0 100644 --- a/ZR.Common/ZR.Common.csproj +++ b/ZR.Common/ZR.Common.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 diff --git a/ZR.Model/ZR.Model.csproj b/ZR.Model/ZR.Model.csproj index fd9c075..fbed56d 100644 --- a/ZR.Model/ZR.Model.csproj +++ b/ZR.Model/ZR.Model.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 true 1701;1702;1591;1570 diff --git a/ZR.Repository/ZR.Repository.csproj b/ZR.Repository/ZR.Repository.csproj index d5e0de2..829a49b 100644 --- a/ZR.Repository/ZR.Repository.csproj +++ b/ZR.Repository/ZR.Repository.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 diff --git a/ZR.Service/ZR.Service.csproj b/ZR.Service/ZR.Service.csproj index 84ec04d..13f5dc7 100644 --- a/ZR.Service/ZR.Service.csproj +++ b/ZR.Service/ZR.Service.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable true diff --git a/ZR.ServiceCore/ZR.ServiceCore.csproj b/ZR.ServiceCore/ZR.ServiceCore.csproj index 82db85b..4a32e4a 100644 --- a/ZR.ServiceCore/ZR.ServiceCore.csproj +++ b/ZR.ServiceCore/ZR.ServiceCore.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable true 1701;1702;1591;1570 diff --git a/ZR.Tasks/TaskScheduler/Job_Device_Execute.cs b/ZR.Tasks/TaskScheduler/Job_Device_Execute.cs new file mode 100644 index 0000000..b1db2c6 --- /dev/null +++ b/ZR.Tasks/TaskScheduler/Job_Device_Execute.cs @@ -0,0 +1,42 @@ +using Infrastructure; +using Infrastructure.Attribute; +using Microsoft.Extensions.DependencyInjection; +using Quartz; +using Quartz.Impl.Triggers; +using Quartz.Impl; +using SqlSugar.IOC; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZR.Model.System; + +namespace ZR.Tasks.TaskScheduler +{ + /// + /// 设备管理 调度每日的巡检和点检 + /// + [AppService(ServiceType = typeof(Job_Device_Execute), ServiceLifetime = LifeTime.Scoped)] + public class Job_Device_Execute : JobBase, IJob + { + private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); + + public async Task Execute(IJobExecutionContext context) + { + await ExecuteJob(context, async () => await Run(context)); + } + public async Task Run(IJobExecutionContext context) + { + AbstractTrigger trigger = (context as JobExecutionContextImpl).Trigger as AbstractTrigger; + //var info = await tasksQzService.CopyNew().GetByIdAsync(trigger.JobName); + var info = await DbScoped.SugarScope.CopyNew().Queryable().FirstAsync(f => f.ID == trigger.JobName); + if (info == null) + { + throw new CustomException($"任务{trigger?.JobName}设备管理调度请求执行失败,任务不存在"); + } + string result; + + } + } +} diff --git a/ZR.Tasks/ZR.Tasks.csproj b/ZR.Tasks/ZR.Tasks.csproj index 221d49b..b6f4a0b 100644 --- a/ZR.Tasks/ZR.Tasks.csproj +++ b/ZR.Tasks/ZR.Tasks.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0