From 3272ca5b51e19f7f8a827b0f68400570a547fe60 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 28 四月 2020 15:02:44 +0800
Subject: [PATCH] 2020-04-28-1

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs |   93 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs
index 34330b4..90a72cc 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs
@@ -205,6 +205,87 @@
 
         #endregion
 
+        #region 鈻� 鎺ヨ繎鎰熷簲___________________________
+        /// <summary>
+        /// 鑾峰彇鎺ヨ繎鎰熷簲閰嶇疆锛坲i鍙帴杩戞劅搴�,浣跨敤杩斿洖鍊肩殑panelProximitySensorInfo锛�
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public async Task<Panel.PanelProximitySensorInfo> GetDeviceProximitySensorsSettion(CommonDevice device)
+        {
+            //鍊熺敤瀹冪殑鍑芥暟
+            var panel = new Panel();
+            panel.DeviceAddr = device.DeviceAddr;
+            panel.DeviceEpoint = device.DeviceEpoint;
+            panel.CurrentGateWayId = device.CurrentGateWayId;
+
+            var result = await panel.GetProximitySensorAsync();
+            panel = null;
+            //鍏遍�氶敊璇娴�
+            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+            if (error != null)
+            {
+                this.ShowErrorMsg(error);
+                return null;
+            }
+            if (result == null || result.panelProximitySensorInfo == null || string.IsNullOrEmpty(result.errorMessageBase) == false)
+            {
+                //鑾峰彇鎺ヨ繎鎰熷簲淇℃伅澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.GetPanelProximityFail);
+                this.ShowErrorMsg(msg);
+                return null;
+            }
+            return result.panelProximitySensorInfo;
+        }
+
+
+        /// <summary>
+        /// 閰嶇疆鎺ヨ繎浼犳劅
+        /// </summary>
+        /// <param name="device">璁惧瀵硅薄</param>
+        /// <para>sensorEnable:浼犳劅鍣ㄤ娇鑳�</para> 
+        /// <returns></returns>
+        public async Task<bool> SetProximitySensorStatus(CommonDevice device, bool sensorEnable)
+        {
+            //鍊熺敤瀹冪殑鍑芥暟
+            var panel = new Panel();
+            panel.DeviceAddr = device.DeviceAddr;
+            panel.DeviceEpoint = device.DeviceEpoint;
+            panel.CurrentGateWayId = device.CurrentGateWayId;
+
+            var result = await panel.SetProximitySensor(sensorEnable);
+            panel = null;
+
+            //鍏遍�氶敊璇娴�
+            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+            if (error != null)
+            {
+                this.ShowErrorMsg(error);
+                return false;
+            }
+
+            if (result == null || result.responseData == null)
+            {
+                //鎺ヨ繎浼犳劅閰嶇疆澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.SetPannelProximityFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+                this.ShowTipMsg(msg);
+                return false;
+            }
+
+            // 澶囦唤璁惧
+            var backData = new Newtonsoft.Json.Linq.JObject
+            {
+                { "sensorEnable",sensorEnable }
+            };
+            //澶囦唤璁惧
+            await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A闈㈡澘鎺ヨ繎鎰熷簲鍔熻兘, backData);
+            return true;
+        }
+        #endregion
+
         #region 鈻� 鑺傝兘妯″紡___________________________
         /// <summary>
         /// 鑾峰彇璁惧鑺傝兘妯″紡鐨勯厤缃姸鎬�(ui鍙妭鑳芥ā寮�)
@@ -479,12 +560,12 @@
         #region 鈻� 淇敼骞叉帴鐐圭鏈夊睘鎬________________
 
         /// <summary>
-        /// 淇敼骞叉帴鐐圭鏈夊睘鎬�
+        /// 淇敼骞叉帴鐐圭涓夌骇鍒殑绉佹湁灞炴��
         /// </summary>
         /// <param name="panel">骞叉帴鐐瑰璞�</param>
         /// <param name="i_value">骞叉帴鐐圭殑绗笁绾у埆灞炴�х殑鍊�,鍏蜂綋璇峰弬鐓х涓夌骇鍒睘鎬�</param>
         /// <returns></returns>
-        public async Task<bool> EditorDryContactFunction(Panel panel, int i_value)
+        public async Task<bool> EditorDryContactThirdFunction(Panel panel, int i_value)
         {
             var result = await panel.ConfigureHdlKeyValueAsync((Panel.KeyMode)i_value);
             //鍏遍�氶敊璇娴�
@@ -537,7 +618,7 @@
                 return false;
             }
             //澶囦唤璁惧
-            await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A骞叉帴鐐圭鏈夊睘鎬�, i_value);
+            await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A骞叉帴鐐圭涓夌骇鍒鏈夊睘鎬�, i_value);
 
             return true;
         }
@@ -707,7 +788,13 @@
                     errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "鍥炲瓒呮椂", false);
                 }
                 this.ShowTipMsg(errorMsg);
+                return false;
             }
+            //澶囦唤璁惧
+            HdlThreadLogic.Current.RunThread(async () =>
+            {
+                await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绠�绾﹂潰鏉块渿鍔ㄥ姛鑳�, datainfo);
+            }, ShowErrorMode.NO);
 
             return success;
         }

--
Gitblit v1.8.0