|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
class HostLifetime(
|
|
class HostLifetime(
|
|
HardwareFileLoader hardwareFileLoader,
|
|
HardwareFileLoader hardwareFileLoader,
|
|
|
|
+ HardwareDBLoader hardwareDBLoader,
|
|
ConfigFileLoader configFileLoader,
|
|
ConfigFileLoader configFileLoader,
|
|
AddressFileLoader addressFileLoader,
|
|
AddressFileLoader addressFileLoader,
|
|
HardWareMonitor hardWareMonitor,
|
|
HardWareMonitor hardWareMonitor,
|
|
@@ -22,8 +23,21 @@ class HostLifetime(
|
|
async Task IHostedService.StartAsync(CancellationToken cancellationToken)
|
|
async Task IHostedService.StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
log.Initialize("General");
|
|
log.Initialize("General");
|
|
|
|
+ //Connect to DataBase Server
|
|
|
|
+ ormCollections.MainORM = new SqlSugarCustom();
|
|
|
|
+ if (string.IsNullOrEmpty(basicInfo.DBConnectionString) ||
|
|
|
|
+ !ormCollections.MainORM.Initialize() ||
|
|
|
|
+ !ormCollections.MainORM.Open(basicInfo.DBConnectionString, DbType.PostgreSQL))
|
|
|
|
+ {
|
|
|
|
+ log.Fatal($"Connect DB Failed");
|
|
|
|
+ Environment.Exit(0);
|
|
|
|
+ }
|
|
|
|
|
|
- hardwareFileLoader.Load();
|
|
|
|
|
|
+ if (!hardwareDBLoader.Load())
|
|
|
|
+ {
|
|
|
|
+ hardwareFileLoader.Load();
|
|
|
|
+ hardwareDBLoader.Save();
|
|
|
|
+ }
|
|
configFileLoader.Load();
|
|
configFileLoader.Load();
|
|
addressFileLoader.Load();
|
|
addressFileLoader.Load();
|
|
addressFileLoader.LoadPLC();
|
|
addressFileLoader.LoadPLC();
|
|
@@ -47,15 +61,6 @@ class HostLifetime(
|
|
dataDispatcher.TryAddNotifier("RT", rtNotifer);
|
|
dataDispatcher.TryAddNotifier("RT", rtNotifer);
|
|
dataDispatcher.TryAddNotifier("Kanban", kanbanNotifier);
|
|
dataDispatcher.TryAddNotifier("Kanban", kanbanNotifier);
|
|
|
|
|
|
- //Connect to DataBase Server
|
|
|
|
- ormCollections.MainORM = new SqlSugarCustom();
|
|
|
|
- if (string.IsNullOrEmpty(basicInfo.DBConnectionString) ||
|
|
|
|
- !ormCollections.MainORM.Initialize() ||
|
|
|
|
- !ormCollections.MainORM.Open(basicInfo.DBConnectionString, DbType.PostgreSQL))
|
|
|
|
- {
|
|
|
|
- log.Fatal($"Connect DB Failed");
|
|
|
|
- Environment.Exit(0);
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
log.Info($"Start RT Server {basicInfo.RTServerAddress}:{basicInfo.RTServerPort} success");
|
|
log.Info($"Start RT Server {basicInfo.RTServerAddress}:{basicInfo.RTServerPort} success");
|