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/UserMain/MessageManagementForm.cs | 676 ++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 528 insertions(+), 148 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs index 7197147..5388ddd 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs @@ -1,6 +1,9 @@ -锘縰sing System; +锘縰sing Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; +using ZigBee.Device; namespace Shared.Phone.UserCenter.UserMain { @@ -16,7 +19,7 @@ /// </summary> private VerticalFrameRefreshControl listView = null; /// <summary> - /// 鍏ㄩ儴鐨勮 + /// 鍏ㄩ儴鐨勮,涓婚敭鏄嚜鍔ㄩ�掑鐨勪笢瑗� /// </summary> private Dictionary<string, RowLayoutControl> dicAllRow = null; @@ -29,6 +32,11 @@ /// </summary> public void ShowForm() { + //宸︽粦浣胯兘 + this.ScrollEnabled = false; + + Common.CommonPage.Instance.IsDrawerLockMode = true; + //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uMessageCenter)); @@ -60,74 +68,138 @@ /// <summary> /// 鍒濆鍖栦腑閮ㄤ俊鎭� /// </summary> - private async void InitMiddleData(bool showReload) + private void InitMiddleData(bool showReload) { //鑾峰彇鏁版嵁 - var dicData = await this.GetMessageData(); - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(dicData == null && showReload == true ? ShowReLoadMode.YES : ShowReLoadMode.NO); - - HdlThreadLogic.Current.RunMain(() => - { - //鍏抽棴鍒锋柊鐗规晥 - listView?.EndHeaderRefreshing(); - }); + var dicData = this.GetMessageData(); if (dicData == null) { + if (showReload == true) + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(ShowReLoadMode.YES); + } + else + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + } + HdlThreadLogic.Current.RunMain(() => + { + //鍏抽棴鍒锋柊鐗规晥 + listView?.EndHeaderRefreshing(); + //娓呯┖ + listView.RemoveAll(); + }); //鏁版嵁寮傚父 return; } + if (this.Parent == null) + { + return; + } + HdlThreadLogic.Current.RunMain(() => { - //鍒濆鍖栦腑閮ㄦ帶浠� - this.InitMiddleFrame(dicData); + //娓呯┖ + listView.RemoveAll(); }); + if (dicData.Count == 0) + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + HdlThreadLogic.Current.RunMain(() => + { + //鍏抽棴鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + listView.frameTable.Height = listView.Height; + }); + return; + } + //鍒濆鍖栦腑閮ㄦ帶浠� + this.InitMiddleFrame(dicData); } /// <summary> - /// 鍒濆鍖栦腑閮ㄦ帶浠� + /// 鍒濆鍖栦腑閮ㄦ帶浠�(瑕佷娇鐢ㄧ嚎绋嬭皟鐢�) /// </summary> /// <param name="dicData"></param> - private void InitMiddleFrame(Dictionary<string, List<MessageRecordInfo>> dicData) + private void InitMiddleFrame(Dictionary<string, List<List<MessageRecordInfo>>> dicData) { - //娓呯┖ - listView.RemoveAll(); + int dateIndex = 0; + FrameListControl framBack = null; + string oldKeys = string.Empty; - int index = 0; + int maxCount = 0; + int countIndex = 0; + foreach (var data in dicData.Values) + { + //鑾峰彇寰幆鐨勬�绘鏁� + maxCount += data.Count; + } + + int waiTime = 500; foreach (var keys in dicData.Keys) { - var listData = dicData[keys]; - index++; - //瀹瑰櫒 - var framBack = new FrameListControl(23); - framBack.Name = index.ToString(); - framBack.Height = Application.GetRealHeight(100); - framBack.BackgroundColor = UserCenterColor.Current.White; - listView.AddChidrenFrame(framBack); - - //鏃ユ湡 - string strMonth = Language.StringByID(R.MyInternationalizationString.Month); - string strDate = Language.StringByID(R.MyInternationalizationString.Day); - var frameDate = new FrameLayout(); - frameDate.Height = Application.GetRealHeight(118); - framBack.AddChidren(frameDate); - var btnDate = new NormalViewControl(500, 60, true); - btnDate.TextSize = 15; - btnDate.X = ControlCommonResourse.XXLeft; - btnDate.Y = Application.GetRealHeight(35); - btnDate.Text = Convert.ToDateTime(listData[0].MsgTime).ToString("MM" + strMonth + "dd" + strDate); - frameDate.AddChidren(btnDate); - - for (int i = 0; i < listData.Count; i++) + var listGroup = dicData[keys]; + foreach (var listData in listGroup) { - //娣诲姞淇℃伅琛� - this.AddMsgRowControl(framBack, listData[i], i != listData.Count - 1); - } - //璋冩暣楂樺害 - listView.AdjustChidrenFrameHeight(framBack, Application.GetRealHeight(23)); - if (index == dicData.Count) - { - listView.AdjustTableHeight(); + HdlThreadLogic.Current.RunMain(() => + { + countIndex++; + //褰撴棩鏈熶笉涓�鏍锋椂,閲嶆柊寤虹珛妗屽竷 + if (oldKeys != keys) + { + oldKeys = keys; + dateIndex++; + //瀹瑰櫒 + framBack = new FrameListControl(23); + framBack.Name = dateIndex.ToString(); + framBack.Height = Application.GetRealHeight(100); + framBack.BackgroundColor = UserCenterColor.Current.White; + listView.AddChidren(framBack); + + //鏃ユ湡 + string strMonth = Language.StringByID(R.MyInternationalizationString.Month); + string strDate = Language.StringByID(R.MyInternationalizationString.Day); + var frameDate = new FrameLayout(); + frameDate.Height = Application.GetRealHeight(118); + framBack.AddChidren(frameDate); + var btnDate = new NormalViewControl(500, 60, true); + btnDate.TextSize = 15; + btnDate.X = HdlControlResourse.XXLeft; + btnDate.Y = Application.GetRealHeight(35); + btnDate.Text = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(listGroup[0][0].CreateTime).ToString("MM" + strMonth + "dd" + strDate); + frameDate.AddChidren(btnDate); + } + + for (int i = 0; i < listData.Count; i++) + { + //涓�鏉′俊鎭噷闈紝瀹冨彲鑳藉寘鍚涓姤璀� + for (int j = 0; j < listData[i].listMsg.Count; j++) + { + //璁剧疆宸茶鐨勫垵濮嬪�� + listData[i].ListReading.Add(listData[i].IsRead); + //娣诲姞淇℃伅琛� + bool addLine = i != listData.Count - 1 || j != listData[i].listMsg.Count - 1; + this.AddMsgRowControl(framBack, listData[i], j, addLine); + } + } + //璋冩暣楂樺害 + listView.AdjustChidrenFrameHeight(framBack, Application.GetRealHeight(23)); + if (countIndex == maxCount) + { + //璋冩暣妗屽竷 + listView.AdjustTableHeight(); + //鍏抽棴鍒锋柊鐗规晥 + listView.EndHeaderRefreshing(); + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + } + }); + //绗竴娆$殑鏃跺�欙紝绛夊緟鐨勬椂鍊欎箙涓�鐐� + System.Threading.Thread.Sleep(waiTime); + waiTime = 300; } } } @@ -157,20 +229,25 @@ /// </summary> private void ShowBottomMenu() { + bool authority = HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2; + var menuContr = new BottomMenuSelectForm(); - menuContr.AddForm(2); + menuContr.AddForm(authority == true ? 2 : 1); //鍏ㄩ儴宸茶 menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uAllRead), () => { //璁剧疆鍏ㄩ儴涓哄凡璇� this.SetAllTickIsRead(); }); - //鍏ㄩ儴鍒犻櫎 - menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uAllDelete), () => + if (authority == true) { - //鍒犻櫎鍏ㄩ儴鐨勬秷鎭� - this.DeleteAllMsg(); - }); + //鍏ㄩ儴鍒犻櫎 + menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uAllDelete), () => + { + //鍒犻櫎鍏ㄩ儴鐨勬秷鎭� + this.DeleteAllMsg(); + }); + } } #endregion @@ -182,8 +259,9 @@ /// </summary> /// <param name="frameList"></param> /// <param name="recordInfo"></param> + /// <param name="msgIndex">鎶ヨ娑堟伅鐨勪笅鏍�</param> /// <param name="addLine"></param> - private void AddMsgRowControl(FrameListControl frameList, MessageRecordInfo recordInfo, bool addLine) + private void AddMsgRowControl(FrameListControl frameList, MessageRecordInfo recordInfo, int msgIndex, bool addLine) { var rowControl = new RowLayoutControl(frameList.rowSpace / 2); frameList.AddChidren(rowControl); @@ -191,40 +269,31 @@ rowControl.MainKeys = recordInfo.Id; this.dicAllRow[frameList.Name + "-" + rowControl.Name] = rowControl; - //鍥炬爣(鐜板湪娴嬭瘯) + //鍥炬爣 var btnIcon = rowControl.frameTable.AddLeftIcon(81); - btnIcon.UnSelectedImagePath = "Item/Safety.png"; - + btnIcon.UnSelectedImagePath = recordInfo.IconPath; //娑堟伅绫诲瀷 - var btnMsgObject = rowControl.frameTable.AddLeftCaption("鎶ヨ娑堟伅", 600); - PicViewControl btnNewTip = null; - if (recordInfo.IsRead == 0) - { - btnNewTip = new PicViewControl(78, 55); - btnNewTip.UnSelectedImagePath = "Item/NewVersion.png"; - btnNewTip.Y = Application.GetRealHeight(9) + rowControl.frameTable.chidrenYaxis; - btnNewTip.X = btnMsgObject.X + btnMsgObject.GetRealWidthByText(14); - rowControl.frameTable.AddChidren(btnNewTip, ChidrenBindMode.BindEventOnly); - } + var btnMsgObject = rowControl.frameTable.AddLeftCaption(recordInfo.MsgObjectText, 600); //娑堟伅 - var btnMsg = rowControl.frameTable.AddMostRightView(recordInfo.MsgContent, 600, 60); + var btnMsg = rowControl.frameTable.AddMostRightView(recordInfo.listMsg[msgIndex], 600, 60); btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3; btnMsg.Y = Application.GetRealHeight(5) + rowControl.frameTable.chidrenYaxis; - rowControl.frameTable.AddChidren(btnMsg, ChidrenBindMode.BindEventOnly); + rowControl.frameTable.AddChidren(btnMsg, ChidrenBindMode.BindEvent); //鏃堕棿 - var btnTime = rowControl.frameTable.AddMostRightView(recordInfo.MsgContent, 200, 50); + var btnTime = rowControl.frameTable.AddMostRightView("", 200, 50); btnTime.TextColor = UserCenterColor.Current.TextGrayColor1; btnTime.Y = btnMsg.Bottom + Application.GetRealHeight(12); - btnTime.Text = Convert.ToDateTime(recordInfo.MsgTime).ToString("HH锛歮m"); - rowControl.frameTable.AddChidren(btnTime, ChidrenBindMode.BindEventOnly); + var convertTime = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(recordInfo.CreateTime); + btnTime.Text = convertTime.ToString("HH锛歮m"); + rowControl.frameTable.AddChidren(btnTime, ChidrenBindMode.BindEvent); //搴曠嚎 if (addLine == true) { rowControl.frameTable.AddBottomLine(); } //宸茶 - if (recordInfo.IsRead == 1) + if (recordInfo.ListReading[msgIndex] == true) { rowControl.frameTable.UseClickStatu = false; //娑堟伅绫诲瀷 @@ -232,26 +301,44 @@ //娑堟伅 btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; } - //鍒犻櫎 - var btnDelete = rowControl.AddDeleteControl(); - btnDelete.ButtonClickEvent += (sender, e) => + //璋冩暣瀹藉害 + btnMsgObject.Width = btnMsgObject.GetRealWidthByText(); + + //鏂版秷鎭� + PicViewControl btnNewTip = null; + if (recordInfo.ListReading[msgIndex] == false) { - //纭鍒犻櫎娑堟伅? - string msg = Language.StringByID(R.MyInternationalizationString.uDeleteMessageMsg); - this.ShowMassage(ShowMsgType.Confirm, msg, async () => + btnNewTip = new PicViewControl(78, 55); + btnNewTip.UnSelectedImagePath = "Item/NewVersion.png"; + btnNewTip.Y = Application.GetRealHeight(9) + rowControl.frameTable.chidrenYaxis; + btnNewTip.X = btnMsgObject.Right + Application.GetRealWidth(10); + rowControl.frameTable.AddChidren(btnNewTip, ChidrenBindMode.BindEvent); + } + + //涓昏涓讳汉鍜岀鐞嗗憳鑳藉鍒犻櫎 + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1 || HdlUserCenterResourse.ResidenceOption.AuthorityNo == 2) + { + //鍒犻櫎 + var btnDelete = rowControl.AddDeleteControl(); + btnDelete.ButtonClickEvent += (sender, e) => { - await this.DeleteMsg(recordInfo.Id, frameList, rowControl); - }); - }; + //纭鍒犻櫎娑堟伅? + string msg = Language.StringByID(R.MyInternationalizationString.uDeleteMessageMsg); + this.ShowMassage(ShowMsgType.Confirm, msg, () => + { + this.DeleteMsg(recordInfo.Id, frameList, rowControl); + }); + }; + } //鐐瑰嚮 - rowControl.frameTable.ButtonClickEvent += async (sender, e) => + rowControl.frameTable.ButtonClickEvent += (sender, e) => { - if (recordInfo.IsRead == 1) + if (recordInfo.ListReading[msgIndex] == true) { return; } - recordInfo.IsRead = 1; + recordInfo.ListReading[msgIndex] = true; rowControl.frameTable.UseClickStatu = false; //娑堟伅绫诲瀷 btnMsgObject.TextColor = UserCenterColor.Current.TextGrayColor1; @@ -261,7 +348,7 @@ if (sender != null) { //鏍囪宸茶(涓嶇瀹冩垚鍔熶笉鎴愬姛) - await this.SetTickIsRead(recordInfo.Id); + this.SetTickIsRead(recordInfo.Id); } }; } @@ -274,17 +361,9 @@ /// 鏍囪宸茶 /// </summary> /// <param name="strId"></param> - private async System.Threading.Tasks.Task<bool> SetTickIsRead(string strId) + private bool SetTickIsRead(string strId) { - string strUrl = "ZigbeeUsers/TickIsRead?Id=" + strId; - - var result = await Common.CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync(strUrl, null, "GET"); - if (result == null) - { - return UserCenterLogic.CheckNotEorrorMsg(null, "ZigbeeUsers/TickIsRead", null, null); - } - //浜戠鏄笉浼氳繑鍥炰笢瑗跨殑 - return true; + return HdlMessageLogic.Current.SetTickIsRead(strId); } /// <summary> @@ -299,23 +378,19 @@ //纭鏍囪鍏ㄩ儴娑堟伅涓哄凡璇�? this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uUnTipAllMessageMsg), () => { - HdlThreadLogic.Current.RunThread(async () => + HdlThreadLogic.Current.RunThread(() => { //鎵撳紑杩涘害鏉� this.ShowProgressBar(); - foreach (var contr in this.dicAllRow.Values) - { - //鏍囪瘑鍏ㄩ儴涓哄凡璇� - var result = await this.SetTickIsRead(contr.MainKeys); - if (result == false) - { - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - return; - } - } + + var result = HdlMessageLogic.Current.SetAllTickIsRead(); + //鍏抽棴杩涘害鏉� this.CloseProgressBar(); + if (result == false) + { + return; + } HdlThreadLogic.Current.RunMain(() => { @@ -339,15 +414,14 @@ /// <param name="strId"></param> /// <param name="frameList"></param> /// <param name="rowContr"></param> - private async System.Threading.Tasks.Task<bool> DeleteMsg(string strId, FrameListControl frameList, RowLayoutControl rowContr) + private bool DeleteMsg(string strId, FrameListControl frameList, RowLayoutControl rowContr) { - string strUrl = "ZigbeeUsers/DeletePushMessage?Id=" + strId; - - var result = await Common.CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync(strUrl, null, "GET"); - if (result == null) + var result = HdlMessageLogic.Current.DeleteCloundMessage(strId); + if (result == false) { - return UserCenterLogic.CheckNotEorrorMsg(null, "ZigbeeUsers/DeletePushMessage", null, null); + return false; } + //浜戠鏄笉浼氳繑鍥炰笢瑗跨殑 if (frameList != null) { @@ -374,20 +448,17 @@ //纭鍒犻櫎鍏ㄩ儴娑堟伅? this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uDeleteAllMessageMsg), () => { - HdlThreadLogic.Current.RunThread(async () => + HdlThreadLogic.Current.RunThread(() => { //鎵撳紑杩涘害鏉� this.ShowProgressBar(); - foreach (var contr in this.dicAllRow.Values) + + var result = HdlMessageLogic.Current.DeleteAllCloundMessage(); + if (result == false) { - //鍒犻櫎鍏ㄩ儴娑堟伅 - var result = await this.DeleteMsg(contr.MainKeys, null, null); - if (result == false) - { - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - return; - } + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(); + return; } //鍒濆鍖栦腑閮ㄤ俊鎭� this.InitMiddleData(true); @@ -469,62 +540,371 @@ /// 鑾峰彇娑堟伅璁板綍 /// </summary> /// <returns></returns> - private async System.Threading.Tasks.Task<Dictionary<string, List<MessageRecordInfo>>> GetMessageData() + private Dictionary<string, List<List<MessageRecordInfo>>> GetMessageData() { this.dicAllRow = new Dictionary<string, RowLayoutControl>(); - var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetPushMessageRecord", false, ""); - if (result == null) + var listData = new List<MessageRecordInfo>(); + var listMsg = HdlMessageLogic.Current.GetListMessageFromDb(); + if (listMsg == null) { - return null; + return new Dictionary<string, List<List<MessageRecordInfo>>>(); } - var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MessageRecordInfo>>(result); + + for (int i = 0; i < listMsg.Count; i++) + { + try + { + var data = listMsg[i]; + //澶勭悊娑堟伅绫诲瀷 + if (this.AdjustMsgContent(ref data) == true) + { + listData.Add(data); + } + } + catch { continue; } + } + //鍚堝苟鏁版嵁 - return this.MergeMessageRecordData(dataInfo); + return this.MergeMessageRecordData(listData); } /// <summary> - /// 鍚堝苟鏁版嵁 + /// 鍚堝苟鏁版嵁(鍚屼竴澶╀箣鍐�,浼氬垎缁�) /// </summary> /// <param name="dataInfo"></param> /// <returns></returns> - private Dictionary<string, List<MessageRecordInfo>> MergeMessageRecordData(List<MessageRecordInfo> dataInfo) + private Dictionary<string, List<List<MessageRecordInfo>>> MergeMessageRecordData(List<MessageRecordInfo> dataInfo) { - var dicData = new Dictionary<string, List<MessageRecordInfo>>(); + var dicData = new Dictionary<string, List<List<MessageRecordInfo>>>(); //棣栧厛鍏堟帓搴忎竴涓�,鏃堕棿澶х殑鏀惧湪鍓嶉潰 var dicTemp = new Dictionary<string, List<MessageRecordInfo>>(); var listSortKeys = new List<string>(); foreach (var data in dataInfo) { - if (dicTemp.ContainsKey(data.MsgTime) == false) + if (dicTemp.ContainsKey(data.CreateTime) == false) { - dicTemp[data.MsgTime] = new List<MessageRecordInfo>(); - listSortKeys.Add(data.MsgTime); + dicTemp[data.CreateTime] = new List<MessageRecordInfo>(); + listSortKeys.Add(data.CreateTime); } - dicTemp[data.MsgTime].Add(data); + dicTemp[data.CreateTime].Add(data); } listSortKeys.Sort(); + + var listGroup = new List<MessageRecordInfo>(); for (int i = listSortKeys.Count - 1; i >= 0; i--) { var listData = dicTemp[listSortKeys[i]]; foreach (var data2 in listData) { - string[] myArry = data2.MsgTime.Split(new string[] { "T" }, StringSplitOptions.RemoveEmptyEntries); - if (myArry.Length != 2) + try { - continue; + if (data2.MessageTitle == "/DoorLock/DoorLockOperatingEventNotificationCommand") + { + //鏆傛椂涓嶅鐞嗚繖涓富棰� + continue; + } + string strDay = HdlCommonLogic.Current.ConvertUtcTimeToLocalTime2(data2.CreateTime).ToString("yyyy/MM/dd"); + //鎸夋瘡澶╁垎缁� + if (dicData.ContainsKey(strDay) == false) + { + listGroup = new List<MessageRecordInfo>(); + dicData[strDay] = new List<List<MessageRecordInfo>>(); + dicData[strDay].Add(listGroup); + } + if (listGroup.Count > 20) + { + //姣�20涓竴缁� + listGroup = new List<MessageRecordInfo>(); + dicData[strDay].Add(listGroup); + } + listGroup.Add(data2); } - if (dicData.ContainsKey(myArry[0]) == false) - { - dicData[myArry[0]] = new List<MessageRecordInfo>(); - } - dicData[myArry[0]].Add(data2); + catch { } } } return dicData; } #endregion + + #region 鈻� 澶勭悊娑堟伅绫诲瀷_______________________ + + /// <summary> + /// 澶勭悊娑堟伅绫诲瀷 + /// </summary> + /// <param name="recordInfo">娑堟伅鏁版嵁</param> + private bool AdjustMsgContent(ref MessageRecordInfo recordInfo) + { + //浼犳劅鍣ㄤ笂鎶� + if (recordInfo.MessageTitle == "/IASInfoReport") + { + var jobject = JObject.Parse(recordInfo.MessageExpand); + this.SensorDeviceReportPush(jobject, ref recordInfo); + } + //闂ㄩ攣涓婃姤 + else if (recordInfo.MessageTitle == "/Alarms/SendAlarmInform") + { + var jobject = JObject.Parse(recordInfo.MessageExpand); + this.DoorLockDeviceReportPush(jobject, ref recordInfo); + } + //鎾ら槻 + else if (recordInfo.MessageTitle == "/Security/WithdrawMode_Respon") + { + var jobject = JObject.Parse(recordInfo.MessageExpand); + this.RemoveSafetyGarrisonPush(jobject, ref recordInfo); + } + //甯冮槻 + else if (recordInfo.MessageTitle == "/Security/EnableMode_Respon") + { + var jobject = JObject.Parse(recordInfo.MessageExpand); + this.SetSafetyGarrisonPush(jobject, ref recordInfo); + } + //閫昏緫瑙﹀彂涓婃姤 + else if (recordInfo.MessageTitle == "/Logic/Execute_Respon") + { + var jobject = JObject.Parse(recordInfo.MessageExpand); + this.LogicExecutePush(jobject, ref recordInfo); + } + //鍦烘櫙瑙﹀彂涓婃姤 + else if (recordInfo.MessageTitle == "/Scene/Exec_Respon") + { + var jobject = JObject.Parse(recordInfo.MessageExpand); + this.SceneExecPush(jobject, ref recordInfo); + } + else + { + //涓嶅鐞嗙殑涓婚 + return false; + } + return true; + } + + #endregion + + #region 鈻� 浼犳劅鍣ㄤ笂鎶________________________ + + /// <summary> + /// 浼犳劅鍣ㄨ澶囦笂鎶� + /// </summary> + /// <param name="receiveData"></param> + private bool SensorDeviceReportPush(JObject receiveData, ref MessageRecordInfo recordInfo) + { + var ias = new IASZone() { DeviceAddr = receiveData.Value<string>("DeviceAddr"), DeviceEpoint = receiveData.Value<int>("Epoint") }; + ias.iASInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.IASInfoData>(receiveData["Data"].ToString()); + //鍥炬爣 + var localDevice = HdlDeviceCommonLogic.Current.GetDevice(ias.DeviceAddr, ias.DeviceEpoint); + if (localDevice == null) + { + recordInfo.IconPath = "Device/Sensor.png"; + //娑堟伅绫诲瀷:浼犳劅鍣� + var infoContent = HdlDeviceCommonLogic.Current.GetDeviceModelIdNameInfo("A402"); + recordInfo.MsgObjectText = infoContent != null ? infoContent.A瀹樻柟鍚嶅瓧 : string.Empty; + } + else + { + string selectPath = string.Empty; + string unselecPath = string.Empty; + HdlDeviceCommonLogic.Current.GetDeviceIcon(localDevice, ref unselecPath, ref selectPath); + recordInfo.IconPath = unselecPath; + //娑堟伅绫诲瀷 + recordInfo.MsgObjectText = HdlDeviceCommonLogic.Current.GetDeviceEpointName(localDevice); + } + + //娑堟伅 + var info = HdlAlarmsLogic.Current.GetSensorAlarmInfo(ias); + if (info == null) + { + //闈炲湪鍐岀殑娑堟伅璁板綍 + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered)); + return true; + } + + if (string.IsNullOrEmpty(info.AlarmMsg) == false) + { + recordInfo.listMsg.Add(info.AlarmMsg); + } + if (info.BatteryMsg != null) + { + recordInfo.listMsg.Add(info.BatteryMsg); + } + if (info.DemolishmenMsg != null) + { + recordInfo.listMsg.Add(info.DemolishmenMsg); + } + + //瑙﹀彂浼犳劅鍣ㄦ姤璀� + if (recordInfo.listMsg.Count == 0) + { + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered)); + } + return true; + } + + #endregion + + #region 鈻� 闂ㄩ攣涓婃姤___________________________ + + /// <summary> + /// 闂ㄩ攣涓婃姤 + /// </summary> + /// <param name="receiveData"></param> + private void DoorLockDeviceReportPush(JObject receiveData, ref MessageRecordInfo recordInfo) + { + //鍥炬爣 + var device = HdlDeviceCommonLogic.Current.GetDevice(receiveData.Value<string>("DeviceAddr"), receiveData.Value<int>("Epoint")); + if (device == null) + { + recordInfo.IconPath = "Device/IntelligentLocks.png"; + //娑堟伅绫诲瀷:鏅鸿兘闂ㄩ攣 + var infoContent = HdlDeviceCommonLogic.Current.GetDeviceModelIdNameInfo("A405"); + recordInfo.MsgObjectText = infoContent != null ? infoContent.A瀹樻柟鍚嶅瓧 : string.Empty; + } + else + { + string selectPath = string.Empty; + string unselecPath = string.Empty; + HdlDeviceCommonLogic.Current.GetDeviceIcon(device, ref unselecPath, ref selectPath); + recordInfo.IconPath = unselecPath; + //娑堟伅绫诲瀷 + recordInfo.MsgObjectText = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device); + } + //娑堟伅 + var msgInfo = HdlAlarmsLogic.Current.GetDoorLockAlarmInfo(receiveData); + string MsgText = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered); + recordInfo.listMsg.Add(MsgText); + } + + #endregion + + #region 鈻� 甯冮槻_______________________________ + + /// <summary> + /// 甯冮槻鎺ㄩ�� + /// </summary> + /// <param name="receiveData"></param> + private void SetSafetyGarrisonPush(JObject receiveData, ref MessageRecordInfo recordInfo) + { + //鍥炬爣 + recordInfo.IconPath = "Item/Safety.png"; + + var data = Newtonsoft.Json.JsonConvert.DeserializeObject<Safeguard.EnableModeResponseData>(receiveData["Data"].ToString()); + if (data.Result == 0) + { + //绂诲甯冮槻 + if (data.ModeId == 2) + { + //绂诲甯冮槻 + recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uRemoveHomeGarrison); + //宸叉墽琛� + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); + } + else + { + //宸叉墽琛� + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); + //娌℃湁鍐呴儴闃插尯 + if (HdlSafeguardLogic.Current.IsHadInternalDefenseArea() == false) + { + //甯冮槻 + recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uGarrison); + } + else + { + //鍦ㄥ甯冮槻 + recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uAtHomeGarrison); + } + } + } + else + { + //甯冮槻璁剧疆澶辫触 + recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uSetGarrisonFail); + } + } + + #endregion + + #region 鈻� 鎾ら槻_______________________________ + + /// <summary> + /// 鎾ら槻鎺ㄩ�� + /// </summary> + /// <param name="receiveData"></param> + private void RemoveSafetyGarrisonPush(JObject receiveData, ref MessageRecordInfo recordInfo) + { + //鍥炬爣 + recordInfo.IconPath = "Item/Safety.png"; + + var data = Newtonsoft.Json.JsonConvert.DeserializeObject<Safeguard.WithdrawModeResponseData>(receiveData["Data"].ToString()); + if (data.Result == 0) + { + //宸叉墽琛� + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); + //鎾ら槻 + recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uWithdrawGarrison); + } + else + { + //鎾ら槻澶辫触 + recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uRemoveGarrisonFail); + } + } + + #endregion + + #region 鈻� 閫昏緫瑙﹀彂涓婃姤_______________________ + + /// <summary> + /// 閫昏緫瑙﹀彂涓婃姤 + /// </summary> + /// <param name="receiveData"></param> + private void LogicExecutePush(JObject receiveData, ref MessageRecordInfo recordInfo) + { + //鍥炬爣 + recordInfo.IconPath = "Item/LogicMsgIcon.png"; + //绫诲瀷:閫昏緫鍚嶅瓧 + recordInfo.MsgObjectText = receiveData["Data"]["LogicName"].ToString(); + //宸叉墽琛� + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); + } + + #endregion + + #region 鈻� 鍦烘櫙瑙﹀彂涓婃姤_______________________ + + /// <summary> + /// 鍦烘櫙瑙﹀彂涓婃姤 + /// </summary> + /// <param name="receiveData"></param> + private void SceneExecPush(JObject receiveData, ref MessageRecordInfo recordInfo) + { + //鍥炬爣 + recordInfo.IconPath = "Item/SceneMsgIcon.png"; + //绫诲瀷:鍦烘櫙鍚嶅瓧 + recordInfo.MsgObjectText = receiveData["Data"]["ScenesName"].ToString(); + //宸叉墽琛� + recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted)); + } + + #endregion + + #region 鈻� 鐣岄潰鍏抽棴___________________________ + + /// <summary> + /// 鐣岄潰鍏抽棴 + /// </summary> + public override void CloseFormBefore() + { + var userPageForm = UserView.UserPage.Instance.GetNowActionForm(); + if (userPageForm != null && userPageForm.FormID == "UserMainForm") + { + Common.CommonPage.Instance.IsDrawerLockMode = false; + } + base.CloseFormBefore(); + } + + #endregion } } -- Gitblit v1.8.0