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 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); }