You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.8 KiB

3 years ago
using EC.Entity.Video;
using ECMonitor.Code.DB;
using System.Collections.Generic;
namespace ECMonitor.Code
{
public class CameraManager
{
public static List<MonitorCamera> CameraList = new List<MonitorCamera>();
public static List<MsVideoRecorder> 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;
}
}
}