From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 17 十二月 2020 09:07:13 +0800 Subject: [PATCH] 新云端Ver1.3 --- ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs | 959 +++++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 665 insertions(+), 294 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs index 766d806..d09ef92 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<DoorHistoryLogInfo> listHistoryInfo = null; + /// <summary> + /// 鍏朵粬娑堟伅鐨勪富閿�,瀹冨瓨鍦ㄥ彟澶栫殑涓�寮犳暟鎹簱琛ㄤ腑 + /// </summary> + private List<string> listOtherMsgId = new List<string>(); #endregion @@ -48,64 +56,63 @@ /// <summary> /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) /// </summary> - /// <param name="i_DeviceMac">闂ㄩ攣鐨凪ac鍦板潃</param> - public void ShowForm(string i_DeviceMac) - { - this.DeviceMac = i_DeviceMac; - - //璁剧疆澶撮儴淇℃伅 - 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) => + /// <param name="i_DeviceMac">闂ㄩ攣鐨凪ac鍦板潃</param> + public void ShowForm(string i_DeviceMac) + { + this.DeviceDoor = HdlDeviceCommonLogic.Current.GetDevicesByMac(i_DeviceMac, false)[0]; + + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uHistoryLog)); + + //鎴愬憳涓嶅厑璁告竻绌鸿褰� + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.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(); - } - - /// <summary> - /// 鍒濆鍖栦腑閮ㄤ俊鎭� - /// </summary> - private void InitMiddleFrame() + }; + } + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() { //娓呯┖bodyFrame - this.ClearBodyFrame(); - - //鍒濆鍖栧ご閮ㄦ绱㈡帶浠� - this.InitTitleSearchControl(); - - //涓荤嚎绋嬬殑寮傛浼氶樆濉炰富绾跨▼,瀵艰嚧鐣岄潰鏈夋鏃堕棿浼氱櫧灞�,鎵�浠ヨ繖鏍峰瓙璁╃晫闈㈠厛鍑烘潵 - //鐒跺悗鍐嶅埛鏂版暟鎹� - HdlThreadLogic.Current.RunThread(() => - { - Application.RunOnMainThread(() => - { - //鍒濆鍖栬褰曞垪琛� - this.InitLogListInfo(); - }); - }); + this.ClearBodyFrame(); + + //鍒濆鍖栧ご閮ㄦ绱㈡帶浠� + this.InitTitleSearchControl(); + + //鍒濆鍖栬褰曞垪琛� + this.InitLogListInfo(true); } /// <summary> @@ -113,10 +120,10 @@ /// </summary> private void InitTitleSearchControl() { - var frameTitle = new FrameRowControl(); - frameTitle.UseClickStatu = false; - frameTitle.Height = Application.GetRealHeight(115); - frameTitle.BackgroundColor = topFrameLayout.BackgroundColor; + var frameTitle = new FrameRowControl(); + frameTitle.UseClickStatu = false; + frameTitle.Height = Application.GetRealHeight(115); + frameTitle.BackgroundColor = topFrameLayout.BackgroundColor; bodyFrameLayout.AddChidren(frameTitle); var btnDateIcon = frameTitle.AddLeftIcon(69); @@ -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,128 +203,117 @@ /// <summary> /// 鍒濆鍖栬褰曞垪琛� /// </summary> - private async void InitLogListInfo() + /// <param name="reReadData">鏄惁浠庢柊浠庝簯绔鍙栨暟鎹�</param> + private void InitLogListInfo(bool reReadData) { + this.listView.frameTable.RemoveAll(); + listView.frameTable.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; } - //鎵撳紑杩涘害鏉� - 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].ChildAccountId, listMenberInfo[i].ShowName); + } + //鍘嗗彶璁板綍 + 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(); - this.listView.RemoveAll(); - listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3); + HdlThreadLogic.Current.RunMain(() => + { + for (int i = 0; i < historyLog.Count; i++) + { + //娣诲姞璁板綍琛� + this.AddLogInfoRow(historyLog[i], dicMemberName, i != historyLog.Count - 1); + } + //闅愯棌涓嬫媺鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); - for (int i = 0; i < historyLog.Count; i++) - { - //娣诲姞璁板綍琛� - this.AddLogInfoRow(historyLog[i], i != historyLog.Count - 1); - } - - 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) { //鍙垵濮嬪寲涓�娆� 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() { - Account = UserCenterResourse.UserInfo.Account, - UserName = UserCenterResourse.UserInfo.UserName, - SubAccountDistributedMark = Common.Config.Instance.Guid + ChildAccountEmail = HdlUserCenterResourse.UserInfo.UserEmail, + ChildAccountPhone = HdlUserCenterResourse.UserInfo.UserPhone, + ChildNickName = HdlUserCenterResourse.UserInfo.NickName, + ChildAccountId = Common.Config.Instance.Guid }; listMenberInfo.Add(myInfo); - - List<MemberInfoRes> listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MemberInfoRes>>(result); + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3) + { + //鎴愬憳鍙兘鐪嬭嚜宸辩殑 + return true; + } + //鑾峰彇鎴愬憳鍒楄〃 + var listInfo = HdlMemberLogic.Current.GetMemberListInfo(ShowNetCodeMode.YES); + if (listInfo == null) + { + return false; + } var checkList = new List<string>(); foreach (MemberInfoRes infoRes in listInfo) { - if (checkList.Contains(infoRes.DistributedMark) == true) + if (checkList.Contains(infoRes.ChildAccountId) == true) { continue; } - checkList.Add(infoRes.DistributedMark); + checkList.Add(infoRes.ChildAccountId); listMenberInfo.Add(infoRes); } 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 @@ -317,37 +324,153 @@ /// 娣诲姞璁板綍琛� /// </summary> /// <param name="historyInfo">鍘嗗彶璁板綍</param> + /// <param name="dicName">鍚嶅瓧</param> /// <param name="addLine">娣诲姞搴曠嚎</param> - private void AddLogInfoRow(HistoryInfo historyInfo, bool addLine = true) + private void AddLogInfoRow(DoorHistoryLogInfo historyInfo, Dictionary<string, string> dicName, bool addLine = true) { var frameTable = new FrameRowControl(listView.rowSpace / 2); frameTable.UseClickStatu = false; - this.listView.AddChidren(frameTable); + this.listView.AddChidren2(frameTable); //鍥炬爣 var btnIcon = frameTable.AddLeftIcon(); - btnIcon.UnSelectedImagePath = "Item/PswSettionSelected.png"; - //淇℃伅 - var btnMsg = frameTable.AddLeftCaption("淇℃伅娴嬭瘯", 600, 60); - btnMsg.TextSize = 15; - //杩欎釜鍧愭爣鏈夌偣鐗规畩 - btnMsg.Y = Application.GetRealHeight(12) + frameTable.chidrenYaxis; - frameTable.AddChidren(btnMsg, ChidrenBindMode.NotBind); - + var btnMsg = frameTable.AddTopView("", 600); //浜虹墿 - var btnpersion = frameTable.AddLeftCaption("浜虹墿娴嬭瘯", 600, 50, true); - //杩欎釜鍧愭爣鏈夌偣鐗规畩 - btnpersion.Y = Application.GetRealHeight(72) + frameTable.chidrenYaxis; - btnpersion.TextSize = 12; - btnpersion.TextColor = UserCenterColor.Current.TextGrayColor1; - frameTable.AddChidren(btnpersion, ChidrenBindMode.NotBind); - + string perName = dicName.ContainsKey(historyInfo.UserId) == true ? dicName[historyInfo.UserId] : Language.StringByID(R.MyInternationalizationString.uOther); + frameTable.AddBottomView(perName, 600); //鏃堕棿 - frameTable.AddMostRightView("13:00:00", 200); + if (this.dateFromControl.dateValue == this.dateToControl.dateValue) + { + //濡傛灉鏃ユ湡鑼冨洿涓�鏍�,鍒欎笉鏄剧ず骞存湀鏃� + frameTable.AddMostRightView(HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(historyInfo.UnlockTime).ToString("HH:mm:ss"), 400); + } + else + { + //濡傛灉鏃ユ湡鑼冨洿涓嶄竴鏍�,鍒欐樉绀哄勾鏈堟棩 + frameTable.AddMostRightView(HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(historyInfo.UnlockTime).ToString("yyyy/MM/dd HH:mm:ss"), 700); + } + //搴曠嚎 if (addLine == true) { - //搴曠嚎 + frameTable.AddBottomLine(); + } + + //鍏朵粬娑堟伅 + if (historyInfo.UnLockMode == -1) + { + //鍥剧墖 + var device = HdlDeviceCommonLogic.Current.GetDevice(historyInfo.DeviceMac, historyInfo.DeviceEpoint); + if (device == null) + { + btnIcon.UnSelectedImagePath = "Device/IntelligentLocks.png"; + } + else + { + HdlDeviceCommonLogic.Current.SetDeviceIconToControl(btnIcon, device); + } + //娑堟伅 + btnMsg.Text = historyInfo.AlarmMsg; + } + //闂ㄩ攣甯稿紑妯″紡 + else if (historyInfo.UnLockMode == 9000) + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png"; + //杩欓噷鏄綉鍏虫垨鑰呴棬閿佽嚜宸辨帹閫� + btnMsg.Text = historyInfo.AlarmMsg; + } + //甯稿紑妯″紡鎵嬪姩寮�鍚� + else if (historyInfo.UnLockMode == 9001) + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png"; + btnMsg.TextID = R.MyInternationalizationString.uNormallyOpenModeManualOpen; + } + //甯稿紑妯″紡鎵嬪姩鍙栨秷 + else if (historyInfo.UnLockMode == 9002) + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png"; + btnMsg.TextID = R.MyInternationalizationString.uNormallyOpenModeManualClose; + } + //甯稿紑妯″紡鍚敤{0}灏忔椂 + else if (historyInfo.UnLockMode == 9003) + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png"; + btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uNormallyOpenModeOpenSomeTime).Replace("{0}", historyInfo.NormallyOpenContinuedTime); + } + //甯稿紑鑷姩鍖栨墜鍔ㄥ彇娑� + else if (historyInfo.UnLockMode == 9004) + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/NormallyOpen.png"; + btnMsg.Text = Language.StringByID(R.MyInternationalizationString.uNormallyOpenLogicManualClose); + } + //寮�閿佹垚鍔� + else if (historyInfo.IsUnlockSuccess == true) + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/UnLockSuccess.png"; + //娑堟伅 + if (historyInfo.UnLockMode == 0) + { + //瀵嗙爜寮�閿佹垚鍔� + btnMsg.TextID = R.MyInternationalizationString.uUnlockByPasswordSuccess; + } + else if (historyInfo.UnLockMode == 3) + { + //IC鍗″紑閿佹垚鍔� + btnMsg.TextID = R.MyInternationalizationString.uUnlockByICcardSuccess; + } + else if (historyInfo.UnLockMode == 13) + { + //闈欒剦绾瑰紑閿佹垚鍔� + btnMsg.TextID = R.MyInternationalizationString.uStriaVenosusUnLockSuccess; + } + else if (historyInfo.UnLockMode == 14) + { + //浜鸿劯璇嗗埆寮�閿佹垚鍔� + btnMsg.TextID = R.MyInternationalizationString.uFaceRecognitionUnLockSuccess; + } + else if (historyInfo.UnLockMode == 15) + { + //鎸囩汗寮�閿佹垚鍔� + btnMsg.TextID = R.MyInternationalizationString.uUnlockByFingerPrintSuccess; + } + } + //寮�閿佸け璐� + else + { + //鍥剧墖 + btnIcon.UnSelectedImagePath = "Item/UnLockFail.png"; + //娑堟伅 + if (historyInfo.UnLockMode == 0) + { + //瀵嗙爜寮�閿佸け璐� + btnMsg.TextID = R.MyInternationalizationString.uUnlockByPasswordFail; + } + else if (historyInfo.UnLockMode == 3) + { + //IC鍗″紑閿佸け璐� + btnMsg.TextID = R.MyInternationalizationString.uUnlockByICcardFail; + } + else if (historyInfo.UnLockMode == 13) + { + //闈欒剦绾瑰紑閿佸け璐� + btnMsg.TextID = R.MyInternationalizationString.uStriaVenosusUnLockFail; + } + else if (historyInfo.UnLockMode == 14) + { + //浜鸿劯璇嗗埆寮�閿佸け璐� + btnMsg.TextID = R.MyInternationalizationString.uFaceRecognitionUnLockFail; + } + else if (historyInfo.UnLockMode == 15) + { + //鎸囩汗寮�閿佸け璐� + btnMsg.TextID = R.MyInternationalizationString.uUnlockByFingerPrintFail; + } } } @@ -363,7 +486,7 @@ 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); + dic.Add(listMenberInfo[i].ChildAccountId, listMenberInfo[i].ShowName); } //鏄剧ず搴曢儴绫诲瀷绛涢�� var form = new DoorLockScreeningTypeForm(); @@ -375,8 +498,348 @@ listSearchLockId.Clear(); listSearchLockId.AddRange(selectLock); //鍒濆鍖栬褰曞垪琛� - this.InitLogListInfo(); + this.InitLogListInfo(false); }; + } + + #endregion + + #region 鈻� 绛涢�夎褰昣__________________________ + + /// <summary> + /// 绛涢�夊巻鍙茶褰� + /// </summary> + /// <returns></returns> + private List<DoorHistoryLogInfo> ScreeningHistoryData(Dictionary<string, string> dicMemberName) + { + //鍘嗗彶璁板綍澶夯鐑︿簡,瀛樺湪涓嶅悓鐨勬暟鎹簱琛ㄩ噷,骞朵笖鏁版嵁杩樹笉涓�鏍�,鍙兘杩欐牱涓�涓釜鍒ゆ柇浜� + var listScreeningData = new List<DoorHistoryLogInfo>(); + //娓呴櫎鎺変箣鍓嶇殑璁板綍 + 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(DoorHistoryLogInfo info, Dictionary<string, string> dicMemberName, + bool selectAllUser, bool selectOtherUser, bool slectAllLockMode) + { + //濡傛灉娌℃湁閫夋嫨 鍏ㄩ�夌敤鎴� + if (selectAllUser == false) + { + //濡傛灉杩欎釜鐢ㄦ埛ID涓嶅寘鍚湪鎸囧畾閫夋嫨鐨勬垚鍛樺垪琛ㄩ噷闈� + if (this.listSearchUserId.Contains(info.UserId) == false) + { + if (dicMemberName.ContainsKey(info.UserId) == true) + { + //濡傛灉鑳藉璇嗗埆杩欎釜id鐨勮瘽,鍒欒〃绀哄畠涓嶅睘浜庡叾浠栫被,骞朵笖涔熶笉鍐嶉�夋嫨鐩爣鍐� + return false; + } + //濡傛灉娌℃湁閫夋嫨 鍏朵粬鐨勮瘽,涓嶆樉绀� + if (selectOtherUser == false) + { + return false; + } + } + } + //濡傛灉鏄垚鍛樿韩浠�,骞朵笖鐢ㄦ埛ID涓嶄负绌� + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3 && info.UserId != string.Empty) + { + //鎴愬憳涓嶈兘鐪嬪埌 鍏朵粬浜虹殑璁板綍(鎴愬憳鐨勬椂鍊�,杩欎釜鍙橀噺閲岄潰鍙湁浠栬嚜宸变竴涓�) + if (dicMemberName.ContainsKey(info.UserId) == false) + { + return false; + } + } + //濡傛灉娌℃湁閫夋嫨 鍏ㄩ�夊紑閿佹柟寮� + if (slectAllLockMode == false) + { + //濡傛灉杩欎釜寮�閿佹柟寮忎笉鍦ㄩ�夋嫨鐨勫垪琛ㄩ噷闈㈢殑璇� + if (this.listSearchLockId.Contains(info.UnLockMode) == false) + { + return false; + } + } + + //鍙︿竴寮犺〃鐨勬暟鎹富閿� + if (info.UnLockMode == -1 || info.UnLockMode == 9000) + { + if (info.MsgKeyId != string.Empty) + { + //鍏朵粬娑堟伅鐨勪富閿�,瀹冨瓨鍦ㄥ彟澶栫殑涓�寮犳暟鎹簱琛ㄤ腑 + this.listOtherMsgId.Add(info.MsgKeyId); + } + } + + return true; + } + + #endregion + + #region 鈻� 鑾峰彇闂ㄩ攣鎵撳紑璁板綍___________________ + + /// <summary> + /// 鑾峰彇鍘嗗彶璁板綍 + /// </summary> + /// <returns></returns> + private List<DoorHistoryLogInfo> GetHistoryLogInfo(Dictionary<string, string> dicMemberName) + { + if (this.listHistoryInfo != null) + { + //涓嶄簩娆¤幏鍙�,涓昏閽堝鐨勬槸绛涢�夊姛鑳� + return this.ScreeningHistoryData(dicMemberName); + } + + var dateFrom = new DateTime(dateFromControl.Year, dateFromControl.Month, dateFromControl.Day, 0, 0, 0); + var dateTo = new DateTime(dateToControl.Year, dateToControl.Month, dateToControl.Day, 23, 59, 59); + + //鑾峰彇闂ㄩ攣鐨勬墦寮�鍜屽叧闂褰� + var listAllLog = HdlDeviceDoorLockLogic.Current.GetDoorHistoryLogInfo(this.GetDoorId(), dateFrom, dateTo); + + //鑾峰彇闂ㄩ攣鐨勫叾浠栬褰� + var listOtherLog = this.GetDoorOtherHistoryLog(dateFrom, dateTo); + listAllLog.AddRange(listOtherLog); + + //鎺掑簭涓�涓� + var dicAllData = new Dictionary<string, List<DoorHistoryLogInfo>>(); + var listSortTime = new List<string>(); + + foreach (var data in listAllLog) + { + //鎸夋椂闂村垎缁� + if (dicAllData.ContainsKey(data.UnlockTime) == false) + { + dicAllData[data.UnlockTime] = new List<DoorHistoryLogInfo>(); + listSortTime.Add(data.UnlockTime); + } + dicAllData[data.UnlockTime].Add(data); + } + + //鎵ц鎺掑簭,鏃堕棿澶х殑鍦ㄥ墠闈� + listSortTime.Sort(); + this.listHistoryInfo = new List<DoorHistoryLogInfo>(); + for (int i = listSortTime.Count - 1; i >= 0; i--) + { + this.listHistoryInfo.AddRange(dicAllData[listSortTime[i]]); + } + //绛涢�夊巻鍙茶褰� + return this.ScreeningHistoryData(dicMemberName); + } + + #endregion + + #region 鈻� 鑾峰彇闂ㄩ攣鍏朵粬璁板綍___________________ + + /// <summary> + /// 鑾峰彇闂ㄩ攣鐨勫叾浠栬褰� + /// </summary> + /// <returns></returns> + private List<DoorHistoryLogInfo> GetDoorOtherHistoryLog(DateTime beginTime, DateTime endTime) + { + var listLog = new List<DoorHistoryLogInfo>(); + //杞负utc鏃堕棿 + var utcFrom = beginTime.ToUniversalTime(); + var utcTo = endTime.ToUniversalTime(); + + //鍘诲彟涓�寮犺〃鍘昏幏鍙栧畠鐨勫叾浠栨秷鎭褰� + var listMsg = HdlMessageLogic.Current.GetListMessageFromDb(); + if (listMsg == null) + { + return listLog; + } + foreach (var msgInfo in listMsg) + { + //鏃堕棿涓嶆槸13浣嶇殑閮戒笉鐞� + if (msgInfo.CreateTime.Length != 13) { continue; } + //鑾峰彇闂ㄩ攣鍏朵粬绫讳俊鎭笂鎶� + if (msgInfo.MessageTitle == "/Alarms/SendAlarmInform") + { + //鍒ゆ柇鏄笉鏄繖涓椂闂存 + var checkDate = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(msgInfo.CreateTime); + if (utcFrom <= checkDate && checkDate <= utcTo) + { + this.AdjustDoorOtherAlarmData(ref listLog, msgInfo); + } + } + //浠庤嚜鍔ㄥ寲涓�,鑾峰彇甯稿紑妯″紡璁板綍 + else if (msgInfo.MessageTitle == "/Logic/Execute_Respon") + { + //鍒ゆ柇鏄笉鏄繖涓椂闂存 + var checkDate = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(msgInfo.CreateTime); + if (utcFrom <= checkDate && checkDate <= utcTo) + { + this.AdjustDoorNormallyOpenData(ref listLog, msgInfo); + } + } + //鑾峰彇闂ㄩ攣涓存椂瀵嗙爜寮�閿佽褰� + else if (msgInfo.MessageTitle == "/DoorLock/DoorLockOperatingEventNotificationCommand") + { + //鍒ゆ柇鏄笉鏄繖涓椂闂存 + var checkDate = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(msgInfo.CreateTime); + if (utcFrom <= checkDate && checkDate <= utcTo) + { + this.AdjustDoorTemporaryPasswordData(ref listLog, msgInfo); + } + } + } + + return listLog; + } + + /// <summary> + /// 澶勭悊闂ㄩ攣甯稿紑妯″紡璁板綍淇℃伅 + /// </summary> + /// <param name="listLog"></param> + /// <param name="i_msgData"></param> + private void AdjustDoorOtherAlarmData(ref List<DoorHistoryLogInfo> listLog, MessageRecordInfo i_msgData) + { + string doorKey = this.GetDoorId(); + //璁惧瀵硅薄 + var jobject = Newtonsoft.Json.Linq.JObject.Parse(i_msgData.MessageExpand); + string deviceAddr = jobject.Value<string>("DeviceAddr"); + int deviceEpoint = jobject.Value<int>("Epoint"); + if (doorKey != deviceAddr + "_" + deviceEpoint) + { + //涓嶆槸鍚屼竴涓棬閿佺殑璁板綍 + return; + } + + var data = new DoorHistoryLogInfo(); + 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 = i_msgData.CreateTime; + //涓婚敭 + data.MsgKeyId = i_msgData.Id; + //娑堟伅鍖哄垎 + if (msgInfo.MsgDiv == 9000) + { + data.UnLockMode = 9000; + } + listLog.Add(data); + } + + /// <summary> + /// 澶勭悊闂ㄩ攣甯稿紑妯″紡淇℃伅涓婃姤 + /// </summary> + /// <param name="listLog"></param> + /// <param name="i_msgData"></param> + private void AdjustDoorNormallyOpenData(ref List<DoorHistoryLogInfo> listLog, MessageRecordInfo i_msgData) + { + string doorKey = this.GetDoorId(); + var jobject = Newtonsoft.Json.Linq.JObject.Parse(i_msgData.MessageExpand); + var myActionData = Newtonsoft.Json.JsonConvert.DeserializeObject<LogicPushResult>(jobject["Data"].ToString()); + if (myActionData.ActionData == null || myActionData.ActionData.Actiontype != 8) + { + //涓嶆槸甯稿紑妯″紡鐨勮嚜鍔ㄥ寲 + return; + } + string deviceAddr = myActionData.ActionData.MacStr; + int deviceEpoint = myActionData.ActionData.Epoint; + if (doorKey != deviceAddr + "_" + deviceEpoint) + { + //涓嶆槸鍚屼竴涓棬閿佺殑璁板綍 + return; + } + + var data = new DoorHistoryLogInfo(); + 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 + { + return; + } + //鏃堕棿 + data.UnlockTime = i_msgData.CreateTime; + //涓婚敭 + data.MsgKeyId = i_msgData.Id; + //娑堟伅鍖哄垎 + data.UnLockMode = 9000; + + listLog.Add(data); + } + + /// <summary> + /// 澶勭悊闂ㄩ攣涓存椂瀵嗙爜涓婃姤 + /// </summary> + /// <param name="listLog"></param> + /// <param name="i_msgData"></param> + private void AdjustDoorTemporaryPasswordData(ref List<DoorHistoryLogInfo> listLog, MessageRecordInfo i_msgData) + { + string doorKey = this.GetDoorId(); + var jobject = Newtonsoft.Json.Linq.JObject.Parse(i_msgData.MessageExpand); + string deviceAddr = jobject.Value<string>("DeviceAddr"); + int deviceEpoint = jobject.Value<int>("Epoint"); + if (doorKey != deviceAddr + "_" + deviceEpoint) + { + //涓嶆槸鍚屼竴涓棬閿佺殑璁板綍 + return; + } + var myActionData = Newtonsoft.Json.JsonConvert.DeserializeObject<PasswordOperationData>(jobject["Data"].ToString()); + if (myActionData.UserID != 246) + { + //涓嶆槸涓存椂瀵嗙爜 + return; + } + var data = new DoorHistoryLogInfo(); + 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 = i_msgData.CreateTime; + //涓婚敭 + data.MsgKeyId = i_msgData.Id; + + listLog.Add(data); } #endregion @@ -386,21 +849,25 @@ /// <summary> /// 娓呯┖鎵�鏈夎褰� /// </summary> - private async void ClearAllHistoryLog() + private void ClearAllHistoryLog() { - //鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁� - var pra = this.GetDbInterfacePra(); + 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); //鎵撳紑杩涘害鏉� this.ShowProgressBar(); - var result = await UserCenterLogic.GetResultStatuByRequestHttps("App/ClearDoorLockHistory", false, pra); - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - if (result == false) + + //涓嶇缁撴灉 + var result = HdlDeviceDoorLockLogic.Current.ClearAllDoorHistoryLog(this.GetDoorId(), dateFrom, dateTo, listOtherMsgId); + + //娓呯┖ + this.listOtherMsgId = new List<string>(); + this.listHistoryInfo = null; + + HdlThreadLogic.Current.RunMain(() => { - return; - } - this.listView.RemoveAll(); - listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3); + //閲嶆柊鍒锋柊鐣岄潰 + this.InitLogListInfo(true); + }); } #endregion @@ -408,131 +875,35 @@ #region 鈻� 涓�鑸柟娉昣__________________________ /// <summary> - /// 鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁� + /// 鑾峰彇璁块棶浜戠鐨凞oorID /// </summary> /// <returns></returns> - private GetHistoryDataPra GetDbInterfacePra() + private string GetDoorId() { - 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 - { - listUser.AddRange(listSearchUserId); - } - - var listLock = new List<int>(); - if (listSearchLockId.Contains(-1) == true) - { - //鎵�鏈夊紑閿佹柟寮� - listLock = new List<int>() { 0, 15, 3 }; - } - else - { - listLock.AddRange(listSearchLockId); - } - - var pra = new GetHistoryDataPra(); - pra.DoorLockId = this.DeviceMac; - pra.CloudAccountId = listUser[0]; - pra.OpenLockMode = listLock[0]; - pra.UnlockTimeBegin = dateFrom; - pra.UnlockTimeEnd = dateTo; - return pra; + return this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint; } #endregion #region 鈻� 缁撴瀯浣揰____________________________ - /// <summary> - /// 鑾峰彇鍘嗗彶璁板綍鏁版嵁 - /// </summary> - private class GetHistoryDataPra - { - /// <summary> - /// RequestVersion - /// </summary> - public string RequestVersion = Common.CommonPage.RequestVersion; - /// <summary> - /// Token - /// </summary> - public string LoginAccessToken = Shared.Common.Config.Instance.Token; - /// <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 string CloudAccountId = string.Empty; - /// <summary> - /// 寮�閿佹柟寮�(0:瀵嗙爜銆�15:鎸囩汗銆�3:IC鍗�) - /// </summary> - public int OpenLockMode = -1; - /// <summary> - /// 寮�閿佹槸鍚︽垚鍔� - /// </summary> - public bool? UnlockIsSuccess = null; - /// <summary> - /// 鎼滅储寮�閿佸紑濮嬫椂闂� - /// </summary> - public DateTime UnlockTimeBegin; - /// <summary> - /// 鎼滅储寮�閿佺粨鏉熸椂闂� - /// </summary> - public DateTime UnlockTimeEnd; - /// <summary> - /// 椤垫暟 - /// </summary> - public PageSettingInfo PageSetting = new PageSettingInfo() { PageSize = 100 }; - } - /// <summary> - /// 鑾峰彇鍘嗗彶璁板綍鐨勭粨鏋� + /// 涓存椂瀵嗙爜鏁版嵁 /// </summary> - private class GetHistoryDataResult + private class PasswordOperationData { /// <summary> - /// 鏁版嵁 + /// 0:瀵嗙爜 15:鎸囩汗 3:IC鍗� /// </summary> - public List<HistoryInfo> PageData = null; + public int OperationEventSoure = -1; /// <summary> - /// 鏄惁瀛樺湪涓嬩竴椤电殑鏁版嵁 + /// 2:寮�閿佹垚鍔� /// </summary> - public bool HasNextPage = false; - } - - /// <summary> - /// 鍘嗗彶璁板綍鐨勭粨鏋� - /// </summary> - private class HistoryInfo - { + public int OperationEventCode = -1; /// <summary> - /// 寮�閿佹柟寮� + /// 246浠h〃涓存椂瀵嗙爜 /// </summary> - public int OpenLockMode = -1; - /// <summary> - /// 寮�閿佹椂闂� - /// </summary> - public string UnlockTime = string.Empty; - /// <summary> - /// 寮�閿佹槸鍚︽垚鍔� - /// </summary> - public bool UnlockIsSuccess = false; + public int UserID = -1; } #endregion -- Gitblit v1.8.0