重构代码

重构代码
This commit is contained in:
chenchun
2022-04-02 17:44:50 +08:00
parent c6371ba72d
commit f5fb2ea17b
105 changed files with 1489 additions and 4654 deletions

View File

@@ -1,24 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Model;
using Yi.Framework.Model.ModelFactory;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
public static class DbExtend
{
public static IServiceCollection AddDbService(this IServiceCollection services)
{
DbContextFactory.MutiDB_Enabled = Appsettings.appBool("MutiDB_Enabled");
DataContext.DbSelect = Appsettings.app("DbSelect");
DataContext._connStr = Appsettings.app("DbConn", "WriteUrl");
services.Configure<DbConnOptions>(Appsettings.appConfiguration("DbConn"));
return services;
}
}
}

View File

@@ -1,36 +0,0 @@
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.Model.ModelFactory;
using Yi.Framework.WebCore.Init;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
public static class DbSeedInitExtend
{
private static readonly ILog log = LogManager.GetLogger(typeof(DbSeedInitExtend));
public static void UseDbSeedInitService(this IApplicationBuilder app, IDbContextFactory _DbFactory)
{
if (Appsettings.appBool("DbSeed_Enabled"))
{
if (app == null) throw new ArgumentNullException(nameof(app));
try
{
DataSeed.SeedAsync(_DbFactory).Wait();
}
catch (Exception e)
{
log.Error($"Error occured seeding the Database.\n{e.Message}");
throw;
}
}
}
}
}

View File

@@ -5,7 +5,6 @@ using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using Yi.Framework.Model;
using Yi.Framework.Model.ModelFactory;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
@@ -20,10 +19,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
//配置文件使用配置
#endregion
services.AddSingleton(new Appsettings(configuration));
#region
//数据库配置
#endregion
services.AddTransient<DbContext, DataContext>();
return services;
}

View File

@@ -7,8 +7,6 @@ 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
{
@@ -24,7 +22,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
try
{
RedisInit.Seed(_cacheClientDB);
//RedisInit.Seed(_cacheClientDB);
}
catch (Exception e)
{