合并同步
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
@@ -20,10 +21,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public class SettingController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<SettingController> _logger;
|
||||
private readonly CacheClientDB _cacheClientDB;
|
||||
|
||||
public SettingController(ILogger<SettingController> logger)
|
||||
public SettingController(ILogger<SettingController> logger, CacheClientDB cacheClientDB)
|
||||
{
|
||||
_logger = logger;
|
||||
_cacheClientDB = cacheClientDB;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,21 +36,20 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetSetting()
|
||||
{
|
||||
var p = RedisConst.stringData[RedisConst.ImageList_key];
|
||||
return Result.Success();
|
||||
public Result GetSetting()
|
||||
{
|
||||
return Result.Success().SetData( _cacheClientDB.Get<SettingDto>(RedisConst.key));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="_Setting"></param>
|
||||
/// <param name="settingDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateSetting()
|
||||
public Result UpdateSetting(SettingDto settingDto)
|
||||
{
|
||||
|
||||
_cacheClientDB.Set(RedisConst.key, settingDto);
|
||||
return Result.Success();
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Model.ModelFactory;
|
||||
using Yi.Framework.WebCore.MiddlewareExtend;
|
||||
using Yi.Framework.WebCore.Utility;
|
||||
@@ -83,7 +84,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
#endregion
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,IDbContextFactory _DbFactory)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,IDbContextFactory _DbFactory, CacheClientDB _cacheClientDB)
|
||||
{
|
||||
//if (env.IsDevelopment())
|
||||
{
|
||||
@@ -141,7 +142,7 @@ namespace Yi.Framework.ApiMicroservice
|
||||
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseDbSeedInitService(_DbFactory);
|
||||
|
||||
app.UseRedisInitService(_cacheClientDB);
|
||||
#region
|
||||
//Endpointsע<73><D7A2>
|
||||
#endregion
|
||||
|
||||
@@ -1,68 +1,69 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"Consul_Enabled": false,
|
||||
"DbSeed_Enabled": true,
|
||||
"Apollo_Enabled": false,
|
||||
"HealthCheck_Enabled": false,
|
||||
"Cors_Enabled": true,
|
||||
"RabbitMQ_Enabled": false,
|
||||
"Redis_Enabled": false,
|
||||
"Kafka_Enabled": false,
|
||||
"MutiDB_Enabled": false,
|
||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||
"DbSelect": "Mysql",
|
||||
"Consul_Enabled": false,
|
||||
"DbSeed_Enabled": true,
|
||||
"Apollo_Enabled": false,
|
||||
"HealthCheck_Enabled": false,
|
||||
"Cors_Enabled": true,
|
||||
"RabbitMQ_Enabled": false,
|
||||
"Redis_Enabled": false,
|
||||
"RedisSet_Enabled": false,
|
||||
"Kafka_Enabled": false,
|
||||
"MutiDB_Enabled": false,
|
||||
"DbList": ["Sqlite", "Mysql", "Sqlserver", "Oracle"],
|
||||
"DbSelect": "Mysql",
|
||||
|
||||
"DbConn": {
|
||||
"WriteUrl": "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"ReadUrl": [
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020."
|
||||
]
|
||||
},
|
||||
"Apollo": {
|
||||
"AppId": "Yi.Framework.ApiMicroservice",
|
||||
"Env": "DEV",
|
||||
"MetaServer": "http://192.168.2.168:8080",
|
||||
"ConfigServer": [ "http://192.168.2.168:8080" ]
|
||||
},
|
||||
"JWTTokenOptions": {
|
||||
"Audience": "http://localhost:7000",
|
||||
"Issuer": "http://localhost:7000",
|
||||
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
|
||||
},
|
||||
"RedisConn": {
|
||||
"Host": "118.195.191.41",
|
||||
"Prot": 6379,
|
||||
"DB": 1,
|
||||
"Password": "Qz52013142020."
|
||||
},
|
||||
"KafkaOptions": {
|
||||
"BrokerList": "192.168.3.230:9092",
|
||||
"TopicName": "kafkalog"
|
||||
},
|
||||
"ConsulClientOption": {
|
||||
"IP": "192.168.2.128",
|
||||
"Port": "8500",
|
||||
"Datacenter": "dc1"
|
||||
},
|
||||
"ConsulRegisterOption": {
|
||||
"IP": "192.168.1.104",
|
||||
"Port": "7001",
|
||||
"GroupName": "ApiMicroservice",
|
||||
"HealthCheckUrl": "/Health",
|
||||
"Interval": 10,
|
||||
"Timeout": 5,
|
||||
"DeregisterCriticalServiceAfter": 60,
|
||||
"Tag": "13"
|
||||
},
|
||||
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
|
||||
}
|
||||
"DbConn": {
|
||||
"WriteUrl": "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"ReadUrl": [
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
|
||||
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020."
|
||||
]
|
||||
},
|
||||
"Apollo": {
|
||||
"AppId": "Yi.Framework.ApiMicroservice",
|
||||
"Env": "DEV",
|
||||
"MetaServer": "http://192.168.2.168:8080",
|
||||
"ConfigServer": ["http://192.168.2.168:8080"]
|
||||
},
|
||||
"JWTTokenOptions": {
|
||||
"Audience": "http://localhost:7000",
|
||||
"Issuer": "http://localhost:7000",
|
||||
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
|
||||
},
|
||||
"RedisConn": {
|
||||
"Host": "118.195.191.41",
|
||||
"Prot": 6379,
|
||||
"DB": 1,
|
||||
"Password": "Qz52013142020."
|
||||
},
|
||||
"KafkaOptions": {
|
||||
"BrokerList": "192.168.3.230:9092",
|
||||
"TopicName": "kafkalog"
|
||||
},
|
||||
"ConsulClientOption": {
|
||||
"IP": "192.168.2.128",
|
||||
"Port": "8500",
|
||||
"Datacenter": "dc1"
|
||||
},
|
||||
"ConsulRegisterOption": {
|
||||
"IP": "192.168.1.104",
|
||||
"Port": "7001",
|
||||
"GroupName": "ApiMicroservice",
|
||||
"HealthCheckUrl": "/Health",
|
||||
"Interval": 10,
|
||||
"Timeout": 5,
|
||||
"DeregisterCriticalServiceAfter": 60,
|
||||
"Tag": "13"
|
||||
},
|
||||
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
|
||||
}
|
||||
@@ -11,32 +11,32 @@ namespace Yi.Framework.Common.Const
|
||||
/// <summary>
|
||||
/// 前缀
|
||||
/// </summary>
|
||||
private const string prefix = "Yi:";
|
||||
public const string key = "YiFramework:data";
|
||||
|
||||
/// <summary>
|
||||
/// 初始化角色名
|
||||
/// </summary>
|
||||
public const string InitRole_key = nameof(InitRole_key);
|
||||
///// <summary>
|
||||
///// 初始化角色名
|
||||
///// </summary>
|
||||
//public const string InitRole_key = nameof(InitRole_key);
|
||||
|
||||
/// <summary>
|
||||
/// 标题名
|
||||
/// </summary>
|
||||
public const string Title_key = nameof(Title_key);
|
||||
///// <summary>
|
||||
///// 标题名
|
||||
///// </summary>
|
||||
//public const string Title_key = nameof(Title_key);
|
||||
|
||||
/// <summary>
|
||||
/// 图片列表名
|
||||
/// </summary>
|
||||
public const string ImageList_key = nameof(ImageList_key);
|
||||
///// <summary>
|
||||
///// 图片列表名
|
||||
///// </summary>
|
||||
//public const string ImageList_key = nameof(ImageList_key);
|
||||
|
||||
public static Dictionary<string, string> stringData = new Dictionary<string, string>()
|
||||
{
|
||||
{prefix+nameof(InitRole_key), "普通用户"},
|
||||
{prefix+nameof(Title_key), "YiFramework"},
|
||||
};
|
||||
//public static Dictionary<string, string> stringData = new Dictionary<string, string>()
|
||||
//{
|
||||
// {prefix+nameof(InitRole_key), "普通用户"},
|
||||
// {prefix+nameof(Title_key), "YiFramework"},
|
||||
//};
|
||||
|
||||
public static Dictionary<string, List<string>> listData = new Dictionary<string, List<string>>()
|
||||
{
|
||||
{prefix+nameof(ImageList_key), new List<string>(){"图片地址1", "图片地址2", "图片地址3", "图片地址4" } }
|
||||
};
|
||||
//public static Dictionary<string, List<string>> listData = new Dictionary<string, List<string>>()
|
||||
//{
|
||||
// {prefix+nameof(ImageList_key), new List<string>(){"图片地址1", "图片地址2", "图片地址3", "图片地址4" } }
|
||||
//};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,9 @@ namespace Yi.Framework.DTOModel
|
||||
{
|
||||
public class SettingDto
|
||||
{
|
||||
public string InitIcon_key { get; set; }
|
||||
public string InitRole_key { get; set; }
|
||||
public string Title_key { get; set; }
|
||||
public List<string> ImageList_key { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
using NPOI.SS.UserModel;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.WebCore
|
||||
{
|
||||
public class Excel
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取Excel多Sheet数据
|
||||
/// </summary>
|
||||
/// <param name="filePath">文件路径</param>
|
||||
/// <param name="sheetName">Sheet名</param>
|
||||
/// <returns></returns>
|
||||
public static DataSet ReadExcelToDataSet(string filePath, string sheetName = null)
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
//LogUtil.Debug($"未找到文件{filePath}");
|
||||
return null;
|
||||
}
|
||||
//获取文件信息
|
||||
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||
IWorkbook workbook = WorkbookFactory.Create(fs);
|
||||
//获取sheet信息
|
||||
ISheet sheet = null;
|
||||
DataSet ds = new DataSet();
|
||||
if (!string.IsNullOrEmpty(sheetName))
|
||||
{
|
||||
sheet = workbook.GetSheet(sheetName);
|
||||
if (sheet == null)
|
||||
{
|
||||
//LogUtil.Debug($"{filePath}未找到sheet:{sheetName}");
|
||||
return null;
|
||||
}
|
||||
DataTable dt = ReadExcelFunc(workbook, sheet);
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
//遍历获取所有数据
|
||||
int sheetCount = workbook.NumberOfSheets;
|
||||
for (int i = 0; i < sheetCount; i++)
|
||||
{
|
||||
sheet = workbook.GetSheetAt(i);
|
||||
if (sheet != null)
|
||||
{
|
||||
DataTable dt = ReadExcelFunc(workbook, sheet);
|
||||
ds.Tables.Add(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取Excel信息
|
||||
/// </summary>
|
||||
/// <param name="workbook">工作区</param>
|
||||
/// <param name="sheet">sheet</param>
|
||||
/// <returns></returns>
|
||||
private static DataTable ReadExcelFunc(IWorkbook workbook, ISheet sheet)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
//获取列信息
|
||||
IRow cells = sheet.GetRow(sheet.FirstRowNum);
|
||||
int cellsCount = cells.PhysicalNumberOfCells;
|
||||
int emptyCount = 0;
|
||||
int cellIndex = sheet.FirstRowNum;
|
||||
List<string> listColumns = new List<string>();
|
||||
bool isFindColumn = false;
|
||||
while (!isFindColumn)
|
||||
{
|
||||
emptyCount = 0;
|
||||
listColumns.Clear();
|
||||
for (int i = 0; i < cellsCount; i++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(cells.GetCell(i).StringCellValue))
|
||||
{
|
||||
emptyCount++;
|
||||
}
|
||||
listColumns.Add(cells.GetCell(i).StringCellValue);
|
||||
}
|
||||
//这里根据逻辑需要,空列超过多少判断
|
||||
if (emptyCount == 0)
|
||||
{
|
||||
isFindColumn = true;
|
||||
}
|
||||
cellIndex++;
|
||||
cells = sheet.GetRow(cellIndex);
|
||||
}
|
||||
|
||||
foreach (string columnName in listColumns)
|
||||
{
|
||||
if (dt.Columns.Contains(columnName))
|
||||
{
|
||||
//如果允许有重复列名,自己做处理
|
||||
continue;
|
||||
}
|
||||
dt.Columns.Add(columnName, typeof(string));
|
||||
}
|
||||
//开始获取数据
|
||||
int rowsCount = sheet.PhysicalNumberOfRows;
|
||||
cellIndex += 1;
|
||||
DataRow dr = null;
|
||||
for (int i = cellIndex; i < rowsCount; i++)
|
||||
{
|
||||
cells = sheet.GetRow(i);
|
||||
dr = dt.NewRow();
|
||||
for (int j = 0; j < dt.Columns.Count; j++)
|
||||
{
|
||||
//这里可以判断数据类型
|
||||
switch (cells.GetCell(j).CellType)
|
||||
{
|
||||
case CellType.String:
|
||||
dr[j] = cells.GetCell(j).StringCellValue;
|
||||
break;
|
||||
case CellType.Numeric:
|
||||
dr[j] = cells.GetCell(j).NumericCellValue.ToString();
|
||||
break;
|
||||
case CellType.Unknown:
|
||||
dr[j] = cells.GetCell(j).StringCellValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出Excel文件
|
||||
/// </summary>
|
||||
/// <typeparam name="T">数据类型</typeparam>
|
||||
/// <param name="entities">数据实体</param>
|
||||
/// <param name="dicColumns">列对应关系,如Name->姓名</param>
|
||||
/// <param name="title">标题</param>
|
||||
/// <returns></returns>
|
||||
public static byte[] ExportExcel<T>(List<T> entities, Dictionary<string, string> dicColumns, string title = null)
|
||||
{
|
||||
if (entities.Count <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//HSSFWorkbook => xls
|
||||
//XSSFWorkbook => xlsx
|
||||
IWorkbook workbook = new XSSFWorkbook();
|
||||
ISheet sheet = workbook.CreateSheet("test");//名称自定义
|
||||
IRow cellsColumn = null;
|
||||
IRow cellsData = null;
|
||||
//获取实体属性名
|
||||
PropertyInfo[] properties = entities[0].GetType().GetProperties();
|
||||
int cellsIndex = 0;
|
||||
//标题
|
||||
if (!string.IsNullOrEmpty(title))
|
||||
{
|
||||
ICellStyle style = workbook.CreateCellStyle();
|
||||
//边框
|
||||
style.BorderBottom = BorderStyle.Dotted;
|
||||
style.BorderLeft = BorderStyle.Hair;
|
||||
style.BorderRight = BorderStyle.Hair;
|
||||
style.BorderTop = BorderStyle.Dotted;
|
||||
//水平对齐
|
||||
style.Alignment = HorizontalAlignment.Left;
|
||||
|
||||
//垂直对齐
|
||||
style.VerticalAlignment = VerticalAlignment.Center;
|
||||
|
||||
//设置字体
|
||||
IFont font = workbook.CreateFont();
|
||||
font.FontHeightInPoints = 10;
|
||||
font.FontName = "微软雅黑";
|
||||
style.SetFont(font);
|
||||
|
||||
IRow cellsTitle = sheet.CreateRow(0);
|
||||
cellsTitle.CreateCell(0).SetCellValue(title);
|
||||
cellsTitle.RowStyle = style;
|
||||
//合并单元格
|
||||
sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 1, 0, dicColumns.Count - 1));
|
||||
cellsIndex = 2;
|
||||
}
|
||||
//列名
|
||||
cellsColumn = sheet.CreateRow(cellsIndex);
|
||||
int index = 0;
|
||||
Dictionary<string, int> columns = new Dictionary<string, int>();
|
||||
foreach (var item in dicColumns)
|
||||
{
|
||||
cellsColumn.CreateCell(index).SetCellValue(item.Value);
|
||||
columns.Add(item.Value, index);
|
||||
index++;
|
||||
}
|
||||
cellsIndex += 1;
|
||||
//数据
|
||||
foreach (var item in entities)
|
||||
{
|
||||
cellsData = sheet.CreateRow(cellsIndex);
|
||||
for (int i = 0; i < properties.Length; i++)
|
||||
{
|
||||
if (!dicColumns.ContainsKey(properties[i].Name)) continue;
|
||||
//这里可以也根据数据类型做不同的赋值,也可以根据不同的格式参考上面的ICellStyle设置不同的样式
|
||||
object[] entityValues = new object[properties.Length];
|
||||
entityValues[i] = properties[i].GetValue(item);
|
||||
//获取对应列下标
|
||||
index = columns[dicColumns[properties[i].Name]];
|
||||
cellsData.CreateCell(index).SetCellValue(entityValues[i].ToString());
|
||||
}
|
||||
cellsIndex++;
|
||||
}
|
||||
|
||||
byte[] buffer = null;
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
workbook.Write(ms);
|
||||
buffer = ms.GetBuffer();
|
||||
ms.Close();
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.ModelFactory;
|
||||
using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.Model.DbInit
|
||||
namespace Yi.Framework.WebCore.Init
|
||||
{
|
||||
public class DataSeed
|
||||
{
|
||||
31
Yi.Framework/Yi.Framework.WebCore/Init/RedisInit.cs
Normal file
31
Yi.Framework/Yi.Framework.WebCore/Init/RedisInit.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.DTOModel;
|
||||
|
||||
namespace Yi.Framework.WebCore.Init
|
||||
{
|
||||
public class RedisInit
|
||||
{
|
||||
public static void Seed(CacheClientDB _cacheClientDB)
|
||||
{
|
||||
|
||||
if (_cacheClientDB.Get<SettingDto>(RedisConst.key)==null)
|
||||
{
|
||||
_cacheClientDB.Add(RedisConst.key, new SettingDto()
|
||||
{
|
||||
ImageList_key = { "默认图片", "默认图片" } ,
|
||||
InitRole_key= "默认角色",
|
||||
Title_key= "默认标题",
|
||||
InitIcon_key= "默认头像"
|
||||
}) ;
|
||||
}
|
||||
|
||||
Console.WriteLine(nameof(RedisInit) + ":Redis初始成功!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.DbInit;
|
||||
using Yi.Framework.Model.ModelFactory;
|
||||
using Yi.Framework.WebCore.Init;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.OpenApi.Models;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Core;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
@@ -17,6 +18,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
if (Appsettings.appBool("Redis_Enabled"))
|
||||
{
|
||||
services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConn"));
|
||||
services.AddTransient<CacheClientDB>();
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using log4net;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Model.ModelFactory;
|
||||
using Yi.Framework.WebCore.Init;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static class RedisInitExtend
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(RedisInitExtend));
|
||||
public static void UseRedisInitService(this IApplicationBuilder app, CacheClientDB _cacheClientDB)
|
||||
{
|
||||
|
||||
if (Appsettings.appBool("RedisSet_Enabled"))
|
||||
{
|
||||
if (app == null) throw new ArgumentNullException(nameof(app));
|
||||
|
||||
try
|
||||
{
|
||||
RedisInit.Seed(_cacheClientDB);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.Error($"Error occured seeding the RedisInit.\n{e.Message}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,13 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="5.0.4" />
|
||||
<PackageReference Include="NPOI" Version="2.5.5" />
|
||||
<PackageReference Include="Quartz.AspNetCore" Version="3.3.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user