From cbc156bc38d8b8eae7aef60cb186ab2b52fa701f Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期二, 16 七月 2024 13:59:56 +0800
Subject: [PATCH] 增加全部挂断

---
 HDL_ON/DAL/Server/HttpServerRequest.cs |  373 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 366 insertions(+), 7 deletions(-)

diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs
index d07ef71..731c865 100644
--- a/HDL_ON/DAL/Server/HttpServerRequest.cs
+++ b/HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -161,7 +161,7 @@
         /// 鍒锋柊Token
         /// </summary>
         /// <returns></returns>
-        public string RefreshToken()
+        public string RefreshToken(bool canRefresh = true)
         {
             var requestJson = HttpUtil.GetSignRequestJson(new RefreshTokenObj()
             {
@@ -187,6 +187,17 @@
             {
                 UserInfo.Current.LastTime = DateTime.MinValue;
             }
+#if __IOS__
+            else if (revertObj.Code == "10001")
+            {
+                if (canRefresh)
+                {
+                    UserInfo.Current.RefreshToken = SiriKit.NSUserDefaultsHelper.DataSuite.StringForKey(SiriKit.NSUserDefaultsHelper.StorageKeys.GLOBAL_GRefreshToken);
+                    //UserInfo.Current.AccessToken = SiriKit.NSUserDefaultsHelper.DataSuite.StringForKey(SiriKit.NSUserDefaultsHelper.StorageKeys.GLOBAL_GAccessToken);
+                    RefreshToken(false);
+                }
+            }
+#endif
             return revertObj.Code;
         }
 
@@ -698,8 +709,8 @@
                         {
                             if (mHomeGatewayRes.Count > 0)
                             {
-                                DB_ResidenceData.Instance.HomeGateway = mHomeGatewayRes[0];
-                                DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes[0].gatewayStatus;
+                                DB_ResidenceData.Instance.HomeGateway = mHomeGatewayRes[0];//缃戝叧鐘舵��
+                                HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes[0].gatewayStatus;
                                 DB_ResidenceData.Instance.SaveResidenceData();
                                 return revertObj.Code;
                             }
@@ -765,7 +776,7 @@
                 var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<HomeGatewayInfo>(revertObj.Data.ToString());
                 if (mHomeGatewayRes != null)
                 {
-                    DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes.gatewayStatus;
+                    HDL_ON.DriverLayer.Control.Ins.GatewayOnline_Cloud = mHomeGatewayRes.gatewayStatus;
                 }
             }
             return revertObj.Code;
@@ -1527,7 +1538,7 @@
         }
 #endregion
 
-#region 鑾峰彇澶╂皵閮ㄥ垎
+        #region 鑾峰彇澶╂皵閮ㄥ垎
         /// <summary>
         /// 鑾峰彇鎸囧畾缁忕含搴︾殑鍩庡競淇℃伅澶╂皵淇℃伅
         /// </summary>
@@ -2288,7 +2299,7 @@
             d.Add("actions", actionObjs);
 
             var requestJson = HttpUtil.GetSignRequestJson(d);
-            MainPage.Log($"api鍔熻兘鎺у埗锛歿requestJson}");
+            MainPage.Log($"api鍙戦�佹帶鍒讹細{requestJson}");
             return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_ControlDevice, requestJson);
         }
         /// <summary>
@@ -2308,6 +2319,23 @@
             var requestJson = HttpUtil.GetSignRequestJson(d);
             return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDevice, requestJson);
         }
+
+        /// <summary>
+        /// 缂栬緫璁惧淇℃伅
+        /// 缁戝畾鍏崇郴銆佸悕绉般�佹敹钘�
+        /// </summary>
+        /// <returns></returns>
+        public ResponsePackNew UpdataDevcieName(string deviceId,string name)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("name", name);
+
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDevice, requestJson);
+        }
+
         /// <summary>
         /// 缂栬緫璁惧淇℃伅
         /// 缁戝畾鍏崇郴銆佸悕绉般�佹敹钘�
@@ -3117,6 +3145,338 @@
             return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_DelTempPasswrod, requestJson);
         }
 
+
+        #region 瑙嗛闂ㄩ攣  2023-07-07 16:47:20
+        /// <summary>
+        /// 鑾峰彇钀ょ煶闂ㄩ攣鐢ㄦ埛鍒楄〃
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <returns></returns>
+        public ResponsePackNew GetDoorlockUserList(string deviceId)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDoorlockUserList, requestJson);
+        }
+
+        /// <summary>
+        /// 淇敼闂ㄩ攣鐢ㄦ埛澶囨敞
+        /// </summary>
+        /// <returns></returns>
+        public ResponsePackNew EditDoorlockUserName(string deviceId,string lockUserIndex,string remarkName)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("lockUserIndex", lockUserIndex);
+            d.Add("remarkName", remarkName);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_setDoorUserRemark, requestJson);
+        }
+
+        /// <summary>
+        /// 鍒犻櫎闂ㄩ攣鐢ㄦ埛鏁板瓧瀵嗙爜
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="lockUserIndex"></param>
+        /// <returns></returns>
+        public ResponsePackNew DeleteDoorlockUserNumberPassword(string deviceId, string lockUserIndex)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("lockUserIndex", lockUserIndex);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_DeleteDoorlockUser_NumberPassword, requestJson);
+        }
+
+        /// <summary>
+        /// 鍒犻櫎闂ㄩ攣鐢ㄦ埛鍗″瘑鐮�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="lockUserIndex"></param>
+        /// <returns></returns>
+        public ResponsePackNew DeleteDoorlockUserCardPassword(string deviceId, string lockUserIndex)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("lockUserIndex", lockUserIndex);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_DeleteDoorlockUser_DeleteCardPassword, requestJson);
+        }
+
+        /// <summary>
+        /// 鍒犻櫎闂ㄩ攣鐢ㄦ埛鎸囩汗瀵嗙爜
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="lockUserIndex"></param>
+        /// <returns></returns>
+        public ResponsePackNew DeleteDoorlockUserFingerPassword(string deviceId, string lockUserIndex)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("lockUserIndex", lockUserIndex);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_DeleteDoorlockUser_DeleteFingerPassword, requestJson);
+        }
+
+        /// <summary>
+        /// 鍒犻櫎闂ㄩ攣鐢ㄦ埛浜鸿劯瀵嗙爜
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="lockUserIndex"></param>
+        /// <returns></returns>
+        public ResponsePackNew DeleteDoorlockUserFacePassword(string deviceId, string lockUserIndex)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("lockUserIndex", lockUserIndex);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_DeleteDoorlockUser_DeleteFacePassword, requestJson);
+        }
+
+
+        /// <summary>
+        /// 鍒犻櫎闂ㄩ攣鐢ㄦ埛
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="lockUserIndex"></param>
+        /// <returns></returns>
+        public ResponsePackNew DeleteDoorlockUser(string deviceId, string lockUserIndex)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("lockUserIndex", lockUserIndex);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_DeleteDoorlockUser_DeleteUser, requestJson);
+        }
+
+        /// <summary>
+        /// 鏌ヨ鎸夐敭涓ゆ寮�闂�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <returns></returns>
+        public ResponsePackNew GetDoubleClickOpenDoorSwitch(string deviceId)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDoubleClickOpenDoorSwitch, requestJson);
+        }
+        /// <summary>
+        /// 璁剧疆鎸夐敭涓ゆ寮�闂�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="enabled">鎸夐敭涓ゆ寮�闂ㄥ紑鍏� 0-鍏抽棴,1娆℃寜閿紑闂� 1-寮�鍚紝2娆℃寜閿紑闂�</param>
+        /// <returns></returns>
+        public ResponsePackNew SetDoubleClickOpenDoorSwitch(string deviceId,int enabled)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("enabled", enabled);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_SetDoubleClickOpenDoorSwitch, requestJson);
+        }
+
+        /// <summary>
+        /// 鏌ヨ绔ラ攣寮�鍏�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <returns></returns>
+        public ResponsePackNew GetChildLockSwitch(string deviceId)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetChildLockSwitch, requestJson);
+        }
+        /// <summary>
+        /// 璁剧疆绔ラ攣寮�鍏�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="enabled">绔ラ攣寮�鍏� 0-鍏抽棴 1-寮�鍚�</param>
+        /// <returns></returns>
+        public ResponsePackNew SetChildLockSwitch(string deviceId, int enabled)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("enabled", enabled);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_SetChildLockSwitch, requestJson);
+        }
+
+
+        /// <summary>
+        /// 鏌ヨ鍙嶉攣閰嶇疆
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <returns></returns>
+        public ResponsePackNew GetAntiLockCfg(string deviceId)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetAntiLockCfg, requestJson);
+        }
+        /// <summary>
+        /// 璁剧疆鍙嶉攣閰嶇疆
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="enabled"></param>
+        /// <returns></returns>
+        public ResponsePackNew SetAntiLockCfg(string deviceId, bool enabled)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("enabled", enabled);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_SetAntiLockCfg, requestJson);
+        }
+
+
+        /// <summary>
+        /// 鏌ヨ甯冩挙闃茬姸鎬�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <returns></returns>
+        public ResponsePackNew GetDefenceStatus(string deviceId)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDefenceStatus, requestJson);
+        }
+        /// <summary>
+        /// 璁剧疆甯冩挙闃茬姸鎬�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="armStatus">甯冮槻鐘舵�� disarmed-鎾ら槻 armed-宸插竷闃�</param>
+        /// <param name="defenceMode">甯冮槻妯″紡 global-鍏ㄥ眬 atHome-鍦ㄥ outDoor-澶栧嚭 sleep-鐫$湢</param>
+        /// <returns></returns>
+        public ResponsePackNew SetDefenceStatus(string deviceId, bool defance)//,string defenceMode)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            if(defance)
+                d.Add("armStatus", "armed");
+            else
+                d.Add("armStatus", "disarmed");
+            d.Add("defenceMode", "global");
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_SetDefenceStatus, requestJson);
+        }
+
+        /// <summary>
+        /// 鏌ヨ浜鸿劯寮�閿侀厤缃�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <returns></returns>
+        public ResponsePackNew GetFaceUnlockCfg(string deviceId)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetFaceRecognitionUnlockCfg, requestJson);
+        }
+        /// <summary>
+        /// 璁剧疆浜鸿劯寮�閿侀厤缃�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="enabled"></param>
+        /// <param name="mode">瑙i攣鏂瑰紡 0-鑷姩 1-鎵嬪姩</param>
+        /// <returns></returns>
+        public ResponsePackNew SetFaceUnlockCfg(string deviceId, bool enabled,int mode)
+        {
+            Dictionary<string, object> d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("enabled", enabled);
+            d.Add("mode", mode);//瑙i攣鏂瑰紡 0-鑷姩 1-鎵嬪姩
+            d.Add("sensitivity", 0);//鐏垫晱搴� 0-楂� 1-浣�
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_SetFaceRecognitionUnlockCfg, requestJson);
+        }
+
+        /// <summary>
+        /// 鏌ヨ闂ㄩ攣绯荤粺澹伴煶
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <returns></returns>
+        public ResponsePackNew GetDoorLockSystemSound(string deviceId)
+        {
+            var d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDoorLockSystemSound, requestJson);
+        }
+
+        /// <summary>
+        /// 璁剧疆闂ㄩ攣绯荤粺澹伴煶
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="sound"></param>
+        /// <returns></returns>
+        public ResponsePackNew SetDoorLockSystemSound(string deviceId,int sound)
+        {
+            var d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("sound", sound);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_SetDoorLockSystemSound, requestJson);
+        }
+
+        /// <summary>
+        /// 鏌ヨ闂ㄩ搩鎻愮ず闊�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <returns></returns>
+        public ResponsePackNew GetDoorBellTone(string deviceId)
+        {
+            var d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDoorBellTone, requestJson);
+        }
+
+        /// <summary>
+        /// 璁剧疆闂ㄩ搩鎻愮ず闊�
+        /// </summary>
+        /// <param name="deviceId"></param>
+        /// <param name="volume"></param>
+        /// <returns></returns>
+        public ResponsePackNew SetDoorBellTone(string deviceId, int volume)
+        {
+            var d = new Dictionary<string, object>();
+            d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+            d.Add("deviceId", deviceId);
+            d.Add("volume", volume);
+            var requestJson = HttpUtil.GetSignRequestJson(d);
+            return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_SetDoorBellTone, requestJson);
+        }
+
+
+
+
+        #endregion
+
         #endregion
 
         #region 鈻� 闊崇璇█鎺у埗鐩稿叧_________________________
@@ -3317,7 +3677,6 @@
             var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetGroupControlInfos, requestJson);
             return pack;
         }
-
         /// <summary>
         /// 鑾峰彇缇ゆ帶璇︽儏
         /// </summary>

--
Gitblit v1.8.0