From 16604a593202f2f87adf71abd57d036fe7da3b52 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 18 十一月 2019 10:39:42 +0800
Subject: [PATCH] 同步了全部的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs |  228 +++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 157 insertions(+), 71 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs
index 766d806..98bb400 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs
@@ -187,9 +187,14 @@
         /// </summary>
         private async void InitLogListInfo()
         {
+            this.listView.RemoveAll();
+            listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3);
+
             //濡傛灉From>To鐨勬椂鍊欙紝涓嶉笩瀹�
             if (Convert.ToInt32(dateFromControl.dateValue) > Convert.ToInt32(dateToControl.dateValue))
             {
+                //寮�濮嬫椂闂村ぇ浜庣粨鏉熸椂闂�
+                this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uFromTimeIsOverToTime));
                 return;
             }
             //鎵撳紑杩涘害鏉�
@@ -213,13 +218,15 @@
             //鍏抽棴杩涘害鏉�
             this.CloseProgressBar();
 
-            this.listView.RemoveAll();
-            listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3);
-
+            var dic = new Dictionary<string, string>();
+            for (int i = 0; i < listMenberInfo.Count; i++)
+            {
+                dic.Add(listMenberInfo[i].SubAccountDistributedMark, string.IsNullOrEmpty(listMenberInfo[i].UserName) == false ? listMenberInfo[i].UserName : listMenberInfo[i].Account);
+            }
             for (int i = 0; i < historyLog.Count; i++)
             {
                 //娣诲姞璁板綍琛�
-                this.AddLogInfoRow(historyLog[i], i != historyLog.Count - 1);
+                this.AddLogInfoRow(historyLog[i], dic, i != historyLog.Count - 1);
             }
 
             if (listView.ChildrenCount == 0)
@@ -248,12 +255,6 @@
                 //鍙垵濮嬪寲涓�娆�
                 return true;
             }
-            var pra = new MemberListInfoPra();
-            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
-            if (result == null)
-            {
-                return false;
-            }
             listMenberInfo = new List<MemberInfoRes>();
             //鎶婅嚜宸变篃鍔犺繘鍘�
             var myInfo = new MemberInfoRes()
@@ -263,7 +264,18 @@
                 SubAccountDistributedMark = Common.Config.Instance.Guid
             };
             listMenberInfo.Add(myInfo);
+            if (UserCenterResourse.UserInfo.AuthorityNo == 3)
+            {
+                //鎴愬憳鍙兘鐪嬭嚜宸辩殑
+                return true;
+            }
 
+            var pra = new MemberListInfoPra();
+            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
+            if (result == null)
+            {
+                return false;
+            }
             List<MemberInfoRes> listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MemberInfoRes>>(result);
             var checkList = new List<string>();
             foreach (MemberInfoRes infoRes in listInfo)
@@ -278,37 +290,6 @@
             return true;
         }
 
-        /// <summary>
-        /// 鑾峰彇鍘嗗彶璁板綍
-        /// </summary>
-        /// <returns></returns>
-        private async Task<List<HistoryInfo>> GetHistoryLogInf()
-        {
-            //鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁�
-            var pra = this.GetDbInterfacePra();
-
-            int nowPage = 0;
-            var listLog = new List<HistoryInfo>();
-            while (true)
-            {
-                //璁块棶浜戠
-                var result = await UserCenterLogic.GetResponseDataByRequestHttps("App/GetDoorLockHistoryPager", false, pra);
-                if (result == null)
-                {
-                    return null;
-                }
-                var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetHistoryDataResult>(result);
-                if (dataInfo.HasNextPage == false)
-                {
-                    break;
-                }
-                //鑾峰彇涓嬩竴椤�
-                nowPage++;
-                pra.PageSetting.Page = nowPage;
-            }
-            return listLog;
-        }
-
         #endregion
 
         #region 鈻� 娣诲姞璁板綍琛宊________________________
@@ -317,25 +298,70 @@
         ///  娣诲姞璁板綍琛�
         /// </summary>
         /// <param name="historyInfo">鍘嗗彶璁板綍</param>
+        /// <param name="dicName">鍚嶅瓧</param>
         /// <param name="addLine">娣诲姞搴曠嚎</param>
-        private void AddLogInfoRow(HistoryInfo historyInfo, bool addLine = true)
+        private void AddLogInfoRow(HistoryInfo historyInfo, Dictionary<string, string> dicName, bool addLine = true)
         {
             var frameTable = new FrameRowControl(listView.rowSpace / 2);
             frameTable.UseClickStatu = false;
             this.listView.AddChidren(frameTable);
             //鍥炬爣
             var btnIcon = frameTable.AddLeftIcon();
-            btnIcon.UnSelectedImagePath = "Item/PswSettionSelected.png";
+            if (historyInfo.UnlockIsSuccess == true)
+            {
+                btnIcon.UnSelectedImagePath = "Item/UnLockSuccess.png";
+            }
+            else
+            {
+                btnIcon.UnSelectedImagePath = "Item/UnLockSuccess.png";
+            }
 
             //淇℃伅
-            var btnMsg = frameTable.AddLeftCaption("淇℃伅娴嬭瘯", 600, 60);
+            var btnMsg = frameTable.AddLeftCaption("", 600, 60);
             btnMsg.TextSize = 15;
             //杩欎釜鍧愭爣鏈夌偣鐗规畩
             btnMsg.Y = Application.GetRealHeight(12) + frameTable.chidrenYaxis;
             frameTable.AddChidren(btnMsg, ChidrenBindMode.NotBind);
+            if (historyInfo.UnlockIsSuccess == true)
+            {
+                if (historyInfo.OpenLockMode == 0)
+                {
+                    //瀵嗙爜寮�閿佹垚鍔�
+                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByPasswordSuccess;
+                }
+                else if (historyInfo.OpenLockMode == 3)
+                {
+                    //IC鍗″紑閿佹垚鍔�
+                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByICcardSuccess;
+                }
+                else if (historyInfo.OpenLockMode == 15)
+                {
+                    //鎸囩汗寮�閿佹垚鍔�
+                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByFingerPrintSuccess;
+                }
+            }
+            else
+            {
+                if (historyInfo.OpenLockMode == 0)
+                {
+                    //瀵嗙爜寮�閿佸け璐�
+                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByPasswordFail;
+                }
+                else if (historyInfo.OpenLockMode == 3)
+                {
+                    //IC鍗″紑閿佸け璐�
+                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByICcardFail;
+                }
+                else if (historyInfo.OpenLockMode == 15)
+                {
+                    //鎸囩汗寮�閿佸け璐�
+                    btnMsg.TextID = R.MyInternationalizationString.uUnlockByFingerPrintFail;
+                }
+            }
 
             //浜虹墿
-            var btnpersion = frameTable.AddLeftCaption("浜虹墿娴嬭瘯", 600, 50, true);
+            string perName = dicName.ContainsKey(historyInfo.CloudAccountId) == true ? dicName[historyInfo.CloudAccountId] : Language.StringByID(R.MyInternationalizationString.uOther);
+            var btnpersion = frameTable.AddLeftCaption(perName, 600, 50, true);
             //杩欎釜鍧愭爣鏈夌偣鐗规畩
             btnpersion.Y = Application.GetRealHeight(72) + frameTable.chidrenYaxis;
             btnpersion.TextSize = 12;
@@ -343,7 +369,7 @@
             frameTable.AddChidren(btnpersion, ChidrenBindMode.NotBind);
 
             //鏃堕棿
-            frameTable.AddMostRightView("13:00:00", 200);
+            frameTable.AddMostRightView(historyInfo.UnlockTime, 400);
             if (addLine == true)
             {
                 //搴曠嚎
@@ -381,6 +407,70 @@
 
         #endregion
 
+        #region 鈻� 鑾峰彇璁板綍___________________________
+
+        /// <summary>
+        /// 鑾峰彇鍘嗗彶璁板綍
+        /// </summary>
+        /// <returns></returns>
+        private async Task<List<HistoryInfo>> GetHistoryLogInf()
+        {
+            //鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁�
+            var pra = this.GetDbInterfacePra();
+
+            int nowPage = 0;
+            var listLog = new List<HistoryInfo>();
+            while (true)
+            {
+                //璁块棶浜戠
+                var result = await UserCenterLogic.GetResponseDataByRequestHttps("DoorLock/GetDoorLockHistoryPager", true, pra);
+                if (result == null)
+                {
+                    return null;
+                }
+                var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetHistoryDataResult>(result);
+                if (dataInfo.HasNextPage == false)
+                {
+                    break;
+                }
+                //鑾峰彇涓嬩竴椤�
+                nowPage++;
+                pra.PageSetting.Page = nowPage;
+            }
+
+            //鎺掑簭涓�涓�
+            var dic = new Dictionary<string, List<HistoryInfo>>();
+            var listSort = new List<string>();
+            //鏄惁鍖呭惈鍏朵粬
+            bool flage = this.listSearchUserId.Contains("") || this.listSearchUserId.Contains("-1");
+            foreach (var data in listLog)
+            {
+                if (flage == false && string.IsNullOrEmpty(data.CloudAccountId) == true)
+                {
+                    //娌℃湁鎸囧畾鏄剧ず鍏朵粬
+                    continue;
+                }
+                if (dic.ContainsKey(data.UnlockTime) == false)
+                {
+                    dic[data.UnlockTime] = new List<HistoryInfo>();
+                    listSort.Add(data.UnlockTime);
+                }
+                dic[data.UnlockTime].Add(data);
+            }
+
+            //鎵ц鎺掑簭,鏃堕棿澶х殑鍦ㄥ墠闈�
+            listSort.Sort();
+            var listSortLog = new List<HistoryInfo>();
+            for (int i = listSort.Count - 1; i >= 0; i--)
+            {
+                listSortLog.AddRange(dic[listSort[i]]);
+            }
+
+            return listSortLog;
+        }
+
+        #endregion
+
         #region 鈻� 娓呯┖璁板綍___________________________
 
         /// <summary>
@@ -392,7 +482,7 @@
             var pra = this.GetDbInterfacePra();
             //鎵撳紑杩涘害鏉�
             this.ShowProgressBar();
-            var result = await UserCenterLogic.GetResultStatuByRequestHttps("App/ClearDoorLockHistory", false, pra);
+            var result = await UserCenterLogic.GetResultStatuByRequestHttps("DoorLock/ClearDoorLockHistory", true, pra);
             //鍏抽棴杩涘害鏉�
             this.CloseProgressBar();
             if (result == false)
@@ -416,35 +506,27 @@
             DateTime dateFrom = new DateTime(dateFromControl.Year, dateFromControl.Month, dateFromControl.Day, 0, 0, 0);
             DateTime dateTo = new DateTime(dateToControl.Year, dateToControl.Month, dateToControl.Day, 23, 59, 59);
 
-            var listUser = new List<string>();
-            if (listSearchUserId.Contains("-1") == true)
-            {
-                //鎵�鏈夌敤鎴�
-                foreach (MemberInfoRes infoRes in listMenberInfo)
-                {
-                    listUser.Add(infoRes.DistributedMark);
-                }
-            }
-            else
+            //鍏ㄩ�夊垯涓簄ull
+            List<string> listUser = null;
+            if (listSearchUserId.Contains("-1") == false)
             {
                 listUser.AddRange(listSearchUserId);
+                //绉婚櫎鍏朵粬,鍥犱负浜戠鍥哄畾浼氱粰
+                listUser.Remove("");
             }
 
-            var listLock = new List<int>();
-            if (listSearchLockId.Contains(-1) == true)
-            {
-                //鎵�鏈夊紑閿佹柟寮�
-                listLock = new List<int>() { 0, 15, 3 };
-            }
-            else
+            //鍏ㄩ�夊垯涓簄ull
+            List<int> listLock = null;
+            if (listSearchLockId.Contains(-1) == false)
             {
                 listLock.AddRange(listSearchLockId);
             }
 
             var pra = new GetHistoryDataPra();
+            pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
             pra.DoorLockId = this.DeviceMac;
-            pra.CloudAccountId = listUser[0];
-            pra.OpenLockMode = listLock[0];
+            pra.CloudAccountIdArr = listUser;
+            pra.OpenLockModeArr = listLock;
             pra.UnlockTimeBegin = dateFrom;
             pra.UnlockTimeEnd = dateTo;
             return pra;
@@ -457,7 +539,7 @@
         /// <summary>
         /// 鑾峰彇鍘嗗彶璁板綍鏁版嵁
         /// </summary>
-        private class GetHistoryDataPra
+        private class GetHistoryDataPra : IfacePraCommon
         {
             /// <summary>
             /// RequestVersion
@@ -466,7 +548,7 @@
             /// <summary>
             /// Token
             /// </summary>
-            public string LoginAccessToken = Shared.Common.Config.Instance.Token;
+            public string LoginAccessToken = string.Empty;
             /// <summary>
             /// 浣忓畢ID
             /// </summary>
@@ -478,11 +560,11 @@
             /// <summary>
             ///  Config.Instance.Guid 鎴栬�� MemberInfoRes.SubAccountDistributedMark
             /// </summary>
-            public string CloudAccountId = string.Empty;
+            public List<string> CloudAccountIdArr = new List<string>();
             /// <summary>
             ///  寮�閿佹柟寮�(0:瀵嗙爜銆�15:鎸囩汗銆�3:IC鍗�)
             /// </summary>
-            public int OpenLockMode = -1;
+            public List<int> OpenLockModeArr = null;
             /// <summary>
             /// 寮�閿佹槸鍚︽垚鍔�
             /// </summary>
@@ -522,7 +604,7 @@
         private class HistoryInfo
         {
             /// <summary>
-            /// 寮�閿佹柟寮�
+            /// 寮�閿佹柟寮� 0:瀵嗙爜  15:鎸囩汗  3:IC鍗�
             /// </summary>
             public int OpenLockMode = -1;
             /// <summary>
@@ -533,6 +615,10 @@
             /// 寮�閿佹槸鍚︽垚鍔�
             /// </summary>
             public bool UnlockIsSuccess = false;
+            /// <summary>
+            /// 璐﹀彿鐨処D
+            /// </summary>
+            public string CloudAccountId = string.Empty;
         }
 
         #endregion

--
Gitblit v1.8.0