using FangYar.Model; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; namespace FangYar.WebUI.ashx { /// /// ZYCameraHandler 的摘要说明 /// public class ZYCameraHandler : IHttpHandler { private FangYar.BLL.TBL_CAMERA bll = new FangYar.BLL.TBL_CAMERA(); public void ProcessRequest(HttpContext context) { 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; } context.Response.Write(returnstr); } //查询 private string List(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string OrgList = context.Request.Params["OrgList"]+""; string keyword = context.Request.Params["keywords"]; string treeID = context.Request.Params["treeID"]; 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包含 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 + "%')"; } 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 list = bll.QueryList(pageIndex, pageSize, where, "", pOrgID, is_content); //List 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 + "\","; returnstr += "\"EXTEND1\":\"" + list[i].EXTEND1.ToString() + "\",\"EXTEND2\":\"" + list[i].EXTEND2 + "\",\"EXTEND3\":\"" + list[i].EXTEND3 + "\",\"EXTEND4\":\"" + list[i].EXTEND4.Replace("\"", "\\\"") + "\",\"RTMPURL\":\"" + list[i].RTMPURL + "\",\"RTMPHDURL\":\"" + list[i].RTMPHDURL + "\",\"HLSURL\":\"" + list[i].HLSURL + "\",\"HLSHDURL\":\"" + list[i].HLSHDURL + "\"}"; if (i != list.Count - 1) { returnstr += ","; } } returnstr += "]"; } returnstr += "}"; } catch { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; } 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 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 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"];//状态 // 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); } 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); } if (bll.Add(model)) { msg = "添加成功!"; code = 1; } else { msg = "添加失败!"; } } catch (Exception e) { msg = "添加失败!"; } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; 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 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"]; //状态 // 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); } 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); } if (bll.Update(model)) { msg = "修改成功!"; code = 1; } else { msg = "修改失败!"; } } catch (Exception e) { msg = "修改失败!"; } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; 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 { msg = "删除失败!"; } returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}"; 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 += "[{\"ID\":\"" + dt.Rows[0]["ID"].ToString() + "\",\"C_NAME\":\"" + dt.Rows[0]["C_NAME"].ToString() + "\",\"PLAYURL\":\"" + dt.Rows[0]["PLAYURL"].ToString() + "\"}]"; } returnstr += "}"; } catch { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}"; } 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 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 { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; } 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 { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}"; } return returnstr; } public bool IsReusable { get { return false; } } //private FangYar.BLL.TBL_CAMERA bll = new FangYar.BLL.TBL_CAMERA(); //public void ProcessRequest(HttpContext context) //{ // 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 "AppGetList": // returnstr = AppGetList(context); // break; // case "AppGetModel": // returnstr = AppGetModel(context); // break; // } // context.Response.Write(returnstr); //} ////查询 //private string List(HttpContext context) //{ // string returnstr = ""; // try // { // string OrgId = context.Request.Params["OrgId"]; // string OrgList = context.Request.Params["OrgList"]; // string keyword = context.Request.Params["keywords"]; // string treeID = context.Request.Params["treeID"]; // string type = context.Request.Params["type"]; // 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"; // if (!string.IsNullOrEmpty(treeID) && treeID != OrgId) // { // if (type == "dept") // { // where += " and sta_id ='" + treeID + "' "; // } // else // { // where += " and ORG_ID = '" + treeID + "'"; // } // } // //if (!string.IsNullOrEmpty(OrgId)) // //{ // // where += " and ORG_ID = '" + OrgId + "'"; // //} // else // { // string[] OrgArray = OrgList.Split(','); // string OrgListString = ""; // for (int i = 0; i < OrgArray.Length; i++) // { // if (i == 0) // { // OrgListString = "'" + OrgArray[i] + "'"; // } // else // { // OrgListString += ",'" + OrgArray[i] + "'"; // } // } // where = " ORG_ID in (" + OrgListString + ") "; // } // if (!string.IsNullOrEmpty(keyword)) // { // if (where != null) // { // where += " and "; // } // where += "( C_NAME like '%" + keyword + "%' or INS_ADDR like '%" + keyword + "%')"; // } // returnstr = "{\"code\":0,\"msg\":\"\","; // int count = bll.GetRecordCount(where); // returnstr += "\"count\":" + count + ",\"data\":"; // if (count == 0) // { // returnstr += "[]"; // } // else // { // List 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\":\"" + list[i].C_FUN + "\",\"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 + "\","; // returnstr += "\"EXTEND1\":\"" + list[i].EXTEND1.ToString() + "\",\"EXTEND2\":\"" + list[i].EXTEND2 + "\",\"EXTEND3\":\"" + list[i].EXTEND3 + "\",\"EXTEND4\":\"" + list[i].EXTEND4 + "\",\"RTMPURL\":\"" + list[i].RTMPURL + "\",\"RTMPHDURL\":\"" + list[i].RTMPHDURL + "\",\"HLSURL\":\"" + list[i].HLSURL + "\",\"HLSHDURL\":\"" + list[i].HLSHDURL + "\"}"; // if (i != list.Count - 1) // { // returnstr += ","; // } // } // returnstr += "]"; // } // returnstr += "}"; // } // catch // { // returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; // } // return returnstr; //} ////添加 //private string Add(HttpContext context) //{ // string returnstr = ""; // int code = -1; // string msg = ""; // try // { // string id = Guid.NewGuid().ToString("N");//摄像头表id // string orgId = context.Request.Params["orgId"].Trim().ToString(); // string deviceNO = context.Request.Params["deviceNO"];//设备编号 // string deviceName = context.Request.Params["deviceName"];//设备名称 // string state = context.Request.Params["state"].Trim().ToString();//状态 // string address = context.Request.Params["address"];//安装位置 // string rtmpURL = context.Request.Params["rtmpURL"].Trim().ToString(); // string rtmpHDURL = context.Request.Params["rtmpHDURL"].Trim().ToString(); // string hlsURL = context.Request.Params["hlsURL"].Trim().ToString(); // string hlsHDRUL = context.Request.Params["hlsHDRUL"].Trim().ToString(); // string altitude = context.Request.Params["altitude"];//高程 // string lon = context.Request.Params["lon"]; //经度 // string lat = context.Request.Params["lat"];//纬度 // string picture = context.Request.Params["picture"];//图片 // string VIDEO_IMG_URL = context.Request.Params["VIDEO_IMG_URL"] + "";//静态图片地址 // string channel = context.Request.Params["channel"];//通道号 // string models = context.Request.Params["model"].Trim().ToString(); // string type = context.Request.Params["type"].Trim().ToString();//型号 // string usingTime = context.Request.Params["usingTime"]; //启用时间 // string isDefault = context.Request.Params["isDefault"].Trim().ToString(); // // // TBL_CAMERA model = new TBL_CAMERA(); // model.ID = id; // model.ORG_ID = orgId; // model.C_NO = deviceNO; // model.C_NAME = deviceName; // if (!String.IsNullOrWhiteSpace("state")) // { // model.C_STATE = decimal.Parse(state); // } // model.INS_ADDR = address; // model.RTMPURL = rtmpURL; // model.RTMPHDURL = rtmpHDURL; // model.HLSURL = hlsURL; // model.HLSHDURL = hlsHDRUL; // model.HEI = altitude; // model.LON = lon; // model.LAT = lat; // if (!String.IsNullOrWhiteSpace(picture)) // { // model.PICTURE = Convert.FromBase64String(picture.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "")); // } // if (!string.IsNullOrEmpty(channel)) // { // model.NVR_CHANNEL = Convert.ToDecimal(channel); // } // model.C_MODEL = models; // if (!String.IsNullOrEmpty(type)) // { // model.C_TYPE = decimal.Parse(type); // } // if (!string.IsNullOrEmpty(usingTime)) // { // model.C_TIME = Convert.ToDateTime(usingTime); // } // if (!String.IsNullOrWhiteSpace(isDefault)) // { // switch (isDefault) // { // case "0": // model.PLAYURL = rtmpURL; // break; // case "1": // model.PLAYURL = rtmpHDURL; // break; // case "2": // model.PLAYURL = hlsURL; // break; // case "3": // model.PLAYURL = hlsHDRUL; // break; // default: // model.PLAYURL = hlsURL; // break; // } // } // if (bll.Add(model)) // { // msg = "添加成功!"; // code = 1; // } // else { msg = "添加失败!"; } // } // catch (Exception e) // { // msg = "添加失败!"; // } // returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; // return returnstr; //} ////修改 //private string Edit(HttpContext context) //{ // string returnstr = string.Empty; // int code = -1; // string msg = string.Empty; // try // { // string id = context.Request.Params["id"];//摄像头表id // string orgId = context.Request.Params["orgId"].Trim().ToString(); // string deviceNO = context.Request.Params["deviceNO"];//设备编号 // string deviceName = context.Request.Params["deviceName"];//设备名称 // string state = context.Request.Params["state"].Trim().ToString();//状态 // string address = context.Request.Params["address"];//安装位置 // string rtmpURL = context.Request.Params["rtmpURL"].Trim().ToString(); // string rtmpHDURL = context.Request.Params["rtmpHDURL"].Trim().ToString(); // string hlsURL = context.Request.Params["hlsURL"].Trim().ToString(); // string hlsHDRUL = context.Request.Params["hlsHDRUL"].Trim().ToString(); // string altitude = context.Request.Params["altitude"];//高程 // string lon = context.Request.Params["lon"]; //经度 // string lat = context.Request.Params["lat"];//纬度 // string picture = context.Request.Params["picture"];//图片 // string VIDEO_IMG_URL = context.Request.Params["VIDEO_IMG_URL"] + "";//静态图片地址 // string channel = context.Request.Params["channel"];//通道号 // string models = context.Request.Params["model"].Trim().ToString();//型号 // string type = context.Request.Params["type"].Trim().ToString();//型号 // string usingTime = context.Request.Params["usingTime"]; //启用时间 // string isDefault = context.Request.Params["isDefault"].Trim().ToString(); // TBL_CAMERA model = new TBL_CAMERA(); // model.ID = id; // model.ORG_ID = orgId; // model.C_NO = deviceNO; // model.C_NAME = deviceName; // if (!String.IsNullOrWhiteSpace("state")) // { // model.C_STATE = decimal.Parse(state); // } // model.INS_ADDR = address; // model.RTMPURL = rtmpURL; // model.RTMPHDURL = rtmpHDURL; // model.HLSURL = hlsURL; // model.HLSHDURL = hlsHDRUL; // model.HEI = altitude; // model.LON = lon; // model.LAT = lat; // if (!String.IsNullOrWhiteSpace(picture)) // { // model.PICTURE = Convert.FromBase64String(picture.Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "")); // } // if (!string.IsNullOrEmpty(channel)) // { // model.NVR_CHANNEL = Convert.ToDecimal(channel); // } // model.C_MODEL = models; // if (!String.IsNullOrEmpty(type)) // { // model.C_TYPE = decimal.Parse(type); // } // if (!string.IsNullOrEmpty(usingTime)) // { // model.C_TIME = Convert.ToDateTime(usingTime); // } // if (!String.IsNullOrWhiteSpace(isDefault)) // { // switch (isDefault) // { // case "0": // model.PLAYURL = rtmpURL; // break; // case "1": // model.PLAYURL = rtmpHDURL; // break; // case "2": // model.PLAYURL = hlsURL; // break; // case "3": // model.PLAYURL = hlsHDRUL; // break; // default: // model.PLAYURL = hlsURL; // break; // } // } // if (bll.Update(model)) // { // msg = "修改成功!"; // code = 1; // } // else { msg = "修改失败!"; } // } // catch (Exception e) // { // msg = "修改失败!"; // } // returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; // 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 // { // msg = "删除失败!"; // } // returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}"; // 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 + "') )"; // if (!string.IsNullOrEmpty(c_fun)) // { // where += " and C_FUN='" + c_fun + "' "; // } // returnstr = "{\"code\":0,\"msg\":\"\","; // int count = bll.GetRecordCount(where); // returnstr += "\"count\":" + count + ",\"data\":"; // if (count == 0) // { // returnstr += "[]"; // } // else // { // string data = "["; // List 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 // { // returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; // } // 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 // { // returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; // } // return returnstr; //} //public bool IsReusable //{ // get // { // return false; // } //} } }