软测单独项目
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.
 
 
 
 
 
 

750 lines
33 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// ZYCameraHandler 的摘要说明
/// </summary>
public class ZYCameraHandler : IHttpHandler
{
private FangYar.BLL.TBL_CAMERA bll = new FangYar.BLL.TBL_CAMERA();
public void ProcessRequest(HttpContext context)
{
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "摄像头操作请求", "");
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "List":
returnstr = List(context);
break;
case "Add":
returnstr = Add(context);
break;
case "Edit":
returnstr = Edit(context);
break;
case "Del":
returnstr = Del(context);
break;
case "GetGuardroomVideo":
returnstr = GetGuardroomVideo(context);
break;
case "AppGetList":
returnstr = AppGetList(context);
break;
case "AppGetModel":
returnstr = AppGetModel(context);
break;
case "getAccessToken":
returnstr = getAccessToken(context);
break;
case "getYunMouApi":
returnstr = getYunMouApi(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string List(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
string treeID = context.Request.Params["treeID"];
string keyword = context.Request.Params["keywords"];
//摄像机状态
string C_STATE = context.Request.Params["C_STATE"];
string type = context.Request.Params["type"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
string is_content = context.Request.Params["is_content"];//0不包含,1包含
//是否查询所有信息
string AllInfo = context.Request.Params["AllInfo"];
int pageIndex = 1;
int pageSize = 10;
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
string where = " find_in_set(org_id,cids) ";
string pOrgID = null;
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
{
pOrgID = treeID;
}
else
{
pOrgID = OrgId;
}
if (!string.IsNullOrEmpty(keyword))
{
where += " and ( C_NAME like '%" + keyword + "%' or INS_ADDR like '%" + keyword + "%')";
}
//判断是否查询全部数据
if (string.IsNullOrWhiteSpace(AllInfo))
{
where += " and LENGTH(PLAYURL)>0 ";
}
//判断是否查询摄像头状态
if (!string.IsNullOrWhiteSpace(C_STATE))
{
where += " and C_STATE ='" + C_STATE + "' ";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where, pOrgID, is_content);
//int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
List<FangYar.Model.TBL_CAMERA> list = bll.QueryList(pageIndex, pageSize, where, "", pOrgID, is_content);
//List<FangYar.Model.TBL_CAMERA> list = bll.QueryList(pageIndex, pageSize, where, "");
//string pic1 = Convert.ToBase64String((byte[])list[i].PICTURE);
//returnstr += FangYar.Common.JsonHelper.ToJson(list);
returnstr += "[";
for (int i = 0; i < list.Count; i++)
{
string pic1 = "";
if (list[i].PICTURE != null && list[i].PICTURE.ToString() != "")
{
pic1 = Convert.ToBase64String((byte[])list[i].PICTURE);
}
returnstr += "{\"ID\":\"" + list[i].ID + "\",\"C_NO\":\"" + list[i].C_NO + "\",\"C_NAME\":\"" + list[i].C_NAME + "\",\"C_IP\":\"" + list[i].C_IP + "\",\"NVR_ID\":\"" + list[i].NVR_ID + "\",\"NVR_IP\":\"" + list[i].NVR_IP + "\",\"NVR_PORT\":\"" + list[i].NVR_PORT + "\",\"NVR_USER\":\"" + list[i].NVR_USER + "\",";
returnstr += "\"NVR_PWD\":\"" + list[i].NVR_PWD + "\",\"NVR_CHANNEL\":\"" + list[i].NVR_CHANNEL + "\",\"C_FUN\":\"" + (string.IsNullOrEmpty(list[i].C_FUN) ? "" : list[i].C_FUN.Replace("\"", "\\\"")) + "\",\"C_TYPE\":\"" + list[i].C_TYPE + "\",\"C_FAC\":\"" + list[i].C_FAC + "\",\"C_MODEL\":\"" + list[i].C_MODEL + "\",\"C_TIME\":\"" + list[i].C_TIME + "\",";
returnstr += "\"C_STATE\":\"" + list[i].C_STATE + "\",\"INS_ADDR\":\"" + list[i].INS_ADDR + "\",\"ORG_ID\":\"" + list[i].ORG_ID + "\",\"ORG_NAME\":\"" + list[i].ORG_NAME + "\",\"STA_ID\":\"" + list[i].STA_ID + "\",\"STA_NAME\":\"" + list[i].STA_NAME + "\",\"CPY_AREA\":\"" + list[i].CPY_AREA + "\",";
returnstr += "\"C_USER\":\"" + list[i].C_USER + "\",\"C_PWD\":\"" + list[i].C_PWD + "\",\"C_POST\":\"" + list[i].C_POST + "\",\"PLAYURL\":\"" + list[i].PLAYURL + "\",\"STOPURL\":\"" + list[i].STOPURL + "\",\"LON\":\"" + list[i].LON + "\",\"LAT\":\"" + list[i].LAT + "\",";
returnstr += "\"HEI\":\"" + list[i].HEI + "\",\"PICTURE\":\"" + pic1 + "\",\"VIDEO_IMG_URL\":\"" + list[i].VIDEO_IMG_URL + "\",";
returnstr += "\"deviceSerial\":\"" + list[i].deviceSerial + "\",\"deviceModel\":\"" + list[i].deviceModel + "\",\"channelId\":\"" + list[i].channelId + "\",";
returnstr += "\"EXTEND1\":\"" + list[i].EXTEND1.ToString() + "\",\"EXTEND2\":\"" + list[i].EXTEND2 + "\",\"EXTEND3\":\"" + list[i].EXTEND3 + "\",\"EXTEND4\":\"" + list[i].EXTEND4.Replace("\"", "\\\"") + "\",\"C_GUARDROOM\":\"" + list[i].C_GUARDROOM + "\",\"yunmouUnit\":\"" + list[i].yunmouUnit + "\"}";
if (i != list.Count - 1)
{
returnstr += ",";
}
}
returnstr += "]";
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "查询异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "摄像头操作请求", "查询");
return returnstr;
}
//添加
private string Add(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string id = Guid.NewGuid().ToString("N");//摄像头表id
string c_no = context.Request.Params["c_no"];//设备编号
string c_name = context.Request.Params["c_name"];//设备名称
string c_ip = context.Request.Params["c_ip"]; //摄像机ip
string nvr_id = context.Request.Params["nvr_id"]; //连接nvr编号
string nvr_ip = context.Request.Params["nvr_ip"];//ip地址
string nvr_port = context.Request.Params["nvr_port"];//nvr控制端口
string nvr_user = context.Request.Params["nvr_user"];//nvr登录用户名
string nvr_pwd = context.Request.Params["nvr_pwd"];//nvr密码
string deviceSerial = context.Request.Params["deviceSerial"];//设备序列号
string channelId = context.Request.Params["channelId"];//通道号ID
string deviceModel = context.Request.Params["deviceModel"];//设备型号
string nvr_channel = context.Request.Params["nvr_channel"];//通道编号
string c_fun = context.Request.Params["c_fun"];//摄像机功能
string EXTEND3 = context.Request.Params["EXTEND3"];//摄像头唯一标识
string EXTEND4 = context.Request.Params["EXTEND4"];//摄像头功能ID字符串
string c_type = context.Request.Params["c_type"];//摄像机类型
string c_model = context.Request.Params["c_model"]; //摄像机型号
string c_time = context.Request.Params["c_time"]; //启用时间
string c_guardroom = context.Request.Params["c_guardroom"];//是否为监控室监控
string ins_addr = context.Request.Params["ins_addr"];//安装位置
string dept_id = context.Request.Params["dept_id"];//部门名称
string dept_name = context.Request.Params["dept_name"];//部门名称
string org_id = context.Request.Params["org_id"];//机构id
string org_name = context.Request.Params["org_name"];//机构名称
string sta_id = context.Request.Params["sta_id"];//消防站id
string sta_name = context.Request.Params["sta_name"];//消防站名称
string cpy_area = context.Request.Params["cpy_area"]; //行政区域
string c_user = context.Request.Params["c_user"]; //摄像头用户名
string c_pwd = context.Request.Params["c_pwd"];//摄像头密码
string c_post = context.Request.Params["c_post"];//摄像头端口号
string playurl = context.Request.Params["playurl"];//云播放地址
string stopurl = context.Request.Params["stopurl"];//云停放地址
string lon = context.Request.Params["lon"]; //经度
string lat = context.Request.Params["lat"];//纬度
string hei = context.Request.Params["hei"];//高程
string picture = context.Request.Params["picture"];//图片
string c_fac = context.Request.Params["c_fac"];//摄像机厂家
string VIDEO_IMG_URL = context.Request.Params["VIDEO_IMG_URL"] + "";//静态图片地址
string c_state = context.Request.Params["c_state"];//状态
string extend2 = context.Request.Params["extend2"];//排序
string yunmouUnit = context.Request.Params["yunmouUnit"];//1:公司1;2:公司2;云眸判断标志
string is_control = context.Request.Params["is_control"];//是否允许云台控制;0:否;1:是
string is_playback = context.Request.Params["is_playback"];//是否允许回放;0:否;1:是
//
FangYar.Model.TBL_CAMERA model = new Model.TBL_CAMERA();
model.ID = id;
model.C_NO = c_no;
model.C_NAME = c_name;
model.C_IP = c_ip;
model.NVR_ID = nvr_id;
model.NVR_IP = nvr_ip;
if (!string.IsNullOrEmpty(nvr_port))
{
model.NVR_PORT = Convert.ToDecimal(nvr_port);
}
model.VIDEO_IMG_URL = VIDEO_IMG_URL;
model.NVR_USER = nvr_user;
model.NVR_PWD = nvr_pwd;
if (!string.IsNullOrEmpty(nvr_channel))
{
model.NVR_CHANNEL = Convert.ToDecimal(nvr_channel);
}
model.deviceSerial = deviceSerial;
model.channelId = channelId;
model.deviceModel = deviceModel;
if (!string.IsNullOrEmpty(c_fun))
{
model.C_FUN = c_fun;
}
if (!string.IsNullOrEmpty(EXTEND3))
{
model.EXTEND3 = EXTEND3;
}
if (!string.IsNullOrEmpty(EXTEND4))
{
model.EXTEND4 = EXTEND4;
}
if (!string.IsNullOrEmpty(c_type))
{
model.C_TYPE = Convert.ToDecimal(c_type);
}
model.C_MODEL = c_model;
if (!string.IsNullOrEmpty(c_time))
{
model.C_TIME = Convert.ToDateTime(c_time);
}
model.C_GUARDROOM = c_guardroom;
model.INS_ADDR = ins_addr;
model.ORG_ID = org_id;
model.ORG_NAME = org_name;
if (!string.IsNullOrEmpty(dept_id))
{
model.ORG_ID = dept_id;
model.ORG_NAME = dept_name;
}
model.STA_ID = sta_id;
model.STA_NAME = sta_name;
model.CPY_AREA = cpy_area;
model.C_USER = c_user;
model.C_PWD = c_pwd;
if (!string.IsNullOrEmpty(c_post))
{
model.C_POST = Convert.ToDecimal(c_post);
}
model.PLAYURL = playurl;
model.STOPURL = stopurl;
model.LON = lon;
model.LAT = lat;
model.HEI = hei;
if (!string.IsNullOrEmpty(picture))
{
String p1 = picture.Substring(picture.IndexOf(',') + 1);
model.PICTURE = Convert.FromBase64String(p1);
}
model.C_FAC = c_fac;
if (!string.IsNullOrEmpty(c_state))
{
model.C_STATE = Convert.ToDecimal(c_state);
}
model.EXTEND2 = extend2;
model.yunmouUnit = yunmouUnit;
model.is_control = is_control;
model.is_playback = is_playback;
if (bll.Add(model))
{
msg = "添加成功!";
code = 1;
}
else { msg = "添加失败!"; }
}
catch (Exception e)
{
msg = "添加失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "添加异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "摄像头操作请求", "添加");
return returnstr;
}
//修改
private string Edit(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string id = context.Request.Params["id"];//摄像头表id
string c_no = context.Request.Params["c_no"];//设备编号
string c_name = context.Request.Params["c_name"];//设备名称
string c_ip = context.Request.Params["c_ip"]; //摄像机ip
string nvr_id = context.Request.Params["nvr_id"]; //连接nvr编号
string nvr_ip = context.Request.Params["nvr_port"];//ip地址
string nvr_port = context.Request.Params["nvr_port"];//nvr控制端口
string nvr_user = context.Request.Params["nvr_user"];//nvr登录用户名
string nvr_pwd = context.Request.Params["nvr_pwd"];//nvr密码
string deviceSerial = context.Request.Params["deviceSerial"];//设备序列号
string channelId = context.Request.Params["channelId"];//通道号ID
string deviceModel = context.Request.Params["deviceModel"];//设备型号
string nvr_channel = context.Request.Params["nvr_channel"];//nvr通道号
string c_fun = context.Request.Params["c_fun"];//摄像机功能
string EXTEND3 = context.Request.Params["EXTEND3"];//摄像头唯一标识
string EXTEND4 = context.Request.Params["EXTEND4"];//摄像头功能ID字符串
string c_type = context.Request.Params["c_type"];//摄像机类型
string c_model = context.Request.Params["c_model"]; //摄像机型号
string c_time = context.Request.Params["c_time"]; //启用时间
string c_guardroom = context.Request.Params["c_guardroom"];//是否为监控室监控
string ins_addr = context.Request.Params["ins_addr"];//安装位置
string dept_id = context.Request.Params["dept_id"];//部门名称
string dept_name = context.Request.Params["dept_name"];//部门名称
string org_id = context.Request.Params["org_id"];//机构id
string org_name = context.Request.Params["org_name"];//机构名称
string sta_id = context.Request.Params["sta_id"];//消防站id
string sta_name = context.Request.Params["sta_name"];//消防站名称
string cpy_area = context.Request.Params["cpy_area"]; //行政区域
string c_user = context.Request.Params["c_user"]; //摄像头用户名
string c_pwd = context.Request.Params["c_pwd"];//摄像头密码
string c_post = context.Request.Params["c_post"];//摄像头端口号
string playurl = context.Request.Params["playurl"];//云播放地址
string stopurl = context.Request.Params["stopurl"];//云停放地址
string lon = context.Request.Params["lon"]; //经度
string lat = context.Request.Params["lat"];//纬度
string hei = context.Request.Params["hei"];//高程
string picture = context.Request.Params["picture"];//图片
string VIDEO_IMG_URL = context.Request.Params["VIDEO_IMG_URL"] + "";//静态图片地址
string c_fac = context.Request.Params["c_fac"];//摄像机厂家
string c_state = context.Request.Params["c_state"]; //状态
string extend2 = context.Request.Params["extend2"];//排序
string yunmouUnit = context.Request.Params["yunmouUnit"];//1:公司1;2:公司2;云眸判断标志
string is_control = context.Request.Params["is_control"];//是否允许云台控制;0:否;1:是
string is_playback = context.Request.Params["is_playback"];//是否允许回放;0:否;1:是
//
FangYar.Model.TBL_CAMERA model = new Model.TBL_CAMERA();
model.ID = id;
model.C_NO = c_no;
model.C_NAME = c_name;
model.C_IP = c_ip;
model.NVR_ID = nvr_id;
model.VIDEO_IMG_URL = VIDEO_IMG_URL;
model.NVR_IP = nvr_ip;
if (!string.IsNullOrEmpty(nvr_port))
{
model.NVR_PORT = Convert.ToDecimal(nvr_port);
}
model.NVR_USER = nvr_user;
model.NVR_PWD = nvr_pwd;
if (!string.IsNullOrEmpty(nvr_channel))
{
model.NVR_CHANNEL = Convert.ToDecimal(nvr_channel);
}
model.deviceSerial = deviceSerial;
model.channelId = channelId;
model.deviceModel = deviceModel;
if (!string.IsNullOrEmpty(c_fun))
{
model.C_FUN = c_fun;
}
if (!string.IsNullOrEmpty(EXTEND3))
{
model.EXTEND3 = EXTEND3;
}
if (!string.IsNullOrEmpty(EXTEND4))
{
model.EXTEND4 = EXTEND4;
}
if (!string.IsNullOrEmpty(c_type))
{
model.C_TYPE = Convert.ToDecimal(c_type);
}
model.C_MODEL = c_model;
if (!string.IsNullOrEmpty(c_time))
{
model.C_TIME = Convert.ToDateTime(c_time);
}
model.C_GUARDROOM = c_guardroom;
model.INS_ADDR = ins_addr;
model.ORG_ID = org_id;
model.ORG_NAME = org_name;
if (!string.IsNullOrEmpty(dept_id))
{
model.ORG_ID = dept_id;
model.ORG_NAME = dept_name;
}
model.STA_ID = sta_id;
model.STA_NAME = sta_name;
model.CPY_AREA = cpy_area;
model.C_USER = c_user;
model.C_PWD = c_pwd;
if (!string.IsNullOrEmpty(c_post))
{
model.C_POST = Convert.ToDecimal(c_post);
}
model.PLAYURL = playurl;
model.STOPURL = stopurl;
model.LON = lon;
model.LAT = lat;
model.HEI = hei;
if (!string.IsNullOrEmpty(picture))
{
String p1 = picture.Substring(picture.IndexOf(',') + 1);
model.PICTURE = Convert.FromBase64String(p1);
}
model.C_FAC = c_fac;
if (!string.IsNullOrEmpty(c_state))
{
model.C_STATE = Convert.ToDecimal(c_state);
}
model.EXTEND2 = extend2;
model.yunmouUnit = yunmouUnit;
model.is_control = is_control;
model.is_playback = is_playback;
if (bll.Update(model))
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
catch (Exception e)
{
msg = "修改失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "修改异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "摄像头操作请求", "修改");
return returnstr;
}
//删除
private string Del(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string EmpList = context.Request.Params["cameraList"];
string[] EmpArray = EmpList.Split(',');
string EmpListString = "";
for (int i = 0; i < EmpArray.Length; i++)
{
if (i == 0)
{
EmpListString = "'" + EmpArray[i] + "'";
}
else
{
EmpListString += ",'" + EmpArray[i] + "'";
}
}
if (bll.DeleteList(EmpListString))
{
msg = "删除成功!";
code = 1;
}
else
{
msg = "删除失败!";
}
}
catch (Exception e)
{
msg = "删除失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "删除异常;" + e);
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "摄像头操作请求", "删除");
return returnstr;
}
//查询获取监控室视频
private string GetGuardroomVideo(HttpContext context)
{
string returnstr = "";
try
{
string ORG_ID = context.Request.Params["OrgId"];
string where = " ORG_ID ='" + ORG_ID + "' AND C_GUARDROOM = '1'";
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
DataTable dt = bll.GetList(where).Tables[0];
returnstr += "[";
for (int i = 0; i < dt.Rows.Count; i++)
{
if (i == 0)
{
returnstr += "{\"ID\":\"" + dt.Rows[i]["ID"].ToString() + "\",\"C_NAME\":\"" + dt.Rows[i]["C_NAME"].ToString() + "\",\"PLAYURL\":\"" + dt.Rows[i]["PLAYURL"].ToString() + "\"}";
}
else
{
returnstr += ",{\"ID\":\"" + dt.Rows[i]["ID"].ToString() + "\",\"C_NAME\":\"" + dt.Rows[i]["C_NAME"].ToString() + "\",\"PLAYURL\":\"" + dt.Rows[i]["PLAYURL"].ToString() + "\"}";
}
}
returnstr += "]";
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "查询获取监控室视频异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "摄像头操作请求", "查询获取监控室视频");
return returnstr;
}
//查询
private string AppGetList(HttpContext context)
{
string returnstr = "";
try
{
string ORG_ID = context.Request.Params["OrgId"];
string c_fun = context.Request.Params["c_fun"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
int pageIndex = 1;
int pageSize = 10;
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
string where = "1=1";
//where += " and (ORG_ID ='" + ORG_ID + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + ORG_ID + "') )";
where += " and ORG_ID ='" + ORG_ID + "'";
if (!string.IsNullOrEmpty(c_fun))
{
where += " and C_FUN='" + c_fun + "' ";
}
where += " order by (extend2) ";
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
string data = "[";
List<FangYar.Model.TBL_CAMERA> list = bll.QueryList(pageIndex, pageSize, where, "");
for (int i = 0; i < list.Count; i++)
{
string pic1 = "";
if (list[i].PICTURE != null && list[i].PICTURE.ToString() != "")
{
pic1 = Convert.ToBase64String((byte[])list[i].PICTURE);
}
data += "{\"ID\":\"" + list[i].ID + "\",\"NAME\":\"" + list[i].C_NAME.Replace("\0", "") + "\",\"ORG_ID\":\"" + list[i].ORG_ID + "\",\"ORG_NAME\":\"" + list[i].ORG_NAME + "\",\"PLAYURL\":\"" + list[i].PLAYURL + "\",";
data += "\"PICTURE\":\"" + pic1 + "\"}";
if (i != list.Count - 1)
{
data += ",";
}
}
returnstr += data + "]";
//returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "查询异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "摄像头操作请求", "查询");
return returnstr;
}
//查询
private string AppGetModel(HttpContext context)
{
string returnstr = "";
try
{
string id = context.Request.Params["id"];
returnstr = "{\"code\":0,\"msg\":\"\",";
returnstr += "\"count\": 1,\"data\":";
if (bll.Exists(id))
{
FangYar.Model.TBL_CAMERA model = bll.GetModel(id);
returnstr += FangYar.Common.JsonHelper.ToJson(model);
}
else
{
returnstr += "[]";
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "查询异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "摄像头操作请求", "查询");
return returnstr;
}
//获取云眸accessToken
private string getAccessToken(HttpContext context)
{
string returnstr = "";
try
{
string client_id = context.Request.Params["client_id"];
string client_secret = context.Request.Params["client_secret"];
string grant_type = context.Request.Params["grant_type"];
string paramStr = "client_id=" + client_id + "&client_secret=" + client_secret + "&grant_type=" + grant_type;
returnstr = FangYar.Common.WebCommonUtil.PostWebRequest("https://api2.hik-cloud.com/oauth/token", paramStr);
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "查询异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "摄像头操作请求", "查询");
return returnstr;
}
//调用云眸Api通用接口
private string getYunMouApi(HttpContext context)
{
string returnstr = "";
try
{
string postUrl = context.Request.Params["postUrl"];
string paramStr = context.Request.Params["paramStr"];
returnstr = FangYar.Common.WebCommonUtil.PostYunmouApi(postUrl, paramStr);
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "摄像头操作请求", "查询异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "摄像头操作请求", "查询");
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}