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.

107 lines
2.7 KiB

3 years ago

using EC.Entity.PublicModel;
using EC.Entity.Video;
using EC.Entity.Warning;
using EC.Utils;
using EC.Utils.ZMQ;
using NetMQ;
using NetMQ.Sockets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ECMonitor.Code.DB
{
public class DBDataHelper
{
//public static string _apiUrl = ConfigHelper.APIServer();
public static string _dbSvrServer = ConfigHelper.DBSvrServer();
public static ZMQRequestHelper requestHelper=null;
public static ZMQRequestHelper RequestContext() {
if (requestHelper == null)
{
requestHelper = new ZMQRequestHelper(_dbSvrServer);
}
return requestHelper;
}
/// <summary>
/// 获取相机数据
/// </summary>
/// <returns></returns>
public static List<MsVideoRecorder> LoadCameraData()
{
List<MsVideoRecorder> msVideoRecorderList = new List<MsVideoRecorder>();
try
{
RequestModel requestModel = new RequestModel();
requestModel.method = DBMethod.GetGroupAndCameraList;
requestModel.jsonstr = "all";
ResultModel resultModel = RequestContext().RequestFromServer(requestModel);
if (resultModel.result == DBMethod.Success)
{
msVideoRecorderList = resultModel.jsonstr.ToObject<List<MsVideoRecorder>>();
}
}
catch (Exception ex)
{
LogFactory.GetLogger().Error(ex);
}
return msVideoRecorderList;
}
/// <summary>
/// 保存预警划线
/// </summary>
/// <param name="drawShapeModelList"></param>
internal static bool SaveDrawShape(List<DrawShape> drawShapeModelList)
{
RequestModel requestModel = new RequestModel();
requestModel.method = DBMethod.SaveDrawShape;
requestModel.jsonstr = drawShapeModelList.ToJson();
LogFactory.GetLogger().Debug(requestModel.jsonstr);
ResultModel resultModel =RequestContext().RequestFromServer(requestModel);
if (resultModel.result == DBMethod.Success)
{
return true;
}else
{
return false;
}
}
internal static List<DrawShape> GetDrawShape(string ip)
{
List<DrawShape> drawShapeModelList = new List<DrawShape>();
try
{
RequestModel requestModel = new RequestModel();
requestModel.method = DBMethod.GetDrawShape;
requestModel.jsonstr = ip;
LogFactory.GetLogger().Debug(requestModel.jsonstr);
ResultModel resultModel = RequestContext().RequestFromServer(requestModel);
if (resultModel.result == DBMethod.Success)
{
drawShapeModelList = Json.ToObject<List<DrawShape>>(resultModel.jsonstr);
}
}catch(Exception ex)
{
LogFactory.GetLogger().Debug(ex);
}
return drawShapeModelList;
}
}
}