From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001 From: hxb <hxb@hdlchina.com.cn> Date: 星期二, 30 八月 2022 09:37:38 +0800 Subject: [PATCH] 合并了IOS的代码 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs | 886 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 705 insertions(+), 181 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs index 98bb400..e295e6d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs @@ -1,7 +1,7 @@ 锘縰sing System; using System.Collections.Generic; using System.Text; -using System.Threading.Tasks; +using ZigBee.Device; namespace Shared.Phone.UserCenter.DeviceDoorLock { @@ -15,7 +15,7 @@ /// <summary> /// 鍒楄〃鎺т欢 /// </summary> - private VerticalListControl listView = null; + private VerticalFrameRefreshControl listView = null; /// <summary> /// 鏃ユ湡From鎺т欢 /// </summary> @@ -29,17 +29,25 @@ /// </summary> private List<MemberInfoRes> listMenberInfo = null; /// <summary> - /// 璁惧鐨凪ac鍦板潃 + /// 璁惧瀵硅薄 /// </summary> - private string DeviceMac = string.Empty; + private CommonDevice DeviceDoor = null; /// <summary> - /// 妫�绱㈠璞$殑ID(-1:鎵�鏈� 绌哄瓧绗︿覆:鍏朵粬) + /// 妫�绱㈠璞$殑ID(-1:鎵�鏈� -9999:鍏朵粬) /// </summary> private List<string> listSearchUserId = new List<string>() { "-1" }; /// <summary> - /// 妫�绱㈠紑閿佹柟寮忕殑ID(-1:鎵�鏈� 0:瀵嗙爜 15:鎸囩汗 3:IC鍗�) + /// 妫�绱㈠紑閿佹柟寮忕殑ID(-1:鎵�鏈� 0:瀵嗙爜 15:鎸囩汗 3:IC鍗� 9000:甯稿紑妯″紡(鑷畾涔夌殑)) /// </summary> private List<int> listSearchLockId = new List<int>() { -1 }; + /// <summary> + /// 鑾峰彇鍒扮殑鍘嗗彶璁板綍 + /// </summary> + private List<HistoryInfo> listHistoryInfo = null; + /// <summary> + /// 鍏朵粬娑堟伅鐨勪富閿�,瀹冨瓨鍦ㄥ彟澶栫殑涓�寮犳暟鎹簱琛ㄤ腑 + /// </summary> + private List<string> listOtherMsgId = new List<string>(); #endregion @@ -50,36 +58,43 @@ /// </summary> /// <param name="i_DeviceMac">闂ㄩ攣鐨凪ac鍦板潃</param> public void ShowForm(string i_DeviceMac) - { - this.DeviceMac = i_DeviceMac; + { + this.DeviceDoor = Common.LocalDevice.Current.GetDevicesByMac(i_DeviceMac, false)[0]; //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uHistoryLog)); - //鍒犻櫎 - var btnDelete = new MostRightIconControl(69, 69); - btnDelete.UnSelectedImagePath = "Item/DeleteIcon2Selected.png"; - topFrameLayout.AddChidren(btnDelete); - btnDelete.InitControl(); - btnDelete.ButtonClickEvent += (sender, e) => + //鎴愬憳涓嶅厑璁告竻绌鸿褰� + if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2) { - var form = new TopRightMenuControl(1, 449); - //娓呯┖璁板綍 - form.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uClearLog), "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () => + //鍒犻櫎 + var btnDelete = new MostRightIconControl(69, 69); + btnDelete.UnSelectedImagePath = "Item/DeleteIcon2Selected.png"; + topFrameLayout.AddChidren(btnDelete); + btnDelete.InitControl(); + btnDelete.ButtonClickEvent += (sender, e) => { - if (this.listView.ChildrenCount == 0) + var form = new TopRightMenuControl(1, 2); + //娓呯┖璁板綍 + form.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uClearLog), "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () => { - //鏃犳暟鎹彲鍒� - return; - } - //纭娓呯┖褰撳墠璁板綍锛� - this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uConfirmClearNowLog), () => - { - //娓呯┖鎵�鏈夎褰� - this.ClearAllHistoryLog(); + if (this.listView.frameTable.ChildrenCount == 0) + { + //鏃犳暟鎹彲鍒� + return; + } + //纭娓呯┖褰撳墠璁板綍锛� + this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uConfirmClearNowLog), () => + { + HdlThreadLogic.Current.RunThread(() => + { + //娓呯┖鎵�鏈夎褰� + this.ClearAllHistoryLog(); + }); + }); }); - }); - }; + }; + } //鍒濆鍖栦腑閮ㄤ俊鎭� this.InitMiddleFrame(); @@ -94,18 +109,10 @@ this.ClearBodyFrame(); //鍒濆鍖栧ご閮ㄦ绱㈡帶浠� - this.InitTitleSearchControl(); - - //涓荤嚎绋嬬殑寮傛浼氶樆濉炰富绾跨▼,瀵艰嚧鐣岄潰鏈夋鏃堕棿浼氱櫧灞�,鎵�浠ヨ繖鏍峰瓙璁╃晫闈㈠厛鍑烘潵 - //鐒跺悗鍐嶅埛鏂版暟鎹� - HdlThreadLogic.Current.RunThread(() => - { - Application.RunOnMainThread(() => - { - //鍒濆鍖栬褰曞垪琛� - this.InitLogListInfo(); - }); - }); + this.InitTitleSearchControl(); + + //鍒濆鍖栬褰曞垪琛� + this.InitLogListInfo(true); } /// <summary> @@ -130,52 +137,63 @@ dateFromControl.DateSelectEvent += (dateValue) => { //鍒濆鍖栬褰曞垪琛� - this.InitLogListInfo(); + this.InitLogListInfo(true); }; var btnTemp = new NormalViewControl(26, 58, true); btnTemp.Y = Application.GetRealHeight(29); - btnTemp.X = Application.GetRealWidth(357); + btnTemp.X = dateFromControl.Right + Application.GetRealWidth(12); btnTemp.TextColor = UserCenterColor.Current.TextGrayColor1; btnTemp.Text = "-"; frameTitle.AddChidren(btnTemp, ChidrenBindMode.NotBind); dateToControl = new DateSelectControl(Language.StringByID(R.MyInternationalizationString.uEndDate)); dateToControl.Y = Application.GetRealHeight(35); - dateToControl.X = Application.GetRealWidth(395); + dateToControl.X = btnTemp.Right + Application.GetRealWidth(12); dateToControl.dateValue = DateTime.Now.ToString("yyyyMMdd"); frameTitle.AddChidren(dateToControl, ChidrenBindMode.NotBind); dateToControl.DateSelectEvent += (dateValue) => { //鍒濆鍖栬褰曞垪琛� - this.InitLogListInfo(); + this.InitLogListInfo(true); }; //绫诲瀷绛涢�� var btnScreening = frameTitle.AddMostRightView(Language.StringByID(R.MyInternationalizationString.uScreeningType), 145); - frameTitle.ChangedChidrenBindMode(btnScreening, ChidrenBindMode.NotBind); btnScreening.TextSize = 12; - + btnScreening.Width = btnScreening.GetRealWidthByText(); + btnScreening.X = frameTitle.Width - Application.GetRealWidth(58) - btnScreening.Width; btnScreening.ButtonClickEvent += (sender, e) => { //鏄剧ず绫诲瀷绛涢�夌晫闈� this.ShowDoorLockScreeningTypeForm(); }; + frameTitle.ChangedChidrenBindMode(btnScreening, ChidrenBindMode.NotBind); //绫诲瀷绛涢�夌殑鍥炬爣 var btnScreeningIcon = new IconViewControl(69); btnScreeningIcon.X = btnScreening.X - Application.GetRealWidth(12) - btnScreeningIcon.IconSize; btnScreeningIcon.Gravity = Gravity.CenterVertical; btnScreeningIcon.UnSelectedImagePath = "Item/ScreeningType.png"; frameTitle.AddChidren(btnScreeningIcon, ChidrenBindMode.NotBind); + btnScreeningIcon.ButtonClickEvent += (sender, e) => + { + //鏄剧ず绫诲瀷绛涢�夌晫闈� + this.ShowDoorLockScreeningTypeForm(); + }; //搴曠嚎 frameTitle.AddBottomLine(); - this.listView = new VerticalListControl(29); + this.listView = new VerticalFrameRefreshControl(29); listView.Y = frameTitle.Bottom - Application.GetRealHeight(3); - listView.BackgroundColor = UserCenterColor.Current.White; listView.Height = bodyFrameLayout.Height - frameTitle.Bottom + Application.GetRealHeight(3); bodyFrameLayout.AddChidren(listView); + listView.frameTable.BackgroundColor = UserCenterColor.Current.White; + listView.BeginHeaderRefreshingAction += () => + { + //涓嬫媺鍒锋柊 + this.InitLogListInfo(true); + }; } #endregion @@ -185,10 +203,11 @@ /// <summary> /// 鍒濆鍖栬褰曞垪琛� /// </summary> - private async void InitLogListInfo() + /// <param name="reReadData">鏄惁浠庢柊浠庝簯绔鍙栨暟鎹�</param> + private void InitLogListInfo(bool reReadData) { - this.listView.RemoveAll(); - listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3); + this.listView.frameTable.RemoveAll(); + listView.frameTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3); //濡傛灉From>To鐨勬椂鍊欙紝涓嶉笩瀹� if (Convert.ToInt32(dateFromControl.dateValue) > Convert.ToInt32(dateToControl.dateValue)) @@ -197,58 +216,66 @@ this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uFromTimeIsOverToTime)); return; } - //鎵撳紑杩涘害鏉� - this.ShowProgressBar(); - //鎴愬憳鍒楄〃 - var result = await this.GetMemberListInfo(); - if (result == false) + if (reReadData == true) { + //缃┖鍚�,閲嶆柊鑾峰彇 + this.listHistoryInfo = null; + } + + HdlThreadLogic.Current.RunThread(() => + { + //鎵撳紑杩涘害鏉� + this.ShowProgressBar(); + //鎴愬憳鍒楄〃 + var result = this.GetMemberListInfo(); + if (result == false) + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(ShowReLoadMode.YES); + return; + } + //鎴愬憳淇℃伅 + var dicMemberName = new Dictionary<string, string>(); + for (int i = 0; i < listMenberInfo.Count; i++) + { + dicMemberName.Add(listMenberInfo[i].SubAccountDistributedMark, string.IsNullOrEmpty(listMenberInfo[i].UserName) == false ? listMenberInfo[i].UserName : listMenberInfo[i].Account); + } + //鍘嗗彶璁板綍 + var historyLog = this.GetHistoryLogInfo(dicMemberName); + if (historyLog == null) + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(ShowReLoadMode.YES); + return; + } //鍏抽棴杩涘害鏉� - this.CloseProgressBar(ShowReLoadMode.YES); - return; - } - //鍘嗗彶璁板綍 - var historyLog = await this.GetHistoryLogInf(); - if (historyLog == null) - { - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(ShowReLoadMode.YES); - return; - } - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); + this.CloseProgressBar(); - 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], dic, i != historyLog.Count - 1); - } + HdlThreadLogic.Current.RunMain(() => + { + for (int i = 0; i < historyLog.Count; i++) + { + //娣诲姞璁板綍琛� + this.AddLogInfoRow(historyLog[i], dicMemberName, i != historyLog.Count - 1); + } + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); - if (listView.ChildrenCount == 0) - { - return; - } - - //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� - var realHeight = listView.ChildrenCount * listView.GetChildren(0).Height; - realHeight += Application.GetRealHeight(23 + 3); - if (realHeight < listView.Height) - { - //缂╁皬鎺т欢楂樺害 - listView.Height = realHeight; - } + if (listView.frameTable.ChildrenCount == 0) + { + return; + } + //璋冩暣鍒楄〃鎺т欢鐨勯珮搴� + listView.AdjustTableHeight(Application.GetRealHeight(23)); + }); + }); } /// <summary> /// 鑾峰彇鎴愬憳鍒楄〃淇℃伅 /// </summary> /// <returns></returns> - private async Task<bool> GetMemberListInfo() + private bool GetMemberListInfo() { if (listMenberInfo != null) { @@ -271,8 +298,8 @@ } var pra = new MemberListInfoPra(); - string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra); - if (result == null) + string result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra); + if (string.IsNullOrEmpty(result) == true) { return false; } @@ -304,26 +331,86 @@ { var frameTable = new FrameRowControl(listView.rowSpace / 2); frameTable.UseClickStatu = false; - this.listView.AddChidren(frameTable); + this.listView.AddChidren2(frameTable); //鍥炬爣 var btnIcon = frameTable.AddLeftIcon(); - if (historyInfo.UnlockIsSuccess == true) + //淇℃伅 + var btnMsg = frameTable.AddTopView("", 600); + //浜虹墿 + string perName = dicName.ContainsKey(historyInfo.CloudAccountId) == true ? dicName[historyInfo.CloudAccountId] : Language.StringByID(R.MyInternationalizationString.uOther); + frameTable.AddBottomView(perName, 600); + //鏃堕棿 + if (this.dateFromControl.dateValue == this.dateToControl.dateValue) { - btnIcon.UnSelectedImagePath = "Item/UnLockSuccess.png"; + //濡傛灉鏃ユ湡鑼冨洿涓�鏍�,鍒欎笉鏄剧ず骞存湀鏃� + frameTable.AddMostRightView(UserCenterLogic.ConvertUtcTimeToLocalTime(historyInfo.UnlockTime).ToString("HH:mm:ss"), 400); } else { - btnIcon.UnSelectedImagePath = "Item/UnLockSuccess.png"; + //濡傛灉鏃ユ湡鑼冨洿涓嶄竴鏍�,鍒欐樉绀哄勾鏈堟棩 + frameTable.AddMostRightView(UserCenterLogic.ConvertUtcTimeToLocalTime(historyInfo.UnlockTime).ToString("yyyy/MM/dd HH:mm:ss"), 700); + } + //搴曠嚎 + if (addLine == true) + { + + frameTable.AddBottomLine(); } - //淇℃伅 - 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 == -1) { + //鍥剧墖 + var device = Common.LocalDevice.Current.GetDevice(historyInfo.DeviceMac, historyInfo.DeviceEpoint); + if (device == null) + { + btnIcon.UnSelectedImagePath = "Device/IntelligentLocks.png"; + } + else + { + Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device); + } + //娑堟伅 + btnMsg.Text = historyInfo.AlarmMsg; + } + //闂ㄩ攣甯稿紑妯″紡 + else if (historyInfo.OpenLockMode == 9000) + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png"; + //娑堟伅 + if (historyInfo.OtherOpenLockMode == 9001) + { + //甯稿紑妯″紡鎵嬪姩寮�鍚� + btnMsg.TextID = R.MyInternationalizationString.uNormallyOpenModeManualOpen; + } + else if (historyInfo.OtherOpenLockMode == 9002) + { + //甯稿紑妯″紡鎵嬪姩鍙栨秷 + btnMsg.TextID = R.MyInternationalizationString.uNormallyOpenModeManualClose; + } + else if (historyInfo.OtherOpenLockMode == 9003) + { + //甯稿紑妯″紡鍚敤{0}灏忔椂 + btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uNormallyOpenModeOpenSomeTime).Replace("{0}", historyInfo.NormallyOpenContinuedTime); + } + else if (historyInfo.OtherOpenLockMode == 9004) + { + //甯稿紑鑷姩鍖栨墜鍔ㄥ彇娑� + btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uNormallyOpenLogicManualClose); + } + else + { + //涓婇潰鏄疉pp鎵嬪姩鎺ㄩ��,杩欓噷鏄綉鍏虫垨鑰呴棬閿佽嚜宸辨帹閫� + btnMsg.Text = historyInfo.AlarmMsg; + } + } + //寮�閿佹垚鍔� + else if (historyInfo.UnlockIsSuccess == true) + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/UnLockSuccess.png"; + //娑堟伅 if (historyInfo.OpenLockMode == 0) { //瀵嗙爜寮�閿佹垚鍔� @@ -334,14 +421,28 @@ //IC鍗″紑閿佹垚鍔� btnMsg.TextID = R.MyInternationalizationString.uUnlockByICcardSuccess; } + else if (historyInfo.OpenLockMode == 13) + { + //闈欒剦绾瑰紑閿佹垚鍔� + btnMsg.TextID = R.MyInternationalizationString.uStriaVenosusUnLockSuccess; + } + else if (historyInfo.OpenLockMode == 14) + { + //浜鸿劯璇嗗埆寮�閿佹垚鍔� + btnMsg.TextID = R.MyInternationalizationString.uFaceRecognitionUnLockSuccess; + } else if (historyInfo.OpenLockMode == 15) { //鎸囩汗寮�閿佹垚鍔� btnMsg.TextID = R.MyInternationalizationString.uUnlockByFingerPrintSuccess; } } + //寮�閿佸け璐� else { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/UnLockFail.png"; + //娑堟伅 if (historyInfo.OpenLockMode == 0) { //瀵嗙爜寮�閿佸け璐� @@ -352,28 +453,21 @@ //IC鍗″紑閿佸け璐� btnMsg.TextID = R.MyInternationalizationString.uUnlockByICcardFail; } + else if (historyInfo.OpenLockMode == 13) + { + //闈欒剦绾瑰紑閿佸け璐� + btnMsg.TextID = R.MyInternationalizationString.uStriaVenosusUnLockFail; + } + else if (historyInfo.OpenLockMode == 14) + { + //浜鸿劯璇嗗埆寮�閿佸け璐� + btnMsg.TextID = R.MyInternationalizationString.uFaceRecognitionUnLockFail; + } else if (historyInfo.OpenLockMode == 15) { //鎸囩汗寮�閿佸け璐� btnMsg.TextID = R.MyInternationalizationString.uUnlockByFingerPrintFail; } - } - - //浜虹墿 - 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; - btnpersion.TextColor = UserCenterColor.Current.TextGrayColor1; - frameTable.AddChidren(btnpersion, ChidrenBindMode.NotBind); - - //鏃堕棿 - frameTable.AddMostRightView(historyInfo.UnlockTime, 400); - if (addLine == true) - { - //搴曠嚎 - frameTable.AddBottomLine(); } } @@ -401,72 +495,389 @@ listSearchLockId.Clear(); listSearchLockId.AddRange(selectLock); //鍒濆鍖栬褰曞垪琛� - this.InitLogListInfo(); + this.InitLogListInfo(false); }; } #endregion - #region 鈻� 鑾峰彇璁板綍___________________________ + #region 鈻� 绛涢�夎褰昣__________________________ + + /// <summary> + /// 绛涢�夊巻鍙茶褰� + /// </summary> + /// <returns></returns> + private List<HistoryInfo> ScreeningHistoryData(Dictionary<string, string> dicMemberName) + { + //鍘嗗彶璁板綍澶夯鐑︿簡,瀛樺湪涓嶅悓鐨勬暟鎹簱琛ㄩ噷,骞朵笖鏁版嵁杩樹笉涓�鏍�,鍙兘杩欐牱涓�涓釜鍒ゆ柇浜� + var listScreeningData = new List<HistoryInfo>(); + //娓呴櫎鎺変箣鍓嶇殑璁板綍 + this.listOtherMsgId = new List<string>(); + + //鏄惁閫夋嫨鍏ㄩ�夌敤鎴� + bool selectAllUser = this.listSearchUserId.Contains("-1"); + //鏄惁鍗曢�変簡鍏朵粬 + bool selectOtherUser = this.listSearchUserId.Contains("-9999"); + //鏄惁閫夋嫨鍏ㄩ�夊紑閿佹柟寮� + bool selectAllLockMode = this.listSearchLockId.Contains(-1); + + //涓�涓釜鍘婚亶鍘� + foreach (var data in this.listHistoryInfo) + { + //妫�娴嬭鍘嗗彶璁板綍鑳藉惁鏄剧ず + bool result = this.CheckHistoryDataCanShow(data, dicMemberName, selectAllUser, selectOtherUser, selectAllLockMode); + if (result == true) + { + listScreeningData.Add(data); + } + } + + return listScreeningData; + } + + /// <summary> + /// 妫�娴嬭鍘嗗彶璁板綍鑳藉惁鏄剧ず + /// </summary> + /// <param name="info">妫�娴嬪璞�</param> + /// <param name="dicMemberName">鎴愬憳淇℃伅</param> + /// <param name="selectAllUser">鏄惁閫夋嫨鍏ㄩ�夌敤鎴�</param> + /// <param name="selectOtherUser">鏄惁鍗曢�変簡鍏朵粬</param> + /// <param name="slectAllLockMode">鏄惁閫夋嫨鍏ㄩ�夊紑閿佹柟寮�</param> + private bool CheckHistoryDataCanShow(HistoryInfo info, Dictionary<string, string> dicMemberName, + bool selectAllUser, bool selectOtherUser, bool slectAllLockMode) + { + //濡傛灉娌℃湁閫夋嫨 鍏ㄩ�夌敤鎴� + if (selectAllUser == false) + { + //濡傛灉杩欎釜鐢ㄦ埛ID涓嶅寘鍚湪鎸囧畾閫夋嫨鐨勬垚鍛樺垪琛ㄩ噷闈� + if (this.listSearchUserId.Contains(info.CloudAccountId) == false) + { + if (dicMemberName.ContainsKey(info.CloudAccountId) == true) + { + //濡傛灉鑳藉璇嗗埆杩欎釜id鐨勮瘽,鍒欒〃绀哄畠涓嶅睘浜庡叾浠栫被,骞朵笖涔熶笉鍐嶉�夋嫨鐩爣鍐� + return false; + } + //濡傛灉娌℃湁閫夋嫨 鍏朵粬鐨勮瘽,涓嶆樉绀� + if (selectOtherUser == false) + { + return false; + } + } + } + //濡傛灉鏄垚鍛樿韩浠�,骞朵笖鐢ㄦ埛ID涓嶄负绌� + if (UserCenterResourse.UserInfo.AuthorityNo == 3 && info.CloudAccountId != string.Empty) + { + //鎴愬憳涓嶈兘鐪嬪埌 鍏朵粬浜虹殑璁板綍(鎴愬憳鐨勬椂鍊�,杩欎釜鍙橀噺閲岄潰鍙湁浠栬嚜宸变竴涓�) + if (dicMemberName.ContainsKey(info.CloudAccountId) == false) + { + return false; + } + } + //濡傛灉娌℃湁閫夋嫨 鍏ㄩ�夊紑閿佹柟寮� + if (slectAllLockMode == false) + { + //濡傛灉杩欎釜寮�閿佹柟寮忎笉鍦ㄩ�夋嫨鐨勫垪琛ㄩ噷闈㈢殑璇� + if (this.listSearchLockId.Contains(info.OpenLockMode) == false) + { + return false; + } + } + + //鍙︿竴寮犺〃鐨勬暟鎹富閿� + if (info.OpenLockMode == -1 || info.OpenLockMode == 9000) + { + if (info.MsgKeyId != string.Empty) + { + //鍏朵粬娑堟伅鐨勪富閿�,瀹冨瓨鍦ㄥ彟澶栫殑涓�寮犳暟鎹簱琛ㄤ腑 + this.listOtherMsgId.Add(info.MsgKeyId); + } + } + + return true; + } + + #endregion + + #region 鈻� 鑾峰彇闂ㄩ攣鎵撳紑璁板綍___________________ /// <summary> /// 鑾峰彇鍘嗗彶璁板綍 /// </summary> /// <returns></returns> - private async Task<List<HistoryInfo>> GetHistoryLogInf() + private List<HistoryInfo> GetHistoryLogInfo(Dictionary<string, string> dicMemberName) { + if (this.listHistoryInfo != null) + { + //涓嶄簩娆¤幏鍙�,涓昏閽堝鐨勬槸绛涢�夊姛鑳� + return this.ScreeningHistoryData(dicMemberName); + } //鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁� - var pra = this.GetDbInterfacePra(); + var pra = this.GetReadHistoryPra(); + + //鑾峰彇闂ㄩ攣鐨勬墦寮�鍜屽叧闂褰� + var listAllLog = this.GetDoorOpenHistoryLog(pra); + //鑾峰彇闂ㄩ攣鐨勫叾浠栬褰� + var listOtherLog = this.GetDoorOtherHistoryLog(pra.UnlockTimeBegin, pra.UnlockTimeEnd); + listAllLog.AddRange(listOtherLog); + + //鎺掑簭涓�涓� + var dicAllData = new Dictionary<string, List<HistoryInfo>>(); + var listSortTime = new List<string>(); + + foreach (var data in listAllLog) + { + //鎸夋椂闂村垎缁� + if (dicAllData.ContainsKey(data.UnlockTime) == false) + { + dicAllData[data.UnlockTime] = new List<HistoryInfo>(); + listSortTime.Add(data.UnlockTime); + } + dicAllData[data.UnlockTime].Add(data); + } + + //鎵ц鎺掑簭,鏃堕棿澶х殑鍦ㄥ墠闈� + listSortTime.Sort(); + this.listHistoryInfo = new List<HistoryInfo>(); + for (int i = listSortTime.Count - 1; i >= 0; i--) + { + this.listHistoryInfo.AddRange(dicAllData[listSortTime[i]]); + } + //绛涢�夊巻鍙茶褰� + return this.ScreeningHistoryData(dicMemberName); + } + + /// <summary> + /// 鑾峰彇闂ㄩ攣鐨勬墦寮�鍜屽叧闂褰� + /// </summary> + /// <param name="i_pra"></param> + /// <returns></returns> + private List<HistoryInfo> GetDoorOpenHistoryLog(GetHistoryDataPra i_pra) + { + var listLog = new List<HistoryInfo>(); int nowPage = 0; - var listLog = new List<HistoryInfo>(); while (true) { //璁块棶浜戠 - var result = await UserCenterLogic.GetResponseDataByRequestHttps("DoorLock/GetDoorLockHistoryPager", true, pra); - if (result == null) + var result = UserCenterLogic.GetResponseDataByRequestHttps("DoorLock/GetDoorLockHistoryPager", true, i_pra); + if (string.IsNullOrEmpty(result) == true) { return null; } var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetHistoryDataResult>(result); + foreach (var data in dataInfo.PageData) + { + //涓嶇煡閬撲负浠�涔堜細鏈変笂鎶ヤ簡铏氭嫙9000鐨勯偅涓壒娈婄殑涓滆タ + if (data.OpenLockMode == 9000 && data.OtherOpenLockMode <= 9000) + { + continue; + } + if (data.CloudAccountId == null) + { + data.CloudAccountId = string.Empty; + } + listLog.Add(data); + } + if (dataInfo.HasNextPage == false) { break; } //鑾峰彇涓嬩竴椤� nowPage++; - pra.PageSetting.Page = nowPage; + i_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) + return listLog; + } + + #endregion + + #region 鈻� 鑾峰彇闂ㄩ攣鍏朵粬璁板綍___________________ + + /// <summary> + /// 鑾峰彇闂ㄩ攣鐨勫叾浠栬褰� + /// </summary> + /// <returns></returns> + private List<HistoryInfo> GetDoorOtherHistoryLog(string beginTime, string endTime) + { + var listLog = new List<HistoryInfo>(); + + //鑾峰彇闂ㄩ攣鍏朵粬绫讳俊鎭笂鎶� + var pra2 = new MessageInfoPra(); + pra2.BeginTime = beginTime; + pra2.EndTime = endTime; + pra2.Topic = "/Alarms/SendAlarmInform"; + pra2.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); + var result = UserCenterLogic.GetResponseDataByRequestHttps("MessageCenter/GetMessageCenterPagger", true, pra2); + if (string.IsNullOrEmpty(result) == true) { - if (flage == false && string.IsNullOrEmpty(data.CloudAccountId) == true) + return null; + } + this.AdjustDoorOtherAlarmData(ref listLog, result); + + //浠庤嚜鍔ㄥ寲涓�,鑾峰彇甯稿紑妯″紡璁板綍 + pra2.Topic = "/Logic/Execute_Respon"; + result = UserCenterLogic.GetResponseDataByRequestHttps("MessageCenter/GetMessageCenterPagger", true, pra2); + if (string.IsNullOrEmpty(result) == true) + { + return null; + } + this.AdjustDoorNormallyOpenData(ref listLog, result); + + //鑾峰彇闂ㄩ攣涓存椂瀵嗙爜寮�閿佽褰� + pra2.Topic = "/DoorLock/DoorLockOperatingEventNotificationCommand"; + result = UserCenterLogic.GetResponseDataByRequestHttps("MessageCenter/GetMessageCenterPagger", true, pra2); + if (string.IsNullOrEmpty(result) == true) + { + return null; + } + this.AdjustDoorTemporaryPasswordData(ref listLog, result); + + return listLog; + } + + /// <summary> + /// 澶勭悊闂ㄩ攣甯稿紑妯″紡璁板綍淇℃伅 + /// </summary> + /// <param name="listLog"></param> + /// <param name="result"></param> + private void AdjustDoorOtherAlarmData(ref List<HistoryInfo> listLog, string result) + { + var dataInfo2 = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageCentetInfo>(result); + string doorKey = this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint; + foreach (var myInfo in dataInfo2.PageData) + { + //璁惧瀵硅薄 + var jobject = Newtonsoft.Json.Linq.JObject.Parse(myInfo.PayloadJson); + string deviceAddr = jobject.Value<string>("DeviceAddr"); + int deviceEpoint = jobject.Value<int>("Epoint"); + if (doorKey != deviceAddr + "_" + deviceEpoint) { - //娌℃湁鎸囧畾鏄剧ず鍏朵粬 + //涓嶆槸鍚屼竴涓棬閿佺殑璁板綍 continue; } - if (dic.ContainsKey(data.UnlockTime) == false) + + var data = new HistoryInfo(); + data.DeviceMac = deviceAddr; + data.DeviceEpoint = deviceEpoint; + //娑堟伅 + var msgInfo = HdlAlarmsLogic.Current.GetDoorLockAlarmInfo(jobject); + data.AlarmMsg = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered); + //鏃堕棿 + data.UnlockTime = myInfo.CreatedOnUtc; + //涓婚敭 + data.MsgKeyId = myInfo.Id; + //娑堟伅鍖哄垎 + if (msgInfo.MsgDiv == 9000) { - dic[data.UnlockTime] = new List<HistoryInfo>(); - listSort.Add(data.UnlockTime); + data.OpenLockMode = 9000; } - dic[data.UnlockTime].Add(data); + listLog.Add(data); } + } - //鎵ц鎺掑簭,鏃堕棿澶х殑鍦ㄥ墠闈� - listSort.Sort(); - var listSortLog = new List<HistoryInfo>(); - for (int i = listSort.Count - 1; i >= 0; i--) + /// <summary> + /// 澶勭悊闂ㄩ攣甯稿紑妯″紡淇℃伅涓婃姤 + /// </summary> + /// <param name="listLog"></param> + /// <param name="result"></param> + private void AdjustDoorNormallyOpenData(ref List<HistoryInfo> listLog, string result) + { + var dataInfo2 = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageCentetInfo>(result); + string doorKey = this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint; + foreach (var myInfo in dataInfo2.PageData) { - listSortLog.AddRange(dic[listSort[i]]); - } + var jobject = Newtonsoft.Json.Linq.JObject.Parse(myInfo.PayloadJson); + var myActionData = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicPushResult>(jobject["Data"].ToString()); + if (myActionData.ActionData == null || myActionData.ActionData.Actiontype != 8) + { + //涓嶆槸甯稿紑妯″紡鐨勮嚜鍔ㄥ寲 + continue; + } + string deviceAddr = myActionData.ActionData.MacStr; + int deviceEpoint = myActionData.ActionData.Epoint; + if (doorKey != deviceAddr + "_" + deviceEpoint) + { + //涓嶆槸鍚屼竴涓棬閿佺殑璁板綍 + continue; + } - return listSortLog; + var data = new HistoryInfo(); + data.DeviceMac = deviceAddr; + data.DeviceEpoint = deviceEpoint; + //娑堟伅 + if (myActionData.ActionData.PassDataString == "055704010112") + { + //甯稿紑妯″紡寮�鍚�(鑷姩鍖栬Е鍙�) + data.AlarmMsg = Language.StringByID(R.MyInternationalizationString.uDoorLockAlarmMsg11); + } + else if (myActionData.ActionData.PassDataString == "055704010113") + { + //甯稿紑妯″紡缁撴潫(鑷姩鍖栬Е鍙�) + data.AlarmMsg = Language.StringByID(R.MyInternationalizationString.uDoorLockAlarmMsg12); + } + else + { + continue; + } + //鏃堕棿 + data.UnlockTime = myInfo.CreatedOnUtc; + //涓婚敭 + data.MsgKeyId = myInfo.Id; + //娑堟伅鍖哄垎 + data.OpenLockMode = 9000; + + listLog.Add(data); + } + } + + /// <summary> + /// 澶勭悊闂ㄩ攣涓存椂瀵嗙爜涓婃姤 + /// </summary> + /// <param name="listLog"></param> + /// <param name="result"></param> + private void AdjustDoorTemporaryPasswordData(ref List<HistoryInfo> listLog, string result) + { + var dataInfo2 = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageCentetInfo>(result); + string doorKey = this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint; + foreach (var myInfo in dataInfo2.PageData) + { + var jobject = Newtonsoft.Json.Linq.JObject.Parse(myInfo.PayloadJson); + string deviceAddr = jobject.Value<string>("DeviceAddr"); + int deviceEpoint = jobject.Value<int>("Epoint"); + if (doorKey != deviceAddr + "_" + deviceEpoint) + { + //涓嶆槸鍚屼竴涓棬閿佺殑璁板綍 + continue; + } + var myActionData = Newtonsoft.Json.JsonConvert.DeserializeObject<PasswordOperationData>(jobject["Data"].ToString()); + if (myActionData.UserID != 246) + { + //涓嶆槸涓存椂瀵嗙爜 + continue; + } + var data = new HistoryInfo(); + data.DeviceMac = deviceAddr; + data.DeviceEpoint = deviceEpoint; + //娑堟伅 + if (myActionData.OperationEventCode == 2) + { + //涓存椂瀵嗙爜寮�閿佹垚鍔� + data.AlarmMsg = Language.StringByID(R.MyInternationalizationString.uDoorLockAlarmMsg13); + } + else + { + //涓存椂瀵嗙爜寮�閿佸け璐� + data.AlarmMsg = Language.StringByID(R.MyInternationalizationString.uDoorLockAlarmMsg14); + } + //鏃堕棿 + data.UnlockTime = myInfo.CreatedOnUtc; + //涓婚敭 + data.MsgKeyId = myInfo.Id; + + listLog.Add(data); + } } #endregion @@ -476,21 +887,50 @@ /// <summary> /// 娓呯┖鎵�鏈夎褰� /// </summary> - private async void ClearAllHistoryLog() + private void ClearAllHistoryLog() { - //鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁� - var pra = this.GetDbInterfacePra(); + //鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁�(2020.05.08:鍏ㄩ儴娓呯┖) + var pra = this.GetDeleteDataPra(); + //鎵撳紑杩涘害鏉� this.ShowProgressBar(); - var result = await UserCenterLogic.GetResultStatuByRequestHttps("DoorLock/ClearDoorLockHistory", true, pra); + var result = UserCenterLogic.GetResultStatuByRequestHttps("DoorLock/ClearDoorLockHistory", true, pra); + if (result == false) + { + return; + } + + //鍒犻櫎鍏朵粬娑堟伅 + if (listOtherMsgId.Count > 0) + { + var pra2 = new MessageReadStatuPra(); + pra2.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); + for (int i = 0; i < listOtherMsgId.Count; i++) + { + pra2.Id = listOtherMsgId[i]; + result = UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/DelMessageCenterItem", true, pra2); + if (result == false) + { + return; + } + } + } //鍏抽棴杩涘害鏉� this.CloseProgressBar(); if (result == false) { return; } - this.listView.RemoveAll(); - listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3); + + //娓呯┖ + this.listOtherMsgId = new List<string>(); + this.listHistoryInfo = null; + + HdlThreadLogic.Current.RunMain(() => + { + this.listView.frameTable.RemoveAll(); + listView.frameTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3); + }); } #endregion @@ -501,34 +941,36 @@ /// 鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁� /// </summary> /// <returns></returns> - private GetHistoryDataPra GetDbInterfacePra() + private GetHistoryDataPra GetReadHistoryPra() { 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); - //鍏ㄩ�夊垯涓簄ull - List<string> listUser = null; - if (listSearchUserId.Contains("-1") == false) - { - listUser.AddRange(listSearchUserId); - //绉婚櫎鍏朵粬,鍥犱负浜戠鍥哄畾浼氱粰 - listUser.Remove(""); - } - - //鍏ㄩ�夊垯涓簄ull - List<int> listLock = null; - if (listSearchLockId.Contains(-1) == false) - { - listLock.AddRange(listSearchLockId); - } - + //鍏ㄩ儴璇诲彇 var pra = new GetHistoryDataPra(); + pra.UnlockTimeBegin = dateFrom.ToUniversalTime().ToString(); + pra.UnlockTimeEnd = dateTo.ToUniversalTime().ToString(); pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); - pra.DoorLockId = this.DeviceMac; - pra.CloudAccountIdArr = listUser; - pra.OpenLockModeArr = listLock; - pra.UnlockTimeBegin = dateFrom; - pra.UnlockTimeEnd = dateTo; + pra.DoorLockId = this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint; + + return pra; + } + + /// <summary> + /// 鑾峰彇鍒犻櫎鏁版嵁鐨勪簯绔帴鍙g殑鍚姩鍙傛暟 + /// </summary> + /// <returns></returns> + private DeleteHistoryDataPra GetDeleteDataPra() + { + 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 pra = new DeleteHistoryDataPra(); + pra.UnlockTimeBegin = dateFrom.ToUniversalTime().ToString(); + pra.UnlockTimeEnd = dateTo.ToUniversalTime().ToString(); + pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); + pra.DoorLockId = this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint; + return pra; } @@ -572,11 +1014,11 @@ /// <summary> /// 鎼滅储寮�閿佸紑濮嬫椂闂� /// </summary> - public DateTime UnlockTimeBegin; + public string UnlockTimeBegin; /// <summary> /// 鎼滅储寮�閿佺粨鏉熸椂闂� /// </summary> - public DateTime UnlockTimeEnd; + public string UnlockTimeEnd; /// <summary> /// 椤垫暟 /// </summary> @@ -599,12 +1041,51 @@ } /// <summary> + /// 鍒犻櫎鍘嗗彶璁板綍鏁版嵁 + /// </summary> + private class DeleteHistoryDataPra : IfacePraCommon + { + /// <summary> + /// RequestVersion + /// </summary> + public string RequestVersion = Common.CommonPage.RequestVersion; + /// <summary> + /// Token + /// </summary> + public string LoginAccessToken = string.Empty; + /// <summary> + /// 浣忓畢ID + /// </summary> + public string HomeId = Common.Config.Instance.Home.Id; + /// <summary> + /// 闂ㄩ攣鐨凪ac鍦板潃 + /// </summary> + public string DoorLockId = string.Empty; + /// <summary> + /// Config.Instance.Guid 鎴栬�� MemberInfoRes.SubAccountDistributedMark + /// </summary> + public List<string> CloudAccountIds = null; + /// <summary> + /// 寮�閿佹柟寮�(0:瀵嗙爜銆�15:鎸囩汗銆�3:IC鍗�) + /// </summary> + public List<int> OpenLockModes = null; + /// <summary> + /// 鎼滅储寮�閿佸紑濮嬫椂闂� + /// </summary> + public string UnlockTimeBegin; + /// <summary> + /// 鎼滅储寮�閿佺粨鏉熸椂闂� + /// </summary> + public string UnlockTimeEnd; + } + + /// <summary> /// 鍘嗗彶璁板綍鐨勭粨鏋� /// </summary> private class HistoryInfo { /// <summary> - /// 寮�閿佹柟寮� 0:瀵嗙爜 15:鎸囩汗 3:IC鍗� + /// 寮�閿佹柟寮� 0:瀵嗙爜 13:闈欒剦绾� 14:浜鸿劯璇嗗埆 15:鎸囩汗 3:IC鍗� 9000:甯稿紑妯″紡(鑷畾涔夌殑) /// </summary> public int OpenLockMode = -1; /// <summary> @@ -619,6 +1100,49 @@ /// 璐﹀彿鐨処D /// </summary> public string CloudAccountId = string.Empty; + /// <summary> + /// 鍏朵粬寮�閿佹柟寮�(OpenLockMode=9000鏃舵湁鏁�) 9001:甯稿紑鎵撳紑 9002:甯稿紑鍙栨秷 9003:甯稿紑鎸佺画 9004:甯稿紑鑷姩鍖栨墜鍔ㄥ彇娑� + /// </summary> + public int? OtherOpenLockMode = -1; + /// <summary> + /// 甯稿紑鎸佺画鏃堕棿(1~72灏忔椂 OtherOpenLockMode=9003鐨勬椂鍊欐湁鏁�) + /// </summary> + public string NormallyOpenContinuedTime = string.Empty; + /// <summary> + /// 褰撳紑閿佹柟寮忎负-1鏃朵娇鐢�,瀹冨睘浜庡叾浠栫被 + /// </summary> + public string AlarmMsg = string.Empty; + /// <summary> + /// 褰撳紑閿佹柟寮忎负-1鏃朵娇鐢�,璁惧Mac + /// </summary> + public string DeviceMac = string.Empty; + /// <summary> + /// 褰撳紑閿佹柟寮忎负-1鏃朵娇鐢�,璁惧绔偣 + /// </summary> + public int DeviceEpoint = 0; + /// <summary> + /// 褰撳紑閿佹柟寮忎负-1鏃朵娇鐢�,娑堟伅鐨勬暟鎹簱涓婚敭 + /// </summary> + public string MsgKeyId = string.Empty; + } + + /// <summary> + /// 涓存椂瀵嗙爜鏁版嵁 + /// </summary> + private class PasswordOperationData + { + /// <summary> + /// 0:瀵嗙爜 15:鎸囩汗 3:IC鍗� + /// </summary> + public int OperationEventSoure = -1; + /// <summary> + /// 2:寮�閿佹垚鍔� + /// </summary> + public int OperationEventCode = -1; + /// <summary> + /// 246浠h〃涓存椂瀵嗙爜 + /// </summary> + public int UserID = -1; } #endregion -- Gitblit v1.8.0