|
|
using Admin.Core.Common;
|
|
|
using Admin.Core.Extensions;
|
|
|
using Admin.Core.IRepository;
|
|
|
using Admin.Core.IService;
|
|
|
using Admin.Core.IService.ISys;
|
|
|
using Admin.Core.Model;
|
|
|
using Admin.Core.Repository;
|
|
|
using Admin.Core.Service;
|
|
|
using Admin.Core.Tasks;
|
|
|
using Autofac;
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using System.Text;
|
|
|
|
|
|
namespace Admin.Core.Wpf
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Startup
|
|
|
/// </summary>
|
|
|
public class Startup
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Startup
|
|
|
/// </summary>
|
|
|
/// <param name="configuration"></param>
|
|
|
public Startup(IConfiguration configuration, IWebHostEnvironment env)
|
|
|
{
|
|
|
Configuration = configuration;
|
|
|
Env = env;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// IConfiguration
|
|
|
/// </summary>
|
|
|
public IConfiguration Configuration { get; }
|
|
|
/// <summary>
|
|
|
/// 环境信息:开发/生产
|
|
|
/// </summary>
|
|
|
public IWebHostEnvironment Env { get; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
/// </summary>
|
|
|
/// <param name="services"></param>
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
{
|
|
|
//Appsettings
|
|
|
services.AddSingleton(new Appsettings(Configuration));
|
|
|
//日志文件目录
|
|
|
services.AddSingleton(new LogLock(Env.ContentRootPath));
|
|
|
//Memory缓存
|
|
|
services.AddMemoryCacheSetup();
|
|
|
//Sqlsugar数据库模型查询
|
|
|
services.AddSqlsugarSetup();
|
|
|
//AutoMapper
|
|
|
services.AddAutoMapperSetup();
|
|
|
|
|
|
//注册业务服务
|
|
|
AddServices(services);
|
|
|
|
|
|
//任务调度
|
|
|
services.AddJobSetup();
|
|
|
|
|
|
//支持编码大全 例如:支持 System.Text.Encoding.GetEncoding("GB2312") System.Text.Encoding.GetEncoding("GB18030")
|
|
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 注意在Program.CreateHostBuilder,添加Autofac服务工厂
|
|
|
/// </summary>
|
|
|
/// <param name="builder"></param>
|
|
|
public void ConfigureContainer(ContainerBuilder builder)
|
|
|
{
|
|
|
builder.RegisterModule(new AutofacModuleRegister());
|
|
|
builder.RegisterModule<AutofacPropertityModuleReg>();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
/// </summary>
|
|
|
/// <param name="app"></param>
|
|
|
/// <param name="env"></param>
|
|
|
public void Configure(IApplicationBuilder app, ISysTasksQzService tasksQzService, ISchedulerCenter schedulerCenter)
|
|
|
{
|
|
|
// 使用静态文件
|
|
|
app.UseStaticFiles();
|
|
|
// 然后是授权中间件
|
|
|
//app.UseAuthorization();
|
|
|
|
|
|
// 开启QuartzNetJob调度服务
|
|
|
app.UseQuartzJobMildd(tasksQzService, schedulerCenter);
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 注册服务
|
|
|
/// <summary>
|
|
|
/// 注册服务
|
|
|
/// </summary>
|
|
|
/// <param name="services"></param>
|
|
|
private static void AddServices(IServiceCollection services)
|
|
|
{
|
|
|
#region 注册服务
|
|
|
//services.AddScoped<IEEquipmentCategoryServices, EEquipmentCategoryServices>();
|
|
|
//services.AddScoped<IEEquipmentCategoryRepository, EEquipmentCategoryRepository>();
|
|
|
//services.AddScoped<IBaseRepository<EEquipmentCategory>, BaseRepository<EEquipmentCategory>>();
|
|
|
//services.AddSingleton<IBaseServices<EEquipmentCategory>, BaseServices<EEquipmentCategory>>();
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|