任务框架

zw
rszn 6 months ago
parent 1e8194189c
commit 3811803739

@ -1,7 +0,0 @@
namespace Common
{
public class Class1
{
}
}

@ -1,10 +1,4 @@
using System; namespace HybirdFrameworkCore.Attribute
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkCore.Attribute
{ {
/// <summary> /// <summary>
/// 常量特性 /// 常量特性

@ -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();
}

@ -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; }
}

@ -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<string, ITask> TaskMap = new();
public static void Init()
{
var list = new List<Type>();
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();
}
}
}

@ -69,7 +69,7 @@ public class ChargerService
{ {
return Result<bool>.Fail(@"充电机未连接"); return Result<bool>.Fail(@"充电机未连接");
} }
chargerClient.SendRemoteStopCharging(); chargerClient.SendRemoteStopCharging();
return Result<bool>.Success("发送停止命令成功"); return Result<bool>.Success("发送停止命令成功");
@ -101,7 +101,7 @@ public class ChargerService
public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version) public SetPeakValleyTime BulidSetPeakValleyTimeObj(int version)
{ {
List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails = List<ElecPriceModelVersionDetail> elecPriceModelVersionDetails =
ElecPriceModelVersionDetailRepository.QueryListByClause(u => u.Version == version,u=>u.StartHour,OrderByType.Asc); ElecPriceModelVersionDetailRepository.QueryListByClause(u => u.Version == version,u=>u.StartHour,OrderByType.Asc);
SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime() SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime()
{ {
@ -142,14 +142,14 @@ public class ChargerService
{ {
BatteryStatusInfoResp batteryStatusInfoResp = new BatteryStatusInfoResp(); BatteryStatusInfoResp batteryStatusInfoResp = new BatteryStatusInfoResp();
List<BinInfo> binInfos = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1); List<BinInfo> binInfos = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1);
if(binInfos.Count>0) if(binInfos.Count>0)
batteryStatusInfoResp.btyTotalCount = binInfos.Count(); batteryStatusInfoResp.btyTotalCount = binInfos.Count();
List<BinInfo> canSwapCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.Soc > Convert.ToDecimal(StaticStationInfo.SwapSoc)); List<BinInfo> 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(); batteryStatusInfoResp.canSwapCount = canSwapCounts.Count();
List<BinInfo> chargingCounts = BinInfoRepository.QueryListByClause(i => i.Exists == 1 && i.Status == 1&&i.ChargeStatus==1); List<BinInfo> 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(); batteryStatusInfoResp.chargingCount = chargingCounts.Count();
return Result<BatteryStatusInfoResp>.Success(batteryStatusInfoResp); return Result<BatteryStatusInfoResp>.Success(batteryStatusInfoResp);
} }
} }

@ -3,13 +3,11 @@ using DotNetty.Transport.Channels;
using Entity.DbModel.Station; using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using HybirdFrameworkDriver.Session; using HybirdFrameworkDriver.Session;
using log4net; using log4net;
using Repository.Station; using Repository.Station;
using Service.Charger.Common; using Service.Charger.Common;
using Service.Equipment; using Service.Equipment;
using Service.Init;
namespace Service.Charger.Client; namespace Service.Charger.Client;
@ -19,7 +17,6 @@ namespace Service.Charger.Client;
[Scope("SingleInstance")] [Scope("SingleInstance")]
public static class ClientMgr public static class ClientMgr
{ {
private static readonly ILog Log = LogManager.GetLogger(typeof(ClientMgr)); private static readonly ILog Log = LogManager.GetLogger(typeof(ClientMgr));
public static readonly Dictionary<string, ChargerClient> Dictionary = new(); public static readonly Dictionary<string, ChargerClient> Dictionary = new();
@ -70,12 +67,14 @@ public static class ClientMgr
EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>(); EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>();
EquipNetInfoRepository netInfoRepository = AppInfo.Container.Resolve<EquipNetInfoRepository>(); EquipNetInfoRepository netInfoRepository = AppInfo.Container.Resolve<EquipNetInfoRepository>();
BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>(); BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
List<EquipInfo> equipInfos = equipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger); List<EquipInfo> equipInfos =
equipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger);
if (equipInfos.Count > 0) if (equipInfos.Count > 0)
{ {
Dictionary<string, EquipInfo> set = equipInfos.ToDictionary(it => it.Code, it => it); Dictionary<string, EquipInfo> set = equipInfos.ToDictionary(it => it.Code, it => it);
List<EquipNetInfo> equipNetInfos = netInfoRepository.QueryListByClause(it => set.Keys.Contains(it.Code)); List<EquipNetInfo> equipNetInfos = netInfoRepository.QueryListByClause(it => set.Keys.Contains(it.Code));
Dictionary<string,BinInfo> binInfoMap = binInfoRepository.QueryListByClause(it => set.Keys.Contains(it.ChargerNo)) Dictionary<string, BinInfo> binInfoMap = binInfoRepository
.QueryListByClause(it => set.Keys.Contains(it.ChargerNo))
.ToDictionary(it => it.ChargerNo, it => it); .ToDictionary(it => it.ChargerNo, it => it);
foreach (EquipNetInfo netInfo in equipNetInfos) foreach (EquipNetInfo netInfo in equipNetInfos)
{ {
@ -85,199 +84,6 @@ public static class ClientMgr
ConnClient(netInfo, binInfo); 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);
}
}
}
/// <summary>
///
/// </summary>
private static void StartAutoChargeThread()
{
if (!AutoChargeWorking)
{
Thread thread = new Thread(AutoChargeThread)
{
Name = @"AutoChargeThread"
};
thread.Start();
AutoChargeWorking = true;
}
}
/// <summary>
///
/// </summary>
private static void AutoChargeThread()
{
ElecPriceModelVersionRepository elecPriceModelVersionRepository =
AppInfo.Container.Resolve<ElecPriceModelVersionRepository>();
ElecPriceModelVersionDetailRepository elecPriceModelVersionDetailRepository =
AppInfo.Container.Resolve<ElecPriceModelVersionDetailRepository>();
BatteryOpModelRepository batteryOpModelRepository = AppInfo.Container.Resolve<BatteryOpModelRepository>();
BatteryOpModelDetailRepository batteryOpModelDetailRepository =
AppInfo.Container.Resolve<BatteryOpModelDetailRepository>();
BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
while (true)
{
try
{
Thread.Sleep(1000 * 30);
DateTime now = DateTime.Now;
if (StaticStationInfo.AutoChargeEnabled != 1)
{
Log.Info("AutoChargeEnabled = 0 continue");
continue;
}
List<BinInfo> 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<ElecPriceModelVersionDetail> 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<BatteryOpModelDetail> batteryOpModelDetails = batteryOpModelDetailRepository.QueryListByClause(d => d.ModelId == oid);
List<BatteryOpModelDetail> opModelDetails = batteryOpModelDetails.Where(t =>
{
List<int> start = t.StartTime.Split(":").Select(int.Parse).ToList();
List<int> 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<BinInfo> 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<BinInfo> 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<BinInfo> 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<string>? 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); client.SessionAttr(netInfo.Code, netInfo.DestAddr);
Log.Info($"succeed to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}"); Log.Info($"succeed to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}");
}); });
AddBySn(netInfo.Code, client); AddBySn(netInfo.Code, client);
Log.Info($"begin to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}"); Log.Info($"begin to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}");
} }
} }

@ -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<BinInfo> 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<ElecPriceModelVersionDetail> 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<BatteryOpModelDetail> batteryOpModelDetails =
batteryOpModelDetailRepository.QueryListByClause(d => d.ModelId == oid);
List<BatteryOpModelDetail> opModelDetails = batteryOpModelDetails.Where(t =>
{
List<int> start = t.StartTime.Split(":").Select(int.Parse).ToList();
List<int> 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<BinInfo> 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<BinInfo> 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<BinInfo> 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<string>? 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;
}
}

@ -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;
}
}

@ -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
{
/// <summary>
/// 获取任务列表
/// </summary>
/// <returns></returns>
[HttpGet("/GetAll")]
public Result<List<TaskInfo>> GetAll()
{
List<TaskInfo> result = new();
foreach (var (key, value) in TaskInit.TaskMap)
{
result.Add(new TaskInfo()
{
Name = key,
Interval = value.Interval(),
Stoped = value.Stoped()
});
}
return Result<List<TaskInfo>>.Success(result);
}
/// <summary>
/// 停止任务
/// </summary>
/// <param name="taskName"></param>
/// <returns></returns>
[HttpGet("/stop/{taskName}")]
public Result<bool> Stop(string taskName)
{
if (TaskInit.TaskMap.TryGetValue(taskName, out var task))
{
task.Stop();
return Result<bool>.Success(task.Stoped());
}
return Result<bool>.Fail("任务不存在");
}
/// <summary>
/// 启动任务
/// </summary>
/// <param name="taskName"></param>
/// <returns></returns>
[HttpGet("/start/{taskName}")]
public Result<bool> Start(string taskName)
{
if (TaskInit.TaskMap.TryGetValue(taskName, out var task))
{
task.Start();
return Result<bool>.Success(task.Stoped());
}
return Result<bool>.Fail("任务不存在");
}
}

@ -1,6 +1,7 @@
using Autofac; using Autofac;
using Autofac.Extensions.DependencyInjection; using Autofac.Extensions.DependencyInjection;
using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.AutoTask;
using HybirdFrameworkCore.Configuration; using HybirdFrameworkCore.Configuration;
using HybirdFrameworkCore.Entity; using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Redis; using HybirdFrameworkCore.Redis;
@ -34,7 +35,7 @@ builder.Host.ConfigureContainer<ContainerBuilder>(cb =>
//redis //redis
var redisConnectionString = AppSettingsHelper.GetContent("Redis", "Connection"); 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"); var defaultDb = int.Parse(AppSettingsHelper.GetContent("Redis", "DefaultDB") ?? "0");
if (redisConnectionString != null && instanceName != null) if (redisConnectionString != null && instanceName != null)
builder.Services.AddSingleton(new RedisHelper(redisConnectionString, instanceName, defaultDb)); 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, "WebStarter.xml"), true);
c.IncludeXmlComments(Path.Combine(basePath, "Entity.xml"), true); c.IncludeXmlComments(Path.Combine(basePath, "Entity.xml"), true);
c.IncludeXmlComments(Path.Combine(basePath, "HybirdFrameworkCore.xml"), true); c.IncludeXmlComments(Path.Combine(basePath, "HybirdFrameworkCore.xml"), true);
}); });
//跨域 //跨域
builder.Services.AddCors(options => builder.Services.AddCors(options =>
@ -96,4 +95,6 @@ foreach (var s in list.Split(";"))
AppInfo.Container = app.Services.GetAutofacRoot(); AppInfo.Container = app.Services.GetAutofacRoot();
ClientMgr.InitClient(); ClientMgr.InitClient();
app.Run(); TaskInit.Init();
app.Run();

Loading…
Cancel
Save