|
@@ -3,23 +3,26 @@ using Microsoft.AspNetCore.Builder;
|
|
|
using SqlSugar;
|
|
|
using EInk.Models;
|
|
|
using EInk.Tools;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
|
|
|
namespace EInk.Lot2Lot3
|
|
|
{
|
|
|
|
|
|
- public class ReadLot2Filter : IStartupFilter
|
|
|
+ public class TaskFilter : IStartupFilter
|
|
|
{
|
|
|
+ private static IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
|
|
|
+
|
|
|
private readonly ISqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
|
|
|
{
|
|
|
DbType = DbType.PostgreSQL,
|
|
|
- ConnectionString = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("TargetDbConnectionString"),
|
|
|
+ ConnectionString = config.GetValue<string>("TargetDbConnectionString"),
|
|
|
IsAutoCloseConnection = true
|
|
|
});
|
|
|
|
|
|
private readonly ISqlSugarClient _local_db = new SqlSugarClient(new ConnectionConfig()
|
|
|
{
|
|
|
DbType = DbType.PostgreSQL,
|
|
|
- ConnectionString = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("LocalDbConnectionString"),
|
|
|
+ ConnectionString = config.GetValue<string>("LocalDbConnectionString"),
|
|
|
IsAutoCloseConnection = true
|
|
|
});
|
|
|
|
|
@@ -29,58 +32,31 @@ namespace EInk.Lot2Lot3
|
|
|
_local_db.CodeFirst.InitTables(typeof(DefectModel));
|
|
|
_local_db.CodeFirst.InitTables(typeof(Lot2Lot3Model));
|
|
|
_local_db.CodeFirst.InitTables(typeof(ColourCastModel));
|
|
|
- ReadLot2Thread readLot2 = new ReadLot2Thread(_db, _local_db);
|
|
|
- if (new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("ReadLot2Thread") =="on")
|
|
|
+
|
|
|
+ if (config.GetValue<bool>("ReadLot2Thread") ==true)
|
|
|
{
|
|
|
+ ReadLot2Thread readLot2 = new ReadLot2Thread(_db, _local_db);
|
|
|
readLot2.ReadThreadStart();
|
|
|
}
|
|
|
- return app => next(app);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public class SendDataFilter : IStartupFilter
|
|
|
- {
|
|
|
- private readonly ISqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
|
|
|
- {
|
|
|
- DbType = DbType.PostgreSQL,
|
|
|
- ConnectionString = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("LocalDbConnectionString"),
|
|
|
- IsAutoCloseConnection = true
|
|
|
- });
|
|
|
|
|
|
- public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
|
|
|
- {
|
|
|
- SendLot2Lot3Thread sendLot2Lot3 = new SendLot2Lot3Thread(_db);
|
|
|
- if (new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("SendLot2Lot3Thread") == "on")
|
|
|
+ if (config.GetValue<bool>("SendLot2Lot3Thread") == true)
|
|
|
{
|
|
|
+ SendLot2Lot3Thread sendLot2Lot3 = new SendLot2Lot3Thread(_db);
|
|
|
sendLot2Lot3.SendThreadStart();
|
|
|
}
|
|
|
|
|
|
- SendColourCastThread sendcolourcast = new SendColourCastThread(_db);
|
|
|
- if (new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("SendColourCastThread") == "on")
|
|
|
+ if (config.GetValue<bool>("SendColourCastThread") == true)
|
|
|
{
|
|
|
+ SendColourCastThread sendcolourcast = new SendColourCastThread(_db);
|
|
|
sendcolourcast.SendThreadStart();
|
|
|
}
|
|
|
- return app => next(app);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public class DeleteDBRecordFilter : IStartupFilter
|
|
|
- {
|
|
|
- private readonly ISqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
|
|
|
- {
|
|
|
- DbType = DbType.PostgreSQL,
|
|
|
- ConnectionString = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("LocalDbConnectionString"),
|
|
|
- IsAutoCloseConnection = true
|
|
|
- });
|
|
|
|
|
|
- public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
|
|
|
- {
|
|
|
- DeleteDBRecordThread deleterecord = new DeleteDBRecordThread(_db);
|
|
|
- if (new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("DeleteDBRecordThread") == "on")
|
|
|
+ if (config.GetValue<bool>("DeleteDBRecordThread") == true)
|
|
|
{
|
|
|
+ DeleteDBRecordThread deleterecord = new DeleteDBRecordThread(_db, config.GetValue<int>("DaysAgo"));
|
|
|
deleterecord.DeleteThreadStart();
|
|
|
}
|
|
|
+
|
|
|
return app => next(app);
|
|
|
}
|
|
|
}
|