You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.1 KiB
C#

using Aucma.Scada.Api.Config;
using Aucma.Scada.Api.Repository.service;
using Aucma.Scada.Api.Repository.service.Impl;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace Aucma.Scada.Api.Repository
{
public static class SqlsugarSetup
{
/// <summary>
/// 注册SqlSugar
/// </summary>
/// <param name="services"></param>
public static void AddSqlSugarSetup(this IServiceCollection services)
{
services.AddSingleton<ISqlSugarClient>(x =>
{
var appConfig = x.GetService<AppConfig>();
SqlSugarScope Db = new SqlSugarScope(new List<ConnectionConfig>()
{
new ConnectionConfig()
{
ConfigId = "mes",
DbType = DbType.SqlServer,
ConnectionString = appConfig.mesConnStr,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
},
new ConnectionConfig()
{
ConfigId = "scada",
DbType = DbType.Oracle,
ConnectionString = appConfig.mcsConnStr,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
}
},
db =>
{
db.Aop.OnLogExecuting = (sql, pars) => { };
});
return Db;
});
}
/// <summary>
/// 注册Repository、Service服务
/// </summary>
/// <param name="services"></param>
public static void AddServices(this IServiceCollection services)
{
services.AddSingleton(typeof(Repository<>));
services.AddSingleton<IRecordElectricalinspectionService, RecordElectricalinspectionServiceImpl>();
services.AddSingleton<IDetailElectricalinspectionService, DetailElectricalinspectionServiceImpl>();
}
}
}