using EC.Entity.Video; using ECMonitor.Code.DB; using System.Collections.Generic; namespace ECMonitor.Code { public class CameraManager { public static List CameraList = new List(); public static List LoadData() { var msVideoRecorderList = DBDataHelper.LoadCameraData(); ///添加测试 //msVideoRecorderList.Add(TestMsVideoRecorder()); CameraList.Clear(); foreach (MsVideoRecorder msVideoRecorder in msVideoRecorderList) { CameraList.AddRange(msVideoRecorder.MsCameraSettingList); } return msVideoRecorderList; } public static MsVideoRecorder TestMsVideoRecorder() { MsVideoRecorder msVideoRecorder = new MsVideoRecorder(); msVideoRecorder.MsCameraSettingList.Add(new MonitorCamera("192.168.1.108", 37777, "admin", "hk123456", 2)); msVideoRecorder.MsCameraSettingList.Add(new MonitorCamera("192.168.1.65", 80000, "admin", "hk123456", 5)); msVideoRecorder.MsCameraSettingList.Add(new MonitorCamera("120.198.209.123", 80000, "admin", "hk123456", 5)); msVideoRecorder.MsCameraSettingList.Add(new MonitorCamera("218.204.221.100", 80000, "admin", "hk123456", 5)); msVideoRecorder.MsCameraSettingList.Add(new MonitorCamera("120.236.237.23", 80000, "admin", "hk123456", 5)); return msVideoRecorder; } public static void Add(MonitorCamera camera) { CameraList.Add(camera); } public static MonitorCamera GetCamera(string cameraIp) { if (string.IsNullOrEmpty(cameraIp)) { return null; } if (CameraList.Count == 0) { LoadData(); } var tempCamera = CameraList.Find(c => c.Ip == cameraIp); if (tempCamera == null)//获取 新更新 的相机 { LoadData(); tempCamera = CameraList.Find(c => c.Ip == cameraIp); } return tempCamera; } } }