1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using EInk.TaskThread;
- using Microsoft.AspNetCore.Builder;
- using SqlSugar;
- using EInk.Models;
- using EInk.Tools;
- using Microsoft.Extensions.Options;
- namespace EInk.Lot2Lot3
- {
-
- public class TaskFilter : IStartupFilter
- {
- private static IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
- private readonly ISqlSugarClient _local_db = new SqlSugarClient(new ConnectionConfig()
- {
- DbType = DbType.PostgreSQL,
- ConnectionString = config.GetValue<string>("LocalDbConnectionString"),
- IsAutoCloseConnection = true
- });
- public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
- {
- _local_db.DbMaintenance.CreateDatabase();
- _local_db.CodeFirst.InitTables(typeof(DefectModel));
- _local_db.CodeFirst.InitTables(typeof(Lot2Lot3Model));
- _local_db.CodeFirst.InitTables(typeof(ColourCastModel));
- if (config.GetValue<bool>("ReadLot2Thread") ==true)
- {
- LogerHelper.RecordLogTxt("Start ReadLot2Thread");
- ReadLot2Thread readLot2 = new ReadLot2Thread();
- readLot2.ReadThreadStart();
- }
- if (config.GetValue<bool>("SendLot2Lot3Thread") == true)
- {
- LogerHelper.RecordLogTxt("Start SendLot2Lot3Thread");
- SendLot2Lot3Thread sendLot2Lot3 = new SendLot2Lot3Thread();
- sendLot2Lot3.SendThreadStart();
- }
- if (config.GetValue<bool>("SendColourCastThread") == true)
- {
- LogerHelper.RecordLogTxt("Start SendColourCastThread");
- SendColourCastThread sendcolourcast = new SendColourCastThread();
- sendcolourcast.SendThreadStart();
- }
- if (config.GetValue<bool>("DeleteDBRecordThread") == true)
- {
- LogerHelper.RecordLogTxt("Start DeleteDBRecordThread");
- DeleteDBRecordThread deleterecord = new DeleteDBRecordThread(config.GetValue<int>("DaysAgo"));
- deleterecord.DeleteThreadStart();
- }
- return app => next(app);
- }
- }
- }
|