From ff3cfcf62632bf43e51a6b6098c203bf0f5cddbc Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期二, 24 十二月 2019 19:53:29 +0800 Subject: [PATCH] 2019.12.24 --- ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs | 219 ++++++++++++++++++++++++++---------------------------- 1 files changed, 107 insertions(+), 112 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs index 628bf5d..7197147 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs @@ -14,7 +14,7 @@ /// <summary> /// 鍒楄〃鎺т欢 /// </summary> - private VerticalFrameControl listView = null; + private VerticalFrameRefreshControl listView = null; /// <summary> /// 鍏ㄩ儴鐨勮 /// </summary> @@ -32,43 +32,52 @@ //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uMessageCenter)); - listView = new VerticalFrameControl(35); - listView.Height = bodyFrameLayout.Height; - bodyFrameLayout.AddChidren(listView); - //鍒濆鍖栧彸涓婅鑿滃崟 this.InitTopRightMenu(); + listView = new VerticalFrameRefreshControl(35); + listView.Height = bodyFrameLayout.Height; + bodyFrameLayout.AddChidren(listView); + listView.BeginHeaderRefreshingAction += () => + { + HdlThreadLogic.Current.RunThread(() => + { + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleData(false); + }); + }; + HdlThreadLogic.Current.RunThread(() => { + //鎵撳紑杩涘害鏉� + this.ShowProgressBar(); + //鍒濆鍖栦腑閮ㄤ俊鎭� - this.InitMiddleData(); + this.InitMiddleData(true); }); } /// <summary> /// 鍒濆鍖栦腑閮ㄤ俊鎭� /// </summary> - private async void InitMiddleData() + private async void InitMiddleData(bool showReload) { - this.dicAllRow = new Dictionary<string, RowLayoutControl>(); + //鑾峰彇鏁版嵁 + var dicData = await this.GetMessageData(); + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(dicData == null && showReload == true ? ShowReLoadMode.YES : ShowReLoadMode.NO); - //鎵撳紑杩涘害鏉� - this.ShowProgressBar(); - var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetPushMessageRecord", false, ""); - if (result == null) + HdlThreadLogic.Current.RunMain(() => { - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(ShowReLoadMode.YES); + //鍏抽棴鍒锋柊鐗规晥 + listView?.EndHeaderRefreshing(); + }); + if (dicData == null) + { + //鏁版嵁寮傚父 return; } - var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MessageRecordInfo>>(result); - //鍚堝苟鏁版嵁 - var dicData = this.MergeMessageRecordData(dataInfo); - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - - HdlThreadLogic.Current.RunMainInThread(() => + HdlThreadLogic.Current.RunMain(() => { //鍒濆鍖栦腑閮ㄦ帶浠� this.InitMiddleFrame(dicData); @@ -81,45 +90,45 @@ /// <param name="dicData"></param> private void InitMiddleFrame(Dictionary<string, List<MessageRecordInfo>> dicData) { + //娓呯┖ + listView.RemoveAll(); + int index = 0; foreach (var keys in dicData.Keys) { var listData = dicData[keys]; - HdlThreadLogic.Current.RunMain(() => + 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++) { - 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++) - { - //娣诲姞淇℃伅琛� - this.AddMsgRowControl(framBack, listData[i], i != listData.Count - 1); - } - //璋冩暣楂樺害 - listView.AdjustChidrenFrameHeight(framBack, Application.GetRealHeight(23)); - if (index == dicData.Count) - { - listView.AdjustTableHeight(); - } - }); + //娣诲姞淇℃伅琛� + this.AddMsgRowControl(framBack, listData[i], i != listData.Count - 1); + } + //璋冩暣楂樺害 + listView.AdjustChidrenFrameHeight(framBack, Application.GetRealHeight(23)); + if (index == dicData.Count) + { + listView.AdjustTableHeight(); + } } } @@ -179,7 +188,7 @@ var rowControl = new RowLayoutControl(frameList.rowSpace / 2); frameList.AddChidren(rowControl); rowControl.Name = frameList.ChildrenCount.ToString(); - rowControl.MainKeys = recordInfo.RegId; + rowControl.MainKeys = recordInfo.Id; this.dicAllRow[frameList.Name + "-" + rowControl.Name] = rowControl; //鍥炬爣(鐜板湪娴嬭瘯) @@ -187,7 +196,7 @@ btnIcon.UnSelectedImagePath = "Item/Safety.png"; //娑堟伅绫诲瀷 - var btnMsgObject = rowControl.frameTable.AddLeftCaption("娴嬭瘯:娑堟伅绫诲瀷", 600); + var btnMsgObject = rowControl.frameTable.AddLeftCaption("鎶ヨ娑堟伅", 600); PicViewControl btnNewTip = null; if (recordInfo.IsRead == 0) { @@ -231,7 +240,7 @@ string msg = Language.StringByID(R.MyInternationalizationString.uDeleteMessageMsg); this.ShowMassage(ShowMsgType.Confirm, msg, async () => { - await this.DeleteMsg(recordInfo.RegId, frameList, rowControl); + await this.DeleteMsg(recordInfo.Id, frameList, rowControl); }); }; @@ -252,7 +261,7 @@ if (sender != null) { //鏍囪宸茶(涓嶇瀹冩垚鍔熶笉鎴愬姛) - await this.SetTickIsRead(recordInfo.RegId); + await this.SetTickIsRead(recordInfo.Id); } }; } @@ -267,8 +276,14 @@ /// <param name="strId"></param> private async System.Threading.Tasks.Task<bool> SetTickIsRead(string strId) { - var pra = new { Id = strId }; - await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/TickIsRead", true, pra); + 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; } @@ -326,9 +341,15 @@ /// <param name="rowContr"></param> private async System.Threading.Tasks.Task<bool> DeleteMsg(string strId, FrameListControl frameList, RowLayoutControl rowContr) { - var pra = new { Id = strId }; - var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeUsers/DeletePushMessage", true, pra); - if (result == true && frameList != null) + string strUrl = "ZigbeeUsers/DeletePushMessage?Id=" + strId; + + var result = await Common.CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync(strUrl, null, "GET"); + if (result == null) + { + return UserCenterLogic.CheckNotEorrorMsg(null, "ZigbeeUsers/DeletePushMessage", null, null); + } + //浜戠鏄笉浼氳繑鍥炰笢瑗跨殑 + if (frameList != null) { HdlThreadLogic.Current.RunMain(() => { @@ -338,7 +359,7 @@ this.AdjustControlLocation(frameList, rowContr); }); } - return result; + return true; } /// <summary> @@ -368,21 +389,8 @@ return; } } - //鍏抽棴杩涘害鏉� - this.CloseProgressBar(); - - HdlThreadLogic.Current.RunMain(() => - { - bodyFrameLayout.RemoveAll(); - listView = new VerticalFrameControl(35); - listView.Height = bodyFrameLayout.Height; - bodyFrameLayout.AddChidren(listView); - HdlThreadLogic.Current.RunThread(() => - { - //鍒濆鍖栦腑閮ㄤ俊鎭� - this.InitMiddleData(); - }); - }); + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleData(true); }); }); } @@ -455,7 +463,25 @@ #endregion - #region 鈻� 鍚堝苟鏁版嵁___________________________ + #region 鈻� 鑾峰彇鏁版嵁___________________________ + + /// <summary> + /// 鑾峰彇娑堟伅璁板綍 + /// </summary> + /// <returns></returns> + private async System.Threading.Tasks.Task<Dictionary<string, List<MessageRecordInfo>>> GetMessageData() + { + this.dicAllRow = new Dictionary<string, RowLayoutControl>(); + + var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetPushMessageRecord", false, ""); + if (result == null) + { + return null; + } + var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MessageRecordInfo>>(result); + //鍚堝苟鏁版嵁 + return this.MergeMessageRecordData(dataInfo); + } /// <summary> /// 鍚堝苟鏁版嵁 @@ -497,37 +523,6 @@ } } return dicData; - } - - #endregion - - #region 鈻� 缁撴瀯浣揰____________________________ - - /// <summary> - /// 淇℃伅缁撴灉 - /// </summary> - private class MessageRecordInfo - { - /// <summary> - /// 涓婚敭 - /// </summary> - public string RegId = string.Empty; - /// <summary> - /// 娑堟伅鍐呭 - /// </summary> - public string MsgContent = string.Empty; - /// <summary> - /// MsgType - /// </summary> - public string MsgType = string.Empty; - /// <summary> - /// 鏄惁宸茶 - /// </summary> - public int IsRead = 0; - /// <summary> - /// 鏃堕棿 2019-09-10 13:11:55 - /// </summary> - public string MsgTime = string.Empty; } #endregion -- Gitblit v1.8.0