From a39e669803d485caa354f0c6facde96905c0c44b Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 10 一月 2020 12:00:42 +0800
Subject: [PATCH] 2019.1.10
---
ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs | 278 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 192 insertions(+), 86 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs
index 8b5ba3c..aad8c36 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DoorLock/DoorLockHistoryLogForm.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
+using ZigBee.Device;
namespace Shared.Phone.UserCenter.DeviceDoorLock
{
@@ -15,7 +16,7 @@
/// <summary>
/// 鍒楄〃鎺т欢
/// </summary>
- private VerticalListControl listView = null;
+ private VerticalFrameRefreshControl listView = null;
/// <summary>
/// 鏃ユ湡From鎺т欢
/// </summary>
@@ -29,9 +30,9 @@
/// </summary>
private List<MemberInfoRes> listMenberInfo = null;
/// <summary>
- /// 璁惧鐨凪ac鍦板潃
+ /// 璁惧瀵硅薄
/// </summary>
- private string DeviceMac = string.Empty;
+ private CommonDevice DeviceDoor = null;
/// <summary>
/// 妫�绱㈠璞$殑ID(-1:鎵�鏈� 绌哄瓧绗︿覆:鍏朵粬)
/// </summary>
@@ -40,6 +41,10 @@
/// 妫�绱㈠紑閿佹柟寮忕殑ID(-1:鎵�鏈� 0:瀵嗙爜 15:鎸囩汗 3:IC鍗�)
/// </summary>
private List<int> listSearchLockId = new List<int>() { -1 };
+ /// <summary>
+ /// 鍏朵粬娑堟伅鐨勪富閿�
+ /// </summary>
+ private List<string> listOtherId = new List<string>();
#endregion
@@ -50,8 +55,8 @@
/// </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));
@@ -63,11 +68,11 @@
btnDelete.InitControl();
btnDelete.ButtonClickEvent += (sender, e) =>
{
- var form = new TopRightMenuControl(1, 449);
+ var form = new TopRightMenuControl(1, 2);
//娓呯┖璁板綍
form.AddRowMenu(Language.StringByID(R.MyInternationalizationString.uClearLog), "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
{
- if (this.listView.ChildrenCount == 0)
+ if (this.listView.frameTable.ChildrenCount == 0)
{
//鏃犳暟鎹彲鍒�
return;
@@ -94,15 +99,10 @@
this.ClearBodyFrame();
//鍒濆鍖栧ご閮ㄦ绱㈡帶浠�
- this.InitTitleSearchControl();
-
- //涓荤嚎绋嬬殑寮傛浼氶樆濉炰富绾跨▼,瀵艰嚧鐣岄潰鏈夋鏃堕棿浼氱櫧灞�,鎵�浠ヨ繖鏍峰瓙璁╃晫闈㈠厛鍑烘潵
- //鐒跺悗鍐嶅埛鏂版暟鎹�
- HdlThreadLogic.Current.RunMainInThread(() =>
- {
- //鍒濆鍖栬褰曞垪琛�
- this.InitLogListInfo();
- });
+ this.InitTitleSearchControl();
+
+ //鍒濆鍖栬褰曞垪琛�
+ this.InitLogListInfo();
}
/// <summary>
@@ -173,11 +173,16 @@
//搴曠嚎
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();
+ };
}
#endregion
@@ -187,10 +192,10 @@
/// <summary>
/// 鍒濆鍖栬褰曞垪琛�
/// </summary>
- private async void InitLogListInfo()
+ private void InitLogListInfo()
{
- 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))
@@ -199,51 +204,52 @@
this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uFromTimeIsOverToTime));
return;
}
- //鎵撳紑杩涘害鏉�
- this.ShowProgressBar();
- //鎴愬憳鍒楄〃
- var result = await this.GetMemberListInfo();
- if (result == false)
+ HdlThreadLogic.Current.RunThread(async () =>
{
+ //鎵撳紑杩涘害鏉�
+ this.ShowProgressBar();
+ //鎴愬憳鍒楄〃
+ var result = await this.GetMemberListInfo();
+ if (result == false)
+ {
+ //鍏抽棴杩涘害鏉�
+ this.CloseProgressBar(ShowReLoadMode.YES);
+ return;
+ }
+ //鍘嗗彶璁板綍
+ var historyLog = await this.GetHistoryLogInfo();
+ 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);
- }
+ 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);
+ }
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ for (int i = 0; i < historyLog.Count; i++)
+ {
+ //娣诲姞璁板綍琛�
+ this.AddLogInfoRow(historyLog[i], dic, 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>
@@ -306,10 +312,23 @@
{
var frameTable = new FrameRowControl(listView.rowSpace / 2);
frameTable.UseClickStatu = false;
- this.listView.AddChidren(frameTable);
+ this.listView.AddChidrenFrame2(frameTable);
//鍥炬爣
var btnIcon = frameTable.AddLeftIcon();
- 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);
+ }
+ }
+ else if (historyInfo.UnlockIsSuccess == true)
{
btnIcon.UnSelectedImagePath = "Item/UnLockSuccess.png";
}
@@ -319,12 +338,13 @@
}
//淇℃伅
- 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)
+ var btnMsg = frameTable.AddTopView("", 600);
+ if (historyInfo.OpenLockMode == -1)
+ {
+ //鍏朵粬娑堟伅
+ btnMsg.Text = historyInfo.AlarmMsg;
+ }
+ else if (historyInfo.UnlockIsSuccess == true)
{
if (historyInfo.OpenLockMode == 0)
{
@@ -363,15 +383,20 @@
//浜虹墿
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);
+ var btnpersion = frameTable.AddBottomView(perName, 600);
//鏃堕棿
- frameTable.AddMostRightView(historyInfo.UnlockTime, 400);
+ if (this.dateFromControl.dateValue == this.dateToControl.dateValue)
+ {
+ //濡傛灉鏃ユ湡鑼冨洿涓�鏍�,鍒欎笉鏄剧ず骞存湀鏃�
+ frameTable.AddMostRightView(Convert.ToDateTime(historyInfo.UnlockTime).ToString("HH:mm:ss"), 400);
+ }
+ else
+ {
+ //濡傛灉鏃ユ湡鑼冨洿涓嶄竴鏍�,鍒欐樉绀哄勾鏈堟棩
+ frameTable.AddMostRightView(Convert.ToDateTime(historyInfo.UnlockTime).ToString("yyyy/MM/dd HH:mm:ss"), 700);
+ }
+
if (addLine == true)
{
//搴曠嚎
@@ -415,7 +440,7 @@
/// 鑾峰彇鍘嗗彶璁板綍
/// </summary>
/// <returns></returns>
- private async Task<List<HistoryInfo>> GetHistoryLogInf()
+ private async Task<List<HistoryInfo>> GetHistoryLogInfo()
{
//鑾峰彇璁块棶浜戠鎺ュ彛鐨勫惎鍔ㄥ弬鏁�
var pra = this.GetDbInterfacePra();
@@ -431,6 +456,7 @@
return null;
}
var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetHistoryDataResult>(result);
+ listLog.AddRange(dataInfo.PageData);
if (dataInfo.HasNextPage == false)
{
break;
@@ -443,8 +469,47 @@
//鎺掑簭涓�涓�
var dic = new Dictionary<string, List<HistoryInfo>>();
var listSort = new List<string>();
+ //娓呯┖涓婁竴娆$殑鍏朵粬ID
+ this.listOtherId = new List<string>();
//鏄惁鍖呭惈鍏朵粬
bool flage = this.listSearchUserId.Contains("") || this.listSearchUserId.Contains("-1");
+ if (flage == true)
+ {
+ //鍘昏幏鍙栧叾浠栦俊鎭�
+ var pra2 = new MessageInfoPra();
+ pra2.BeginTime = pra.UnlockTimeBegin;
+ pra2.EndTime = pra.UnlockTimeEnd;
+ pra2.Topic = "/Alarms/SendAlarmInform";
+ pra2.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+ var result = await UserCenterLogic.GetResponseDataByRequestHttps("MessageCenter/GetMessageCenterPagger", true, pra2);
+ if (result == null)
+ {
+ return null;
+ }
+ var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageCentetInfo>(result);
+ foreach (var myInfo in dataInfo.PageData)
+ {
+ var data = new HistoryInfo();
+ if (dic.ContainsKey(myInfo.CreatedOnUtc) == false)
+ {
+ dic[myInfo.CreatedOnUtc] = new List<HistoryInfo>();
+ listSort.Add(myInfo.CreatedOnUtc);
+ }
+
+ //璁惧瀵硅薄
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(myInfo.PayloadJson);
+ data.DeviceMac = jobject.Value<string>("DeviceAddr");
+ data.DeviceEpoint = jobject.Value<int>("Epoint");
+ //娑堟伅
+ var msgInfo = HdlAlarmsLogic.Current.GetDoorLockAlarmInfo(jobject);
+ data.AlarmMsg = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered);
+ dic[myInfo.CreatedOnUtc].Add(data);
+ //鏃堕棿
+ data.UnlockTime = myInfo.CreatedOnUtc;
+
+ this.listOtherId.Add(myInfo.Id);
+ }
+ }
foreach (var data in listLog)
{
if (flage == false && string.IsNullOrEmpty(data.CloudAccountId) == true)
@@ -485,14 +550,37 @@
//鎵撳紑杩涘害鏉�
this.ShowProgressBar();
var result = await UserCenterLogic.GetResultStatuByRequestHttps("DoorLock/ClearDoorLockHistory", true, pra);
+ if (result == false)
+ {
+ return;
+ }
+
+ //鍒犻櫎鍏朵粬娑堟伅
+ if (listOtherId.Count > 0)
+ {
+ var pra2 = new MessageReadStatuPra();
+ pra2.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
+ for (int i = 0; i < listOtherId.Count; i++)
+ {
+ pra2.Id = listOtherId[i];
+ result = await UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/DelMessageCenterItem", true, pra);
+ if (result == false)
+ {
+ return;
+ }
+ }
+ }
//鍏抽棴杩涘害鏉�
this.CloseProgressBar();
if (result == false)
{
return;
}
- this.listView.RemoveAll();
- listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3);
+ this.listView.frameTable.RemoveAll();
+ listView.frameTable.Height = bodyFrameLayout.Height - Application.GetRealHeight(115 - 3);
+
+ //娓呯┖
+ this.listOtherId = new List<string>();
}
#endregion
@@ -510,7 +598,13 @@
//鍏ㄩ�夊垯涓簄ull
List<string> listUser = null;
- if (listSearchUserId.Contains("-1") == false)
+ if (listSearchUserId.Count == 1 && listSearchUserId[0] == "")
+ {
+ //濡傛灉鍗曠函鐨勫彧鏄�夋嫨鍏朵粬,鍒欒妫�绱㈡潯浠朵笉鎴愮珛鍗冲彲
+ listUser = new List<string>();
+ listUser.Add("鍏朵粬");
+ }
+ else if (listSearchUserId.Contains("-1") == false)
{
listUser = new List<string>();
listUser.AddRange(listSearchUserId);
@@ -528,11 +622,11 @@
var pra = new GetHistoryDataPra();
pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
- pra.DoorLockId = this.DeviceMac;
+ pra.DoorLockId = this.DeviceDoor.DeviceAddr + "_" + this.DeviceDoor.DeviceEpoint;
pra.CloudAccountIdArr = listUser;
pra.OpenLockModeArr = listLock;
- pra.UnlockTimeBegin = dateFrom;
- pra.UnlockTimeEnd = dateTo;
+ pra.UnlockTimeBegin = dateFrom.ToString();
+ pra.UnlockTimeEnd = dateTo.ToString();
return pra;
}
@@ -576,11 +670,11 @@
/// <summary>
/// 鎼滅储寮�閿佸紑濮嬫椂闂�
/// </summary>
- public DateTime UnlockTimeBegin;
+ public string UnlockTimeBegin;
/// <summary>
/// 鎼滅储寮�閿佺粨鏉熸椂闂�
/// </summary>
- public DateTime UnlockTimeEnd;
+ public string UnlockTimeEnd;
/// <summary>
/// 椤垫暟
/// </summary>
@@ -623,6 +717,18 @@
/// 璐﹀彿鐨処D
/// </summary>
public string CloudAccountId = 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;
}
#endregion
--
Gitblit v1.8.0