From 8407d6631ac8f5b65c4a14fa27babaa48026d4ca Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 30 三月 2023 16:13:40 +0800 Subject: [PATCH] Merge branch 'wjc' into Dev-Branch --- HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideDoorLockSend.cs | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 237 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideDoorLockSend.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideDoorLockSend.cs new file mode 100644 index 0000000..021f52d --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideDoorLockSend.cs @@ -0,0 +1,237 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Threading; +using HDL_ON.DAL.Server; +using HDL_ON.Entity; +using Shared; +using static HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod; + + +namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock +{ + /// <summary> + /// 钀ょ煶瑙嗛闂ㄩ攣鏁版嵁鍙戦�� + /// </summary> + public class VideDoorLockSend + { + + private static VideDoorLockSend send = null; + /// <summary> + /// 鑾峰彇褰撳墠鐨勫璞� + /// </summary> + public static VideDoorLockSend Current + { + get + { + if (send == null) + { + send = new VideDoorLockSend(); + } + + return send; + } + } + /// <summary> + /// 瑙g粦璁惧(钀ょ煶瑙嗛闂ㄩ攣) + /// </summary> + /// <param name="function">褰撳墠鐨勮澶�</param> + /// <param name="action">鍥炶皟缁撴灉</param> + /// <param name="tipType">鏄惁闇�瑕佹彁绀�,榛樿鎻愮ず</param> + public void DelDevice(Function function, Action<bool> action, TipType tipType = TipType.flicker) + { + new Thread(() => + { + try + { + 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, tipType)) + { + return; + } + + if (function != null) + { + action?.Invoke(true); + } + } + catch (Exception s) + { + } + }) + { IsBackground = true }.Start(); + + } + /// <summary> + /// 鑾峰彇闂ㄩ攣鐘舵��(钀ょ煶瑙嗛闂ㄩ攣) + /// </summary> + /// <param name="function">褰撳墠鐨勮澶�</param> + /// <param name="tipType">鏄惁闇�瑕佹彁绀�,榛樿鎻愮ず</param> + /// <param name="return">杩斿洖缁撴灉涓嶄細涓簄ull</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,tipType)) + { + return new VideoDoorLockInfo(); + } + + var videoDoorLockInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<VideoDoorLockInfo>(responsePackNew.Data.ToString()); + if (videoDoorLockInfo == null) + { + return new VideoDoorLockInfo(); + } + return videoDoorLockInfo; + + + + } + /// <summary> + /// 鑾峰彇鐢垫睜鐢甸噺(钀ょ煶瑙嗛闂ㄩ攣) + /// </summary> + /// <param name="function">褰撳墠鐨勮澶�</param> + /// <param name="tipType">鏄惁闇�瑕佹彁绀�,榛樿鎻愮ず</param> + /// <param name="return">杩斿洖缁撴灉涓嶄細涓簄ull</param> + public CellInfo GetCellValue(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_Details, "鑾峰彇钀ょ煶闂ㄩ攣璁惧鐢甸噺"); + if (!this.DataChecking(responsePackNew,tipType)) + { + return new CellInfo(); + } + var cellInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<CellInfo>(responsePackNew.Data.ToString()); + if (cellInfo == null) + { + return new CellInfo(); + } + + return cellInfo; + + } + /// <summary> + /// 鑾峰彇闂ㄩ攣鐢ㄦ埛鍒楄〃(钀ょ煶瑙嗛闂ㄩ攣) + /// </summary> + /// <param name="function">褰撳墠鐨勮澶�</param> + /// <param name="tipType">鏄惁闇�瑕佹彁绀�,榛樿鎻愮ず</param> + /// <param name="return">杩斿洖缁撴灉涓嶄細涓簄ull</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, tipType)) + { + return new List<UserVideoDoorLockInfo>(); + } + var list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UserVideoDoorLockInfo>>(responsePackNew.Data.ToString()); + if (list == null) + { + return new List<UserVideoDoorLockInfo>(); + } + return list; + } + /// <summary> + /// 鑾峰彇闂ㄩ攣璁惧鍒楄〃(钀ょ煶瑙嗛闂ㄩ攣) + /// </summary> + /// <param name="spk">鎸囧畾spk鑾峰彇</param> + /// <param name="tipType">鏄惁闇�瑕佹彁绀�,榛樿鎻愮ず</param> + /// <returns>杩斿洖缁撴灉涓嶄細涓簄ull</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_GetDevcieList, "鑾峰彇钀ょ煶闂ㄩ攣璁惧鍒楄〃"); + if (!this.DataChecking(responsePackNew, tipType)) + { + return new List<Function>(); + } + var doorLockList = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLockList>(responsePackNew.Data.ToString()); + if (doorLockList == null) + { + return new DoorLockList().list; + } + return doorLockList.list; + } + + /// <summary> + /// 鑾峰彇闂ㄩ攣鍨嬪彿鍒楄〃(钀ょ煶瑙嗛闂ㄩ攣) + /// </summary> + /// <param name="tipType">鏄惁闇�瑕佹彁绀�,榛樿鎻愮ず</param> + /// <returns>杩斿洖缁撴灉涓嶄細涓簄ull</returns> + public List<string> 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 List<string>(); + } + var lockModels = Newtonsoft.Json.JsonConvert.DeserializeObject<LockModels>(responsePackNew.Data.ToString()); + if (lockModels == null) + { + return new LockModels().lockModels; + } + return lockModels.lockModels; + } + + /// <summary> + /// 鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken + /// </summary> + /// <param name="tipType">鏄惁闇�瑕佹彁绀�,榛樿鎻愮ず</param> + public string GetEZGetChildToken(TipType tipType = TipType.flicker) + { + //鍏堣幏鍙栬悿鐭充簯瀛愯处鍙穞oken + 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> + /// <returns></returns> + private bool DataChecking(ResponsePackNew responsePackNew, TipType tipType) + { + if (responsePackNew.Data == null || responsePackNew.Code != "0" || responsePackNew.Data.ToString() == "") + { + if (TipType.flicker == tipType) + { + if (responsePackNew == null) + { + responsePackNew = new ResponsePackNew { message = "娌″洖澶�,璇风‘璁ょ綉缁滄槸鍚︽甯�.", Code = "-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; + } + return true; + } + + + } +} -- Gitblit v1.8.0