From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 28 二月 2020 15:25:13 +0800
Subject: [PATCH] 2020.2.28

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs |  166 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 155 insertions(+), 11 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
old mode 100755
new mode 100644
index 052ba53..4379054
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/DoorLock.cs
@@ -42,6 +42,7 @@
         public string RemoteUnlockPassword = string.Empty;//杩滅▼寮�閿佸瘑鐮�
 
         public static int RemoteUnlockCount = 5;//杩滅▼寮�閿佹鏁伴檺鍒�
+        public static int failedCount = 3;//杩滅▼寮�閿佸け璐ユ鏁�
         public static DateTime maxValue = DateTime.MaxValue;
         public static DateTime minValue = DateTime.MinValue;
 
@@ -491,6 +492,25 @@
             /// 浜戠甯愬彿Id -->閿悕 : CloudAccountId (鍙��)
             /// </summary>
             public string CloudAccountId = "";
+            /// <summary>
+            /// 绗嚑椤�
+            /// </summary>
+            public PageSetting pageSetting = new PageSetting();
+        }
+
+        /// <summary>
+        ///  鑾峰彇闂ㄩ攣
+        /// </summary>
+        public class PageSetting
+        {
+            /// <summary>
+            /// 绗嚑椤�
+            /// </summary>
+            public int Page = 1;
+            /// <summary>
+            /// 绗嚑椤�
+            /// </summary>
+            public int PageSize = 10;
         }
 
         [Serializable]
@@ -632,12 +652,12 @@
         {
             DoorLockAccountList.Clear();
             return await System.Threading.Tasks.Task.Run((Func<System.Threading.Tasks.Task<List<Shared.Phone.UserCenter.MemberInfoRes>>>)(async () =>
-           {
-               var pra = new Shared.Phone.UserCenter.MemberListInfoPra();
-               string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
-               var listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Shared.Phone.UserCenter.MemberInfoRes>>(result);
-               return listInfo;
-           }));
+            {
+                var pra = new Shared.Phone.UserCenter.MemberListInfoPra();
+                string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
+                var listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Shared.Phone.UserCenter.MemberInfoRes>>(result);
+                return listInfo;
+            }));
         }
 
         /// <summary>
@@ -1132,7 +1152,7 @@
                             result = new DefaultControlResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
                         }
                         else
-                        {
+                        {
                             if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
                             {
                                 var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
@@ -1183,6 +1203,109 @@
 
                 return result;
             });
+        }
+
+        /// <summary>
+        /// 鐢ㄦ埛绠$悊鍙戦�佹暟鎹�
+        /// userIdList:涓暟涓嶈兘瓒呰繃10涓�
+        /// </summary>
+        public string FreezeAccountData(List<int> userIdList, AccessType accessType)
+        {
+            string data = "";
+            string dataLength = "";
+            string dataComand1 = "50";
+            string dataComand2 = "04";
+            string dataSerialNum = "01";
+            string addDataLength = "";
+            string delUserTypeStr = "";
+            string userIdStr = "";
+            try
+            {
+                if (userIdList.Count == 0)
+                {
+                    return null;
+                }
+                if (userIdList.Count > 9)
+                {
+                    return null;
+                }
+                var tempLength = 5 + userIdList.Count * 2;
+                string tempLength1 = Convert.ToString(tempLength, 16);
+                switch (tempLength1.Length)
+                {
+                    case 1:
+                        dataLength = "0" + tempLength1.ToUpper();
+                        break;
+                    case 2:
+                        dataLength = tempLength1.ToUpper();
+                        break;
+                }
+
+                var tempAddDataLength = 1 + userIdList.Count * 2;
+                string tempAddDataLength1 = Convert.ToString(tempAddDataLength, 16);
+                switch (tempAddDataLength1.Length)
+                {
+                    case 1:
+                        addDataLength = "0" + tempAddDataLength1.ToUpper();
+                        break;
+                    case 2:
+                        addDataLength = tempAddDataLength1.ToUpper();
+                        break;
+                }
+
+                switch ((int)accessType)
+                {
+                    case 0:
+                        delUserTypeStr = "00";
+                        break;
+                    case 1:
+                        delUserTypeStr = "01";
+                        break;
+                    case 2:
+                        delUserTypeStr = "20";
+                        break;
+                    case 3:
+                        delUserTypeStr = "21";
+                        break;
+                    case 4:
+                        delUserTypeStr = "10";
+                        break;
+                    case 5:
+                        delUserTypeStr = "30";
+                        break;
+                    case 6:
+                        delUserTypeStr = "31";
+                        break;
+                }
+
+                var sbString = new System.Text.StringBuilder();
+                foreach (var userId in userIdList)
+                {
+                    string temp = Convert.ToString(userId, 16);
+                    switch (temp.Length)
+                    {
+                        case 1:
+                            userIdStr = "0" + temp + "00";
+                            break;
+                        case 2:
+                            userIdStr = temp + "00";
+                            break;
+                        case 3:
+                            var thirdBit = temp.Substring(temp.Length - 2, 1);
+                            userIdStr = temp + "0" + thirdBit;
+                            break;
+                        case 4:
+                            userIdStr = temp;
+                            break;
+                    }
+                    sbString.Append(userIdStr.ToString().ToUpper());
+                }
+                data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+                   delUserTypeStr + sbString;
+            }
+            catch { };
+
+            return data;
         }
 
         /// <summary>
@@ -1292,7 +1415,7 @@
         public enum AccessType
         {
             /// <summary>
-            /// 0x00 鍒犻櫎鍏ㄩ儴鍗曟鐢ㄦ埛
+            /// 0x00 鍒犻櫎鍏ㄩ儴涓存椂鐢ㄦ埛
             /// </summary>
             DelAllUsers = 0,
             /// <summary>
@@ -1307,6 +1430,18 @@
             /// 0x21 瑙e喕鎸囧畾鐢ㄦ埛
             /// </summary>
             Enable = 3,
+            /// <summary>
+            /// 0x10 澶氫釜鎸囧畾鐢ㄦ埛鍒犻櫎
+            /// </summary>
+            DelMoreUsers = 4,
+            /// <summary>
+            /// 0x30 澶氫釜鎸囧畾鐢ㄦ埛鍐荤粨
+            /// </summary>
+            DisEnableMoreUsers = 5,
+            /// <summary>
+            /// 0x31 澶氫釜鎸囧畾鐢ㄦ埛瑙e喕
+            /// </summary>
+            EnableMoreUsers = 6,
         }
         #endregion
 
@@ -2081,6 +2216,8 @@
                                     doorLockUserDetailData.userType = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
                                     doorLockUserDetailData.totalNum = Convert.ToInt32(data[12].ToString() + data[13].ToString(), 16);
                                     doorLockUserDetailData.currentNum = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
+                                    totalNum = doorLockUserDetailData.totalNum;
+                                    currentNum = doorLockUserDetailData.currentNum;
                                     result = new DoorlockUserInfo { doorLockUserDetailData = doorLockUserDetailData };
                                     DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0451_{ topic}");
                                 }
@@ -2099,15 +2236,22 @@
                     var data = new JObject { { "PassData", passData } };
                     jObject.Add("Data", data);
                     Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
-
                 }
                 catch { }
 
-                //鎺ユ敹涓�涓寘鏈�澶氱瓑3绉掞紝娌℃湁鏀跺埌灏遍��鍑�
+                //鎺ユ敹涓�涓寘鏈�澶氱瓑3绉掞紝娌℃湁鏀跺埌灏遍��鍑�,鍗曟鏁版嵁鍖呬笉瓒呰繃30涓敤鎴�
                 while ((DateTime.Now - dateTime).TotalMilliseconds < 3000)
                 {
                     await System.Threading.Tasks.Task.Delay(100);
+                    if (totalNum == currentNum)
+                    {
+                        break;
+                    }
                 }
+                //if ((DateTime.Now - dateTime).TotalMilliseconds > 3000)
+                //{
+                //    result = new DoorlockUserInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+                //}
                 Gateway.Actions -= action;
                 DebugPrintLog("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
 
@@ -2198,4 +2342,4 @@
 
         #endregion
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.8.0