From 38118037396bbde105c26eec3e9b3322dfb1dee8 Mon Sep 17 00:00:00 2001 From: rszn <645583145@qq.com> Date: Sat, 1 Jun 2024 23:21:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/Class1.cs | 7 - .../Attribute/ConstAttribute.cs | 8 +- HybirdFrameworkCore/AutoTask/ITask.cs | 36 +++ HybirdFrameworkCore/AutoTask/TaskInfo.cs | 8 + HybirdFrameworkCore/AutoTask/TaskInit.cs | 38 ++++ Service/Charger/ChargerService.cs | 12 +- Service/Charger/Client/ClientMgr.cs | 206 +----------------- Service/Charger/MyTask/AutoChargeTask.cs | 185 ++++++++++++++++ .../Charger/MyTask/QueryBatteryInfoTask.cs | 54 +++++ .../Controllers/System/TaskController.cs | 67 ++++++ WebStarter/Program.cs | 9 +- 11 files changed, 406 insertions(+), 224 deletions(-) delete mode 100644 Common/Class1.cs create mode 100644 HybirdFrameworkCore/AutoTask/ITask.cs create mode 100644 HybirdFrameworkCore/AutoTask/TaskInfo.cs create mode 100644 HybirdFrameworkCore/AutoTask/TaskInit.cs create mode 100644 Service/Charger/MyTask/AutoChargeTask.cs create mode 100644 Service/Charger/MyTask/QueryBatteryInfoTask.cs create mode 100644 WebStarter/Controllers/System/TaskController.cs diff --git a/Common/Class1.cs b/Common/Class1.cs deleted file mode 100644 index e0f23b9..0000000 --- a/Common/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Common -{ - public class Class1 - { - - } -} diff --git a/HybirdFrameworkCore/Attribute/ConstAttribute.cs b/HybirdFrameworkCore/Attribute/ConstAttribute.cs index 8440e08..bf430c3 100644 --- a/HybirdFrameworkCore/Attribute/ConstAttribute.cs +++ b/HybirdFrameworkCore/Attribute/ConstAttribute.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace HybirdFrameworkCore.Attribute +namespace HybirdFrameworkCore.Attribute { /// /// 常量特性 diff --git a/HybirdFrameworkCore/AutoTask/ITask.cs b/HybirdFrameworkCore/AutoTask/ITask.cs new file mode 100644 index 0000000..74b6fc3 --- /dev/null +++ b/HybirdFrameworkCore/AutoTask/ITask.cs @@ -0,0 +1,36 @@ +namespace HybirdFrameworkCore.AutoTask; + +public interface ITask +{ + public string Name(); + public int Interval(); + public void Handle(); + + public void Start() + { + Stop(); + Thread.Sleep(Interval()); + ResetStop(); + Thread thread = new Thread(Process) + { + Name = Name(), + IsBackground = true + }; + + thread.Start(); + } + + void Process() + { + while (!Stoped()) + { + Thread.Sleep(Interval()); + Handle(); + } + } + + public bool Stoped(); + + public void Stop(); + public void ResetStop(); +} diff --git a/HybirdFrameworkCore/AutoTask/TaskInfo.cs b/HybirdFrameworkCore/AutoTask/TaskInfo.cs new file mode 100644 index 0000000..859e81f --- /dev/null +++ b/HybirdFrameworkCore/AutoTask/TaskInfo.cs @@ -0,0 +1,8 @@ +namespace HybirdFrameworkCore.AutoTask; + +public class TaskInfo +{ + public string Name { get; set; } + public int Interval { get; set; } + public bool Stoped { get; set; } +} diff --git a/HybirdFrameworkCore/AutoTask/TaskInit.cs b/HybirdFrameworkCore/AutoTask/TaskInit.cs new file mode 100644 index 0000000..d896567 --- /dev/null +++ b/HybirdFrameworkCore/AutoTask/TaskInit.cs @@ -0,0 +1,38 @@ +using System.Collections.Concurrent; +using Autofac; +using Autofac.Core; +using HybirdFrameworkCore.Autofac; + +namespace HybirdFrameworkCore.AutoTask; + +public class TaskInit +{ + public static readonly ConcurrentDictionary TaskMap = new(); + + public static void Init() + { + var list = new List(); + foreach (var reg in AppInfo.Container.ComponentRegistry.Registrations) + foreach (var service in reg.Services) + if (service is TypedService ts) + { + if (ts.ServiceType.GetInterface(nameof(ITask)) != null) + { + list.Add(ts.ServiceType); + } + } + + foreach (Type type in list) + { + var resolve = AppInfo.Container.Resolve(type); + ITask task = (ITask)resolve; + if (TaskMap.TryGetValue(task.Name(), out var exist)) + { + throw new ArgumentException($"same task name already added {exist.GetType()}"); + } + + TaskMap.TryAdd(task.Name(), task); + task.Start(); + } + } +} diff --git a/Service/Charger/ChargerService.cs b/Service/Charger/ChargerService.cs index 6dbd128..604820c 100644 --- a/Service/Charger/ChargerService.cs +++ b/Service/Charger/ChargerService.cs @@ -69,7 +69,7 @@ public class ChargerService { return Result.Fail(@"充电机未连接"); } - + chargerClient.SendRemoteStopCharging(); return Result.Success("发送停止命令成功"); @@ -101,7 +101,7 @@ public class ChargerService public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version) { - List elecPriceModelVersionDetails = + List elecPriceModelVersionDetails = ElecPriceModelVersionDetailRepository.QueryListByClause(u => u.Version == version,u=>u.StartHour,OrderByType.Asc); SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime() { @@ -142,14 +142,14 @@ public class ChargerService { BatteryStatusInfoResp batteryStatusInfoResp = new BatteryStatusInfoResp(); List binInfos = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1); - if(binInfos.Count>0) + if(binInfos.Count>0) batteryStatusInfoResp.btyTotalCount = binInfos.Count(); List canSwapCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.Soc > Convert.ToDecimal(StaticStationInfo.SwapSoc)); - if(canSwapCounts.Count>0) + if(canSwapCounts.Count>0) batteryStatusInfoResp.canSwapCount = canSwapCounts.Count(); List chargingCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.ChargeStatus==1); - if(chargingCounts.Count>0) + if(chargingCounts.Count>0) batteryStatusInfoResp.chargingCount = chargingCounts.Count(); return Result.Success(batteryStatusInfoResp); } -} \ No newline at end of file +} diff --git a/Service/Charger/Client/ClientMgr.cs b/Service/Charger/Client/ClientMgr.cs index eacbf02..7485e43 100644 --- a/Service/Charger/Client/ClientMgr.cs +++ b/Service/Charger/Client/ClientMgr.cs @@ -3,13 +3,11 @@ using DotNetty.Transport.Channels; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac.Attribute; -using HybirdFrameworkCore.Entity; using HybirdFrameworkDriver.Session; using log4net; using Repository.Station; using Service.Charger.Common; using Service.Equipment; -using Service.Init; namespace Service.Charger.Client; @@ -19,7 +17,6 @@ namespace Service.Charger.Client; [Scope("SingleInstance")] public static class ClientMgr { - private static readonly ILog Log = LogManager.GetLogger(typeof(ClientMgr)); public static readonly Dictionary Dictionary = new(); @@ -70,12 +67,14 @@ public static class ClientMgr EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve(); EquipNetInfoRepository netInfoRepository = AppInfo.Container.Resolve(); BinInfoRepository binInfoRepository = AppInfo.Container.Resolve(); - List equipInfos = equipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger); + List equipInfos = + equipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger); if (equipInfos.Count > 0) { Dictionary set = equipInfos.ToDictionary(it => it.Code, it => it); List equipNetInfos = netInfoRepository.QueryListByClause(it => set.Keys.Contains(it.Code)); - Dictionary binInfoMap = binInfoRepository.QueryListByClause(it => set.Keys.Contains(it.ChargerNo)) + Dictionary binInfoMap = binInfoRepository + .QueryListByClause(it => set.Keys.Contains(it.ChargerNo)) .ToDictionary(it => it.ChargerNo, it => it); foreach (EquipNetInfo netInfo in equipNetInfos) { @@ -85,199 +84,6 @@ public static class ClientMgr ConnClient(netInfo, binInfo); }); } - - StartAutoChargeThread(); - StartQueryBatteryInfoThread(); - } - } - - private static void StartQueryBatteryInfoThread() - { - Thread thread = new Thread(QueryBatteryInfo) - { - Name = @"QueryBatteryInfoThread" - }; - thread.Start(); - } - - private static void QueryBatteryInfo() - { - while (true) - { - try - { - Thread.Sleep(1000); - foreach (var (key, client) in Dictionary) - { - client.SendQueryBattery(); - } - } - catch (Exception e) - { - Log.Error("QueryBatteryInfo error", e); - } - - } - } - - /// - /// - /// - private static void StartAutoChargeThread() - { - if (!AutoChargeWorking) - { - Thread thread = new Thread(AutoChargeThread) - { - Name = @"AutoChargeThread" - }; - thread.Start(); - AutoChargeWorking = true; - } - } - /// - /// - /// - private static void AutoChargeThread() - { - ElecPriceModelVersionRepository elecPriceModelVersionRepository = - AppInfo.Container.Resolve(); - - ElecPriceModelVersionDetailRepository elecPriceModelVersionDetailRepository = - AppInfo.Container.Resolve(); - - BatteryOpModelRepository batteryOpModelRepository = AppInfo.Container.Resolve(); - BatteryOpModelDetailRepository batteryOpModelDetailRepository = - AppInfo.Container.Resolve(); - - BinInfoRepository binInfoRepository = AppInfo.Container.Resolve(); - - while (true) - { - try - { - Thread.Sleep(1000 * 30); - DateTime now = DateTime.Now; - - if (StaticStationInfo.AutoChargeEnabled != 1) - { - Log.Info("AutoChargeEnabled = 0 continue"); - continue; - } - - List binInfos = binInfoRepository.Query(); - if (binInfos.Count < 0) - { - Log.Info("lack of binInfos"); - continue; - } - - - #region 电价模型 - - int ceid = StaticStationInfo.Ceid; - ElecPriceModelVersion elecPriceModelVersion = elecPriceModelVersionRepository.QueryByClause(i => i.Version == ceid); - if (elecPriceModelVersion == null) - { - Log.Info("lack of effective elecPriceModelVersion"); - continue; - } - - List elecPriceModelVersionDetails = elecPriceModelVersionDetailRepository.QueryListByClause(it => it.Version == elecPriceModelVersion.Version); - ElecPriceModelVersionDetail? elecPriceModelVersionDetail = elecPriceModelVersionDetails.Where(i => i.StartHour <= now.Hour && i.StartMinute <= now.Minute - && i.EndHour > now.Hour && - i.EndMinute > now.Minute).FirstOrDefault(); - if (elecPriceModelVersionDetail == null) - { - Log.Info("lack of effective elecPriceModelVersionDetail"); - continue; - } - - #endregion - - #region 运营模型 - - int oid = int.Parse(StaticStationInfo.Oid); - BatteryOpModel batteryOpModel = batteryOpModelRepository.QueryByClause(d => d.ModelId == oid); - if (batteryOpModel == null) - { - Log.Info("lack of effective batteryOpModel"); - continue; - } - - List batteryOpModelDetails = batteryOpModelDetailRepository.QueryListByClause(d => d.ModelId == oid); - List opModelDetails = batteryOpModelDetails.Where(t => - { - List start = t.StartTime.Split(":").Select(int.Parse).ToList(); - List end = t.EndTime.Split(":").Select(int.Parse).ToList(); - return now.Hour >= start[0] && now.Hour < end[0] && now.Minute >= start[1] && now.Minute < end[1] && now.Second >= start[2] && now.Second < end[2] ; - }).ToList(); - - if (opModelDetails.Count == 0) - { - Log.Info("lack of effective batteryOpModelDetails"); - continue; - } - - int needBatteryCount = opModelDetails[0].BatteryCount ?? 8; - List canSwapList = binInfos.Where(it => it.Soc != null && Convert.ToSingle(it.Soc) >= StaticStationInfo.SwapSoc).ToList(); - if (canSwapList.Count == needBatteryCount) - { - Log.Info($"lack of needBatteryCount {needBatteryCount}"); - continue; - } - if(canSwapList.Count > needBatteryCount) - { - List chargingList = binInfos.Where(it => it.ChargeStatus == 1).ToList(); - - int needStopCount = chargingList.Count - (canSwapList.Count - needBatteryCount); - if (needStopCount > 0) - { - //停电量低的 - chargingList.Sort((a,b) => (a.Soc??0).CompareTo(b.Soc??0)); - for (int i = 0; i < needStopCount; i++) - { - Log.Info($"auto stop charge {chargingList[i].No}"); - GetBySn(chargingList[i].No)?.SendRemoteStopCharging(); - } - } - } - else - { - List canChargeList = binInfos.Where(it => it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.SwapSoc && it.CanChargeFlag == 1).ToList(); - //启动电量高的 - canChargeList.Sort((a,b) => (b.Soc??0).CompareTo(a.Soc??0)); - - byte chargeSoc = StaticStationInfo.ChargeSoc; - float chargePower = StaticStationInfo.ChargePower; - int count = needBatteryCount - canSwapList.Count; - int number = 0; - foreach (var binInfo in canChargeList) - { - Result? result = GetBySn(binInfo.ChargerNo)?.SendRemoteStartCharging(chargeSoc, chargePower); - if (result is {IsSuccess: true} ) - { - Log.Info($"auto start charge {binInfo.ChargerNo}"); - number++; - } - if (count == number) - { - Log.Info($"auto start charge count {count}"); - break; - } - } - } - - - - #endregion - - - } - catch (Exception e) - { - Log.Error("AutoChargeThread error", e); - } } } @@ -295,8 +101,8 @@ public static class ClientMgr client.SessionAttr(netInfo.Code, netInfo.DestAddr); Log.Info($"succeed to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}"); }); - + AddBySn(netInfo.Code, client); Log.Info($"begin to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}"); } -} \ No newline at end of file +} diff --git a/Service/Charger/MyTask/AutoChargeTask.cs b/Service/Charger/MyTask/AutoChargeTask.cs new file mode 100644 index 0000000..176eaf8 --- /dev/null +++ b/Service/Charger/MyTask/AutoChargeTask.cs @@ -0,0 +1,185 @@ +using Entity.DbModel.Station; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.Entity; +using HybirdFrameworkCore.AutoTask; +using log4net; +using Repository.Station; +using Service.Charger.Client; +using Service.Init; + +namespace Service.Charger.MyTask; + +[Scope] +public class AutoChargeTask : ITask +{ + private static readonly ILog Log = LogManager.GetLogger(typeof(AutoChargeTask)); + private volatile bool _stop; + + public ElecPriceModelVersionRepository elecPriceModelVersionRepository { get; set; } + public ElecPriceModelVersionDetailRepository elecPriceModelVersionDetailRepository { get; set; } + public BatteryOpModelRepository batteryOpModelRepository { get; set; } + public BatteryOpModelDetailRepository batteryOpModelDetailRepository { get; set; } + public BinInfoRepository binInfoRepository { get; set; } + + public string Name() + { + return "AutoChargeTask"; + } + + public int Interval() + { + return 1000 * 30; + } + + public void Handle() + { + try + { + DateTime now = DateTime.Now; + + if (StaticStationInfo.AutoChargeEnabled != 1) + { + Log.Info("AutoChargeEnabled = 0 continue"); + return; + } + + List binInfos = binInfoRepository.Query(); + if (binInfos.Count < 0) + { + Log.Info("lack of binInfos"); + return; + } + + + #region 电价模型 + + int ceid = StaticStationInfo.Ceid; + ElecPriceModelVersion elecPriceModelVersion = + elecPriceModelVersionRepository.QueryByClause(i => i.Version == ceid); + if (elecPriceModelVersion == null) + { + Log.Info("lack of effective elecPriceModelVersion"); + return; + } + + List elecPriceModelVersionDetails = + elecPriceModelVersionDetailRepository.QueryListByClause(it => + it.Version == elecPriceModelVersion.Version); + ElecPriceModelVersionDetail? elecPriceModelVersionDetail = elecPriceModelVersionDetails.Where(i => + i.StartHour <= now.Hour && i.StartMinute <= now.Minute + && i.EndHour > now.Hour && + i.EndMinute > now.Minute).FirstOrDefault(); + if (elecPriceModelVersionDetail == null) + { + Log.Info("lack of effective elecPriceModelVersionDetail"); + return; + } + + #endregion + + #region 运营模型 + + int oid = int.Parse(StaticStationInfo.Oid); + BatteryOpModel batteryOpModel = batteryOpModelRepository.QueryByClause(d => d.ModelId == oid); + if (batteryOpModel == null) + { + Log.Info("lack of effective batteryOpModel"); + return; + } + + List batteryOpModelDetails = + batteryOpModelDetailRepository.QueryListByClause(d => d.ModelId == oid); + List opModelDetails = batteryOpModelDetails.Where(t => + { + List start = t.StartTime.Split(":").Select(int.Parse).ToList(); + List end = t.EndTime.Split(":").Select(int.Parse).ToList(); + return now.Hour >= start[0] && now.Hour < end[0] && now.Minute >= start[1] && now.Minute < end[1] && + now.Second >= start[2] && now.Second < end[2]; + }).ToList(); + + if (opModelDetails.Count == 0) + { + Log.Info("lack of effective batteryOpModelDetails"); + return; + } + + int needBatteryCount = opModelDetails[0].BatteryCount ?? 8; + List canSwapList = binInfos.Where(it => + it.Soc != null && Convert.ToSingle(it.Soc) >= StaticStationInfo.SwapSoc && it.CanSwapFlag == 1) + .ToList(); + if (canSwapList.Count == needBatteryCount) + { + Log.Info($"lack of needBatteryCount {needBatteryCount}"); + return; + } + + if (canSwapList.Count > needBatteryCount) + { + List chargingList = binInfos.Where(it => it.ChargeStatus == 1).ToList(); + + int needStopCount = chargingList.Count - (canSwapList.Count - needBatteryCount); + if (needStopCount > 0) + { + //停电量低的 + chargingList.Sort((a, b) => (a.Soc ?? 0).CompareTo(b.Soc ?? 0)); + for (int i = 0; i < needStopCount; i++) + { + Log.Info($"auto stop charge {chargingList[i].No}"); + ClientMgr.GetBySn(chargingList[i].No)?.SendRemoteStopCharging(); + } + } + } + else + { + List canChargeList = binInfos.Where(it => + it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.ChargeSoc && + it.CanChargeFlag == 1) + .ToList(); + //启动电量高的 + canChargeList.Sort((a, b) => (b.Soc ?? 0).CompareTo(a.Soc ?? 0)); + + byte chargeSoc = StaticStationInfo.ChargeSoc; + float chargePower = StaticStationInfo.ChargePower; + int count = needBatteryCount - canSwapList.Count; + int number = 0; + foreach (var binInfo in canChargeList) + { + Result? result = ClientMgr.GetBySn(binInfo.ChargerNo) + ?.SendRemoteStartCharging(chargeSoc, chargePower); + if (result is { IsSuccess: true }) + { + Log.Info($"auto start charge {binInfo.ChargerNo}"); + number++; + } + + if (count == number) + { + Log.Info($"auto start charge count {count}"); + break; + } + } + } + + #endregion + } + catch (Exception e) + { + Log.Error("handle with error", e); + } + } + + public bool Stoped() + { + return _stop; + } + + public void Stop() + { + _stop = true; + } + + public void ResetStop() + { + _stop = false; + } +} diff --git a/Service/Charger/MyTask/QueryBatteryInfoTask.cs b/Service/Charger/MyTask/QueryBatteryInfoTask.cs new file mode 100644 index 0000000..679d661 --- /dev/null +++ b/Service/Charger/MyTask/QueryBatteryInfoTask.cs @@ -0,0 +1,54 @@ +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.AutoTask; +using log4net; +using Service.Charger.Client; + +namespace Service.Charger.MyTask; + +[Scope] +public class QueryBatteryInfoTask : ITask +{ + private volatile bool _stop; + private static readonly ILog Log = LogManager.GetLogger(typeof(QueryBatteryInfoTask)); + + public string Name() + { + return "QueryBatteryInfo"; + } + + public int Interval() + { + return 1000; + } + + public void Handle() + { + try + { + foreach (var (key, client) in ClientMgr.Dictionary) + { + client.SendQueryBattery(); + } + } + catch (Exception e) + { + Log.Error(e); + } + + } + + public bool Stoped() + { + return _stop; + } + + public void Stop() + { + _stop = true; + } + + public void ResetStop() + { + _stop = false; + } +} diff --git a/WebStarter/Controllers/System/TaskController.cs b/WebStarter/Controllers/System/TaskController.cs new file mode 100644 index 0000000..fd7b5d6 --- /dev/null +++ b/WebStarter/Controllers/System/TaskController.cs @@ -0,0 +1,67 @@ +using HybirdFrameworkCore.Entity; +using HybirdFrameworkCore.AutoTask; +using Microsoft.AspNetCore.Mvc; + +namespace WebStarter.Controllers.System; + +[Produces("application/json")] +[ApiController] +[Route("api/[controller]")] +public class TaskController +{ + /// + /// 获取任务列表 + /// + /// + [HttpGet("/GetAll")] + public Result> GetAll() + { + List result = new(); + foreach (var (key, value) in TaskInit.TaskMap) + { + result.Add(new TaskInfo() + { + Name = key, + Interval = value.Interval(), + Stoped = value.Stoped() + }); + } + + return Result>.Success(result); + } + + /// + /// 停止任务 + /// + /// + /// + [HttpGet("/stop/{taskName}")] + public Result Stop(string taskName) + { + if (TaskInit.TaskMap.TryGetValue(taskName, out var task)) + { + task.Stop(); + return Result.Success(task.Stoped()); + } + + return Result.Fail("任务不存在"); + } + + + /// + /// 启动任务 + /// + /// + /// + [HttpGet("/start/{taskName}")] + public Result Start(string taskName) + { + if (TaskInit.TaskMap.TryGetValue(taskName, out var task)) + { + task.Start(); + return Result.Success(task.Stoped()); + } + + return Result.Fail("任务不存在"); + } +} diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index 0fcbbb1..1a4dfe7 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -1,6 +1,7 @@ using Autofac; using Autofac.Extensions.DependencyInjection; using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.AutoTask; using HybirdFrameworkCore.Configuration; using HybirdFrameworkCore.Entity; using HybirdFrameworkCore.Redis; @@ -34,7 +35,7 @@ builder.Host.ConfigureContainer(cb => //redis var redisConnectionString = AppSettingsHelper.GetContent("Redis", "Connection"); -var instanceName = AppSettingsHelper.GetContent("Redis", "InstanceName");//默认数据库 +var instanceName = AppSettingsHelper.GetContent("Redis", "InstanceName"); //默认数据库 var defaultDb = int.Parse(AppSettingsHelper.GetContent("Redis", "DefaultDB") ?? "0"); if (redisConnectionString != null && instanceName != null) builder.Services.AddSingleton(new RedisHelper(redisConnectionString, instanceName, defaultDb)); @@ -52,8 +53,6 @@ builder.Services.AddSwaggerGen(c => c.IncludeXmlComments(Path.Combine(basePath, "WebStarter.xml"), true); c.IncludeXmlComments(Path.Combine(basePath, "Entity.xml"), true); c.IncludeXmlComments(Path.Combine(basePath, "HybirdFrameworkCore.xml"), true); - - }); //跨域 builder.Services.AddCors(options => @@ -96,4 +95,6 @@ foreach (var s in list.Split(";")) AppInfo.Container = app.Services.GetAutofacRoot(); ClientMgr.InitClient(); -app.Run(); \ No newline at end of file +TaskInit.Init(); + +app.Run();