| | |
| | | /// </summary> |
| | | /// <param name="function">当前的设备</param> |
| | | /// <param name="action">回调结果</param> |
| | | public void DelDevice(Function function, Action<bool> action) |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | public void DelDevice(Function function, Action<bool> action, TipType tipType = TipType.flicker) |
| | | { |
| | | new Thread(() => |
| | | { |
| | |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceSerial", function.sid);//等同门锁序列号 |
| | | d.Add("platform", 1);//平台 |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_DeleteDevice, "删除萤石门锁设备"); |
| | | if (!this.DataChecking(responsePackNew)) |
| | | d.Add("platform", 1);//平台 |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_DeleteDevice, "删除萤石门锁设备"); |
| | | if (!this.DataChecking(responsePackNew, tipType)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | if (function != null) |
| | | { |
| | | action?.Invoke(false); |
| | | action?.Invoke(true); |
| | | } |
| | | } |
| | | catch (Exception s) |
| | |
| | | /// 获取门锁状态(萤石视频门锁) |
| | | /// </summary> |
| | | /// <param name="function">当前的设备</param> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <param name="return">返回结果不会为null</param> |
| | | public VideoDoorLockInfo GetVideoDoorLockState(Function function, TipType tipType = TipType.flicker) |
| | | { |
| | |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceId", function.deviceId); |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_Lockstatus, "删除萤石视频门锁状态"); |
| | | if (!this.DataChecking(responsePackNew)) |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_Lockstatus, "获取萤石视频门锁状态"); |
| | | if (!this.DataChecking(responsePackNew,tipType)) |
| | | { |
| | | return new VideoDoorLockInfo(); |
| | | } |
| | |
| | | /// 获取电池电量(萤石视频门锁) |
| | | /// </summary> |
| | | /// <param name="function">当前的设备</param> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <param name="return">返回结果不会为null</param> |
| | | public CellInfo GetCellValue(Function function, TipType tipType = TipType.flicker) |
| | | { |
| | |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceId", function.deviceId); |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_Details, "获取萤石门锁设备电量"); |
| | | if (!this.DataChecking(responsePackNew)) |
| | | if (!this.DataChecking(responsePackNew,tipType)) |
| | | { |
| | | return new CellInfo(); |
| | | } |
| | |
| | | /// 获取门锁用户列表(萤石视频门锁) |
| | | /// </summary> |
| | | /// <param name="function">当前的设备</param> |
| | | /// /// <param name="return">返回结果不会为null</param> |
| | | public List<UserInfo> GetVideoDoorLockUserListInfo(Function function, TipType tipType = TipType.flicker) |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <param name="return">返回结果不会为null</param> |
| | | public List<UserVideoDoorLockInfo> GetVideoDoorLockUserListInfo(Function function, TipType tipType = TipType.flicker) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("deviceId", function.deviceId); |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_UserList, "获取萤石门锁用户列表"); |
| | | if (!this.DataChecking(responsePackNew)) |
| | | if (!this.DataChecking(responsePackNew, tipType)) |
| | | { |
| | | return new List<UserInfo>(); |
| | | return new List<UserVideoDoorLockInfo>(); |
| | | } |
| | | var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UserInfo>>(responsePackNew.Data.ToString()); |
| | | var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UserVideoDoorLockInfo>>(responsePackNew.Data.ToString()); |
| | | if (list == null) |
| | | { |
| | | return new List<UserInfo>(); |
| | | return new List<UserVideoDoorLockInfo>(); |
| | | } |
| | | return list; |
| | | } |
| | |
| | | /// 获取门锁设备列表(萤石视频门锁) |
| | | /// </summary> |
| | | /// <param name="spk">指定spk获取</param> |
| | | /// <returns></returns> |
| | | public List<Function> GetVideoDoorLockDeviceList(string spk) |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <returns>返回结果不会为null</returns> |
| | | public List<Function> GetVideoDoorLockDeviceList(string spk, TipType tipType = TipType.flicker) |
| | | { |
| | | |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id); |
| | | d.Add("spk", spk); |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_UserList, "获取萤石门锁设备列表"); |
| | | if (!this.DataChecking(responsePackNew)) |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_GetDevcieList, "获取萤石门锁设备列表"); |
| | | if (!this.DataChecking(responsePackNew, tipType)) |
| | | { |
| | | return new List<Function>(); |
| | | } |
| | | var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Function>>(responsePackNew.Data.ToString()); |
| | | if (list == null) |
| | | var doorLockList = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLockList>(responsePackNew.Data.ToString()); |
| | | if (doorLockList == null) |
| | | { |
| | | return new List<Function>(); |
| | | return new DoorLockList().list; |
| | | } |
| | | return list; |
| | | return doorLockList.list; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取门锁型号列表(萤石视频门锁) |
| | | /// </summary> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <returns>返回结果不会为null</returns> |
| | | public LockModels GetVideoDoorLockLockModelsList(TipType tipType = TipType.flicker) |
| | | { |
| | | var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(new object { }, NewAPI.Api_Post_Lock_Models, "获取萤石门锁型号列表"); |
| | | if (!this.DataChecking(responsePackNew, tipType)) |
| | | { |
| | | return new LockModels(); |
| | | } |
| | | var lockModels = Newtonsoft.Json.JsonConvert.DeserializeObject<LockModels>(responsePackNew.Data.ToString()); |
| | | if (lockModels == null) |
| | | { |
| | | return new LockModels(); |
| | | } |
| | | return lockModels; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 先获取萤石云子账号token |
| | | /// </summary> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | public string GetEZGetChildToken(TipType tipType = TipType.flicker) |
| | | { |
| | | //先获取萤石云子账号token |
| | | var responsePackNew = new HttpServerRequest().EZGetChildToken(); |
| | | if (!this.DataChecking(responsePackNew, tipType)) |
| | | { |
| | | return ""; |
| | | } |
| | | return responsePackNew.Data.ToString(); |
| | | } |
| | | /// <summary> |
| | | /// 检验数据回复成功或者失败 |
| | | /// </summary> |
| | | /// <param name="responsePackNew">回复数据对象</param> |
| | | /// <param name="tipType">是否需要提示,默认提示</param> |
| | | /// <param name="tipType">是否需要提示</param> |
| | | /// <returns></returns> |
| | | private bool DataChecking(ResponsePackNew responsePackNew, TipType tipType = TipType.flicker) |
| | | private bool DataChecking(ResponsePackNew responsePackNew, TipType tipType) |
| | | { |
| | | if (responsePackNew.Data == null || responsePackNew.Code != "0" || responsePackNew.Data.ToString() == "") |
| | | { |
| | |
| | | if (responsePackNew == null) |
| | | { |
| | | responsePackNew = new ResponsePackNew { message = "没回复,请确认网络是否正常.", Code = "-1", }; |
| | | |
| | | } |
| | | //new Tip() |
| | | //{ |
| | | // CloseTime = 1, |
| | | // Text = responsePackNew.message + "(" + responsePackNew.Code + ")", |
| | | // Direction = AMPopTipDirection.None, |
| | | //}.Show(MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1)); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //new Tip() |
| | | //{ |
| | | // CloseTime = 1, |
| | | // Text = responsePackNew.message + "(" + responsePackNew.Code + ")", |
| | | // Direction = AMPopTipDirection.None, |
| | | //}.Show(MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1)); |
| | | CommonMethod.Current.ShowTip(responsePackNew.message + "(" + responsePackNew.Code + ")"); |
| | | }); |
| | | } |
| | | return false; |
| | | } |