增加摄像头列表增、改、删的本地化存储支持
This commit is contained in:
@@ -44,7 +44,7 @@ public class Program
|
||||
|
||||
// 核心设备管理器
|
||||
// 注意:暂时保持无参构造,后续我们在改造 CameraManager 时再注入 storageService
|
||||
using var cameraManager = new CameraManager();
|
||||
using var cameraManager = new CameraManager(storageService);
|
||||
|
||||
// 动态窗口管理器
|
||||
var displayManager = new DisplayWindowManager();
|
||||
@@ -60,13 +60,17 @@ public class Program
|
||||
// ==============================================================================
|
||||
// 4. 业务编排
|
||||
// ==============================================================================
|
||||
|
||||
// 【关键修复 1】先 StartAsync,让它先从文件把 999 号设备读进内存
|
||||
await cameraManager.StartAsync();
|
||||
|
||||
// 【关键修复 2】文件加载完后,再决定要不要加默认设备
|
||||
await ConfigureBusinessLogic(cameraManager);
|
||||
|
||||
// ==============================================================================
|
||||
// 5. 启动引擎与交互
|
||||
// ==============================================================================
|
||||
Console.WriteLine("\n[系统] 正在启动全局管理引擎...");
|
||||
await cameraManager.StartAsync();
|
||||
|
||||
Console.WriteLine($">> 系统就绪。Web 管理地址: http://localhost:{port}");
|
||||
Console.WriteLine($">> 数据存储路径: App_Data/Process_{processId}/");
|
||||
@@ -112,9 +116,9 @@ public class Program
|
||||
});
|
||||
});
|
||||
|
||||
// 2. 日志降噪
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Warning);
|
||||
builder.Logging.AddFilter("Microsoft.AspNetCore.Hosting.Diagnostics", LogLevel.Warning);
|
||||
//// 2. 日志降噪
|
||||
//builder.Logging.SetMinimumLevel(LogLevel.Warning);
|
||||
//builder.Logging.AddFilter("Microsoft.AspNetCore.Hosting.Diagnostics", LogLevel.Warning);
|
||||
|
||||
// 3. 【核心】依赖注入注册
|
||||
// 将 storageService 注册为单例,这样 UserActionFilter 和 MonitorController 就能拿到它了
|
||||
@@ -157,29 +161,35 @@ public class Program
|
||||
|
||||
static async Task ConfigureBusinessLogic(CameraManager manager)
|
||||
{
|
||||
// 1. 添加测试设备
|
||||
var config = new VideoSourceConfig
|
||||
try
|
||||
{
|
||||
Id = 101,
|
||||
Brand = DeviceBrand.HikVision,
|
||||
IpAddress = "192.168.5.9",
|
||||
Port = 8000,
|
||||
Username = "admin",
|
||||
Password = "RRYFOA",
|
||||
StreamType = 0
|
||||
};
|
||||
manager.AddDevice(config);
|
||||
// 1. 添加测试设备
|
||||
var config = new VideoSourceConfig
|
||||
{
|
||||
Id = 101,
|
||||
Brand = DeviceBrand.HikVision,
|
||||
IpAddress = "192.168.5.9",
|
||||
Port = 8000,
|
||||
Username = "admin",
|
||||
Password = "RRYFOA",
|
||||
StreamType = 0
|
||||
};
|
||||
manager.AddDevice(config);
|
||||
|
||||
var config2 = new VideoSourceConfig
|
||||
var config2 = new VideoSourceConfig
|
||||
{
|
||||
Id = 102,
|
||||
Brand = DeviceBrand.HikVision,
|
||||
IpAddress = "172.16.41.20",
|
||||
Port = 8000,
|
||||
Username = "admin",
|
||||
Password = "abcd1234",
|
||||
StreamType = 0
|
||||
};
|
||||
manager.AddDevice(config2);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Id = 102,
|
||||
Brand = DeviceBrand.HikVision,
|
||||
IpAddress = "172.16.41.20",
|
||||
Port = 8000,
|
||||
Username = "admin",
|
||||
Password = "abcd1234",
|
||||
StreamType = 0
|
||||
};
|
||||
manager.AddDevice(config2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user