public ActionResult Remove(string ids, bool state, int Identification) { List <int> list = new List <int>(); VideoApiHelper api = new VideoApiHelper(); if (!string.IsNullOrEmpty(ids)) { var idArry = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in idArry) { int id = 0; Int32.TryParse(item, out id); if (id != 0) { string sn_number = _videoEquipmentContract.VideoEquipments.Where(x => x.Id == id) .Select(x => x.snNumber).FirstOrDefault(); if (!state) { if (Identification == 1) { try { string bind = api.bindDevice(sn_number, ""); dynamic json = JToken.Parse(bind) as dynamic; if (json.result.code == "0") { list.Add(id); } } catch (Exception e) { } } else if (Identification == 2) { list.Add(id); } } else { try { string bind = api.unBindDevice(sn_number); dynamic json = JToken.Parse(bind) as dynamic; if (json.result.code == "0") { list.Add(id); } } catch (Exception e) { } } } } } var res = _videoEquipmentContract.Remove(state, list.ToArray()); return(Json(res)); }
public string CheckIsOnline(string deviceId) { string isOnline = ""; VideoApiHelper api = new VideoApiHelper(); string result = api.deviceOnline(deviceId); try { dynamic json = JToken.Parse(result) as dynamic; if (json.result.code == "0") { string isOnlineDesc = json.result.data.onLine; if (isOnlineDesc == "0") { isOnline = "否"; } else if (isOnlineDesc == "1") { isOnline = "是"; } } } catch (Exception e) { } return(isOnline); }
public ActionResult ViewMonitor(string sn_Number, string loadtype) { VideoApiHelper api = new VideoApiHelper(); ViewBag.token = api.accessToken(); ViewBag.sn_Number = sn_Number; ViewBag.loadtype = loadtype; return(PartialView()); }
public string GetChannelPicUrl(string deviceId) { //bindDeviceInfo VideoApiHelper api = new VideoApiHelper(); string result = api.bindDeviceInfo(deviceId); string channelPicUrl = string.Empty; try { dynamic json = JToken.Parse(result) as dynamic; if (json.result.code == "0") { channelPicUrl = json.result.data.channels[0].channelPicUrl; } } catch (Exception e) { } return(channelPicUrl); }
public ActionResult CheckIsExistence(string snNUmber) { int count = _videoEquipmentContract.VideoEquipments.Where(x => x.snNumber == snNUmber && x.IsDeleted == false && x.IsEnabled == true).Count(); string msg = string.Empty; int Identification = 0; if (count == 0 && !string.IsNullOrEmpty(snNUmber)) { //检查设备是否已经绑定 VideoApiHelper api = new VideoApiHelper(); try { string checkDevice = api.checkDeviceBindOrNot(snNUmber); dynamic json = JToken.Parse(checkDevice) as dynamic; if (json.result.code == "0") { if (json.result.data.isBind == "True") { if (json.result.data.isMine == "True") { //设备绑定在当前帐号 Identification = 2; msg = "设备已绑定"; } else { Identification = 3; msg = "此设备不能使用,不是绑定在当前账户下的"; } } else { //设备未绑定 并且不在线 Identification = 1; msg = "当前设备不在线"; } } else { Identification = 4; msg = "检查当前设备是否绑定出现异常!"; } } catch (Exception e) { Identification = 4; msg = "出现异常!"; } } else { Identification = 0; msg = "设备已存在"; } var data = new { Identification = Identification, msg = msg }; return(Json(data)); }
public int CheckIsBind(int Id) { string snNUmber = _videoEquipmentContract.VideoEquipments.Where(x => x.Id == Id). Select(x => x.snNumber).FirstOrDefault(); VideoApiHelper api = new VideoApiHelper(); string msg = string.Empty; int Identification = 0; string json = api.checkDeviceBindOrNot(snNUmber); try { dynamic jsonM = JToken.Parse(json) as dynamic; if (jsonM.result.code == "0") { if (jsonM.result.data.isBind == "True") { if (jsonM.result.data.isMine == "True") { //设备绑定在当前帐号 Identification = 2; msg = "设备已绑定"; } else { Identification = 3; msg = "此设备不能使用,不是绑定在当前账户下的"; } } else { //设备未绑定 并且不在线 Identification = 1; string onLine = api.deviceOnline(snNUmber); dynamic onLineM = JToken.Parse(onLine) as dynamic; if (onLineM.result.code == "0") { if (onLineM.result.data.onLine == "1") { Identification = 1; } else { Identification = 5;//设备不在线 } } else { Identification = 4; } } } else { Identification = 4; msg = "检查当前设备是否绑定出现异常!"; } } catch (Exception e) { Identification = 4; msg = "检查当前设备是否绑定出现异常!"; } var data = new { Identification = Identification, msg = msg }; return(Identification); }