|
@@ -53,4 +53,24 @@ namespace EInk.Lot2Lot3
|
|
|
}
|
|
|
|
|
|
|
|
|
+ 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>("DeleteDBRecordhread") == "on")
|
|
|
+ {
|
|
|
+ deleterecord.DeleteThreadStart();
|
|
|
+ }
|
|
|
+ return app => next(app);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|