From 8b9ce384b26c414db32f98e94e088f5334869c2d Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 13 十一月 2019 15:36:28 +0800
Subject: [PATCH] 全部合并了代码,安卓和 IOS 都测试通过了

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs |  108 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 86 insertions(+), 22 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
index 4a2710a..052ba53 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using System.Text;
 using System.Threading.Tasks;
-using Java.Util;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using Shared;
@@ -36,14 +35,16 @@
         public string currentUserDisplayMethod = string.Empty;//褰撳墠鐢ㄦ埛鏄剧ず鏂瑰紡
         //鏈湴鎵�鏈夎处鎴峰垪琛�
         public List<Shared.Phone.UserCenter.MemberInfoRes> localAllAccountList = new List<Shared.Phone.UserCenter.MemberInfoRes> { };
-        public static int RemoteUnlockCount = 5;//杩滅▼寮�閿佹鏁伴檺鍒�
-        public static string RemoteUnlockPassword = string.Empty;//杩滅▼寮�閿佸瘑鐮�
-        public static DateTime maxValue = DateTime.MaxValue;
-        public static DateTime minValue = DateTime.MinValue;
         public string LocalTempPassword = string.Empty;//鏈湴鐢熸垚鐨勪复鏃跺瘑鐮�
         public Dictionary<string, bool> IsFreezeAccount = new Dictionary<string, bool> { };//鏄惁鍐荤粨瀛愯处鎴�
         public Dictionary<string, bool> HasRemoteUnlockAccess = new Dictionary<string, bool> { };//鏄惁缁欏瓙璐︽埛鎷ユ湁杩滅▼寮�閿佺殑鏉′欢
         public Dictionary<string, bool> IsFailedToGetDoorLockInfo = new Dictionary<string, bool> { };//鏄惁鑾峰彇闂ㄩ攣鏁版嵁澶辫触
+        public string RemoteUnlockPassword = string.Empty;//杩滅▼寮�閿佸瘑鐮�
+
+        public static int RemoteUnlockCount = 5;//杩滅▼寮�閿佹鏁伴檺鍒�
+        public static DateTime maxValue = DateTime.MaxValue;
+        public static DateTime minValue = DateTime.MinValue;
+
         #region 涓存椂瀵嗙爜淇℃伅
         /// <summary>
         /// 鐢ㄦ埛绠$悊鍙戦�佹暟鎹洖澶�
@@ -217,6 +218,7 @@
             public string PrimaryId = "";
             /// <summary>
             /// 闂ㄩ攣Id -->閿悕 : DoorLockId (鍙��)
+            /// DelDoorLockDelType 闂ㄩ攣鍒犻櫎绫诲瀷(0: 鏍规闂ㄩ攣涓婚敭(浜戠涓婚敭)鍒犻櫎(鍗曟潯鍒犻櫎)銆�1:鏍规闂ㄩ攣Id鎵归噺鍒犻櫎(鍑℃槸涓庨棬閿両d鐩稿悓閮戒細鍒犻櫎)銆�2锛氭牴妞愰棬閿両d鍙婇棬閿佹湰鍦扮敤鎴稩d鎵归噺鍒犻櫎(杩欎釜闂ㄩ攣Id杩欎釜闂ㄩ攣鏈湴鐢ㄦ埛Id鍧囦細琚垹闄�)) -->閿悕 : DelDoorLockDelType 榛樿鍊�: 0
             /// </summary>
             public int DelDoorLockDelType;
         }
@@ -675,7 +677,7 @@
             ///涓嶅父鐢細
             /// 1:RF(Zigbee鏃犵嚎)锛�2:Manual(鎵嬪姩)锛�255:Indeterminate(涓嶇‘瀹�)
             /// </summary>
-            public int OperationEventSource;
+            public int OperationEventSoure;
             /// <summary>
             /// 浜嬩欢鐮�
             /// 甯哥敤锛�
@@ -1463,12 +1465,12 @@
         ///杩滅▼寮�閿�
         ///<para>inputPassword: 杈撳叆瀵嗙爜/para>
         /// </summary>
-        public async System.Threading.Tasks.Task<TempPasswordResponseAllData> RemoteControlAsync(string inputPassword)
+        public async System.Threading.Tasks.Task<RemoteResponseAllData> RemoteControlAsync(string inputPassword)
         {
-            TempPasswordResponseAllData result = null;
+            RemoteResponseAllData result = null;
             if (Gateway == null)
             {
-                result = new TempPasswordResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+                result = new RemoteResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
                 return result;
             }
             return await System.Threading.Tasks.Task.Run(async () =>
@@ -1485,22 +1487,33 @@
 
                         if (temp == null)
                         {
-                            result = new TempPasswordResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+                            result = new RemoteResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
                         }
 
                         else
                         {
-                            result = new TempPasswordResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+                            result = new RemoteResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
                         }
                     }
-                    if (topic == gatewayID + "/" + "ZbDataPassthrough")
+                    else if (topic == $"{gatewayID}/DoorLock/DoorLockOperatingEventNotificationCommand")
+                    {
+                        var OperatingEventNotificationDatad = Newtonsoft.Json.JsonConvert.DeserializeObject<ZigBee.Device.DoorLock.DoorLockOperatingEventNotificationCommand>(jobject["Data"].ToString());
+                        if (OperatingEventNotificationDatad != null)
+                        {
+                            if (OperatingEventNotificationDatad.OperationEventSoure == 1 && OperatingEventNotificationDatad.OperationEventCode == 5)
+                            {
+                                result = new RemoteResponseAllData { IsPawDispear = true };
+                            }
+                        }
+                    }
+                    else if (topic == gatewayID + "/" + "ZbDataPassthrough")
                     {
                         var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
                         gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
 
                         if (gatewayTemp.clientDataPassthroughResponseData == null)
                         {
-                            result = new TempPasswordResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+                            result = new RemoteResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
                         }
                         else
                         {
@@ -1512,10 +1525,10 @@
                                     var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
                                     if (command == "0002")
                                     {
-                                        var tempD = new TempPasswordResponseData();
+                                        var tempD = new RemoteResponseData();
                                         tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
                                         tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
-                                        result = new TempPasswordResponseAllData { responseData = tempD };
+                                        result = new RemoteResponseAllData { responseData = tempD };
                                         DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0462_{ topic}");
                                     }
                                 }
@@ -1523,7 +1536,6 @@
                         }
                     }
                 };
-
                 Gateway.Actions += action;
                 DebugPrintLog("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
 
@@ -1539,18 +1551,25 @@
                 catch { }
 
                 var dateTime = DateTime.Now;
-                while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
+                while ((DateTime.Now - dateTime).TotalMilliseconds < 5000)// WaitReceiveDataTime)
                 {
                     await System.Threading.Tasks.Task.Delay(10);
-                    if (result != null && result.responseData != null && result.responseData.command == "0462")
+                    if (result == null)
+                    {
+                        continue;
+                    }
+                    if (result.responseData != null && result.responseData.command == "0462")
+                    {
+                        break;
+                    }
+                    if (result.IsPawDispear == true)
                     {
                         break;
                     }
                 }
                 if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
                 {
-                    result = new TempPasswordResponseAllData
-                    { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+                    result = new RemoteResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
                 }
                 Gateway.Actions -= action;
                 DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
@@ -1585,6 +1604,51 @@
             catch { };
 
             return data;
+        }
+
+        /// <summary>
+        ///  杩滅▼鍥炲鏁版嵁
+        /// </summary>
+        public RemoteResponseAllData remoteResponseAllData;
+        [System.Serializable]
+        public class RemoteResponseAllData
+        {
+            /// <summary>
+            /// 閿欒淇℃伅
+            /// </summary> 
+            public string errorMessageBase;
+            /// <summary>
+            /// 缃戝叧淇℃伅閿欒鍙嶉
+            /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+            /// </summary>
+            public ErrorResponData errorResponData;
+            /// <summary>
+            /// 涓存椂瀵嗙爜鍥炲鏁版嵁
+            /// </summary>
+            public RemoteResponseData responseData;
+            /// <summary>
+            /// 鏄惁瀵嗙爜琚垹闄�
+            /// </summary>
+            public bool IsPawDispear = false;
+        }
+
+        /// <summary>
+        /// 鐢ㄦ埛绠$悊鏁版嵁鍥炲
+        /// </summary>
+        [System.Serializable]
+        public class RemoteResponseData
+        {
+            /// <summary>
+            ///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛�
+            /// </summary>
+            public string command = "";
+            /// <summary>
+            /// 鐘舵�佸��
+            /// <para>榛樿鍝嶅簲缁撴灉锛�
+            ///<para>0 鎴愬姛</para>
+            ///<para>1 澶辫触</para> 
+            /// </summary>
+            public int status = -1;
         }
         #endregion
 
@@ -1735,13 +1799,13 @@
         /// <summary>
         /// 涓存椂瀵嗙爜鍥炲鏁版嵁
         /// </summary>
-        public TempPasswordResponseAllData keyColorDataResponseAllData;
+        public TempPasswordResponseAllData tempPasswordResponseAllData;
         [System.Serializable]
         public class TempPasswordResponseAllData
         {
             /// <summary>
             /// 閿欒淇℃伅
-            /// </summary>
+            /// </summary> 
             public string errorMessageBase;
             /// <summary>
             /// 缃戝叧淇℃伅閿欒鍙嶉

--
Gitblit v1.8.0