HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/UserCenter/UserMain/MessageManagementForm.cs
@@ -19,7 +19,7 @@
        /// </summary>
        private VerticalFrameRefreshControl listView = null;
        /// <summary>
        /// 全部的行
        /// 全部的行,主键是自动递增的东西
        /// </summary>
        private Dictionary<string, RowLayoutControl> dicAllRow = null;
@@ -32,6 +32,9 @@
        /// </summary>
        public void ShowForm()
        {
            //左滑使能
            this.ScrollEnabled = false;
            Common.CommonPage.Instance.IsDrawerLockMode = true;
            //设置头部信息
@@ -65,10 +68,10 @@
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private async void InitMiddleData(bool showReload)
        private void InitMiddleData(bool showReload)
        {
            //获取数据
            var dicData = await this.GetMessageData();
            var dicData = this.GetMessageData();
            if (dicData == null)
            {
                if (showReload == true)
@@ -154,7 +157,7 @@
                            framBack.Name = dateIndex.ToString();
                            framBack.Height = Application.GetRealHeight(100);
                            framBack.BackgroundColor = UserCenterColor.Current.White;
                            listView.AddChidrenFrame(framBack);
                            listView.AddChidren(framBack);
                            //日期
                            string strMonth = Language.StringByID(R.MyInternationalizationString.Month);
@@ -172,8 +175,15 @@
                        for (int i = 0; i < listData.Count; i++)
                        {
                            //添加信息行
                            this.AddMsgRowControl(framBack, listData[i], i != listData.Count - 1);
                            //一条信息里面,它可能包含多个报警
                            for (int j = 0; j < listData[i].listMsg.Count; j++)
                            {
                                //设置已读的初始值
                                listData[i].ListReading.Add(listData[i].IsReading);
                                //添加信息行
                                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));
@@ -249,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);
@@ -265,24 +276,24 @@
            var btnMsgObject = rowControl.frameTable.AddLeftCaption(recordInfo.MsgObjectText, 600);
            //消息
            var btnMsg = rowControl.frameTable.AddMostRightView(recordInfo.MsgText, 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("", 200, 50);
            btnTime.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnTime.Y = btnMsg.Bottom + Application.GetRealHeight(12);
            var convertTime = UserCenterLogic.ConvertUtcTimeToLocalTime(recordInfo.CreatedOnUtc);
            btnTime.Text = convertTime.ToString("HH:mm");
            rowControl.frameTable.AddChidren(btnTime, ChidrenBindMode.BindEventOnly);
            rowControl.frameTable.AddChidren(btnTime, ChidrenBindMode.BindEvent);
            //底线
            if (addLine == true)
            {
                rowControl.frameTable.AddBottomLine();
                rowControl.frameTable.AddBottomLine();
            }
            //已读
            if (recordInfo.IsReading == true)
            if (recordInfo.ListReading[msgIndex] == true)
            {
                rowControl.frameTable.UseClickStatu = false;
                //消息类型
@@ -295,13 +306,13 @@
            //新消息
            PicViewControl btnNewTip = null;
            if (recordInfo.IsReading == false)
            if (recordInfo.ListReading[msgIndex] == false)
            {
                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.BindEventOnly);
                rowControl.frameTable.AddChidren(btnNewTip, ChidrenBindMode.BindEvent);
            }
            //主要主人和管理员能够删除
@@ -313,9 +324,9 @@
                {
                    //确认删除消息?
                    string msg = Language.StringByID(R.MyInternationalizationString.uDeleteMessageMsg);
                    this.ShowMassage(ShowMsgType.Confirm, msg, async () =>
                    this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                    {
                        await this.DeleteMsg(recordInfo.Id, frameList, rowControl);
                        this.DeleteMsg(recordInfo.Id, frameList, rowControl);
                    });
                };
            }
@@ -323,11 +334,11 @@
            //点击
            rowControl.frameTable.ButtonClickEvent += async (sender, e) =>
            {
                if (recordInfo.IsReading == true)
                if (recordInfo.ListReading[msgIndex] == true)
                {
                    return;
                }
                recordInfo.IsReading = true;
                recordInfo.ListReading[msgIndex] = true;
                rowControl.frameTable.UseClickStatu = false;
                //消息类型
                btnMsgObject.TextColor = UserCenterColor.Current.TextGrayColor1;
@@ -337,7 +348,7 @@
                if (sender != null)
                {
                    //标记已读(不管它成功不成功)
                    await this.SetTickIsRead(recordInfo.Id);
                    this.SetTickIsRead(recordInfo.Id);
                }
            };
        }
@@ -350,12 +361,12 @@
        /// 标记已读
        /// </summary>
        /// <param name="strId"></param>
        private async System.Threading.Tasks.Task<bool> SetTickIsRead(string strId)
        private bool SetTickIsRead(string strId)
        {
            var pra = new MessageReadStatuPra();
            pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
            pra.Id = strId;
            var result = await UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/TagMessageMessageCenterItem", true, pra);
            var result = UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/TagMessageMessageCenterItem", true, pra);
            return result;
        }
@@ -371,23 +382,21 @@
            //确认标记全部消息为已读?
            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 pra = new MessageReadStatuPra();
                    pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                    pra.TagAllOrClearType = 0;
                    var result = UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/TagAllOrClearMessageCenter", true, pra);
                    //关闭进度条
                    this.CloseProgressBar();
                    if (result == false)
                    {
                        return;
                    }
                    HdlThreadLogic.Current.RunMain(() =>
                    {
@@ -411,12 +420,12 @@
        /// <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)
        {
            var pra = new MessageReadStatuPra();
            pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
            pra.Id = strId;
            var result = await UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/DelMessageCenterItem", true, pra);
            var result = UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/DelMessageCenterItem", true, pra);
            if (result == false)
            {
                return false;
@@ -448,20 +457,20 @@
            //确认删除全部消息?
            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 pra = new MessageReadStatuPra();
                    pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
                    pra.TagAllOrClearType = 1;
                    var result = UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/TagAllOrClearMessageCenter", true, pra);
                    if (result == false)
                    {
                        //删除全部消息
                        var result = await this.DeleteMsg(contr.MainKeys, null, null);
                        if (result == false)
                        {
                            //关闭进度条
                            this.CloseProgressBar();
                            return;
                        }
                        //关闭进度条
                        this.CloseProgressBar();
                        return;
                    }
                    //初始化中部信息
                    this.InitMiddleData(true);
@@ -543,7 +552,7 @@
        /// 获取消息记录
        /// </summary>
        /// <returns></returns>
        private async Task<Dictionary<string, List<List<MessageRecordInfo>>>> GetMessageData()
        private Dictionary<string, List<List<MessageRecordInfo>>> GetMessageData()
        {
            this.dicAllRow = new Dictionary<string, RowLayoutControl>();
            var allListData = new List<MessageRecordInfo>();
@@ -553,7 +562,7 @@
            //传感器上报
            pra.Topic = "/IASInfoReport";
            var dataInfo = await this.GetMessageDataFromDb(pra);
            var dataInfo = this.GetMessageDataFromDb(pra);
            if (dataInfo == null)
            {
                return null;
@@ -562,7 +571,7 @@
            //门锁上报
            pra.Topic = "/Alarms/SendAlarmInform";
            dataInfo = await this.GetMessageDataFromDb(pra);
            dataInfo = this.GetMessageDataFromDb(pra);
            if (dataInfo == null)
            {
                return null;
@@ -571,7 +580,7 @@
            //撤防
            pra.Topic = "/Security/WithdrawMode_Respon";
            dataInfo = await this.GetMessageDataFromDb(pra);
            dataInfo = this.GetMessageDataFromDb(pra);
            if (dataInfo == null)
            {
                return null;
@@ -580,7 +589,7 @@
            //布防
            pra.Topic = "/Security/EnableMode_Respon";
            dataInfo = await this.GetMessageDataFromDb(pra);
            dataInfo = this.GetMessageDataFromDb(pra);
            if (dataInfo == null)
            {
                return null;
@@ -589,7 +598,7 @@
            //逻辑触发上报
            pra.Topic = "/Logic/Execute_Respon";
            dataInfo = await this.GetMessageDataFromDb(pra);
            dataInfo = this.GetMessageDataFromDb(pra);
            if (dataInfo == null)
            {
                return null;
@@ -598,7 +607,7 @@
            //场景触发上报
            pra.Topic = "/Scene/Exec_Respon";
            dataInfo = await this.GetMessageDataFromDb(pra);
            dataInfo = this.GetMessageDataFromDb(pra);
            if (dataInfo == null)
            {
                return null;
@@ -614,10 +623,10 @@
        /// </summary>
        /// <param name="pra"></param>
        /// <returns></returns>
        private async Task<List<MessageRecordInfo>> GetMessageDataFromDb(MessageInfoPra pra)
        private List<MessageRecordInfo> GetMessageDataFromDb(MessageInfoPra pra)
        {
            var result = await UserCenterLogic.GetResponseDataByRequestHttps("MessageCenter/GetMessageCenterPagger", true, pra);
            if (result == null)
            var result = UserCenterLogic.GetResponseDataByRequestHttps("MessageCenter/GetMessageCenterPagger", true, pra);
            if (string.IsNullOrEmpty(result) == true)
            {
                return null;
            }
@@ -759,7 +768,8 @@
            {
                recordInfo.IconPath = "Device/Sensor.png";
                //消息类型:传感器
                recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId1200);
                var infoContent = Common.LocalDevice.Current.GetDeviceModelIdNameInfo("A402");
                recordInfo.MsgObjectText = infoContent != null ? infoContent.A官方名字 : string.Empty;
            }
            else
            {
@@ -776,19 +786,27 @@
            if (info == null)
            {
                //非在册的消息记录
                recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered);
                recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered));
                return true;
            }
            else if (info.BatteryMsg != null)
            if (string.IsNullOrEmpty(info.AlarmMsg) == false)
            {
                recordInfo.MsgText = info.BatteryMsg;
                recordInfo.listMsg.Add(info.AlarmMsg);
            }
            else if (info.DemolishmenMsg != null)
            if (info.BatteryMsg != null)
            {
                recordInfo.MsgText = info.DemolishmenMsg;
                recordInfo.listMsg.Add(info.BatteryMsg);
            }
            else
            if (info.DemolishmenMsg != null)
            {
                recordInfo.MsgText = string.IsNullOrEmpty(info.AlarmMsg) == false ? info.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered);
                recordInfo.listMsg.Add(info.DemolishmenMsg);
            }
            //触发传感器报警
            if (recordInfo.listMsg.Count == 0)
            {
                recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered));
            }
            return true;
        }
@@ -809,7 +827,8 @@
            {
                recordInfo.IconPath = "Device/IntelligentLocks.png";
                //消息类型:智能门锁
                recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2800);
                var infoContent = Common.LocalDevice.Current.GetDeviceModelIdNameInfo("A405");
                recordInfo.MsgObjectText = infoContent != null ? infoContent.A官方名字 : string.Empty;
            }
            else
            {
@@ -822,7 +841,8 @@
            }
            //消息
            var msgInfo = HdlAlarmsLogic.Current.GetDoorLockAlarmInfo(receiveData);
            recordInfo.MsgText = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered);
            string MsgText = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered);
            recordInfo.listMsg.Add(MsgText);
        }
        #endregion
@@ -847,12 +867,12 @@
                    //离家布防
                    recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uRemoveHomeGarrison);
                    //已执行
                    recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted);
                    recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted));
                }
                else
                {
                    //已执行
                    recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted);
                    recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted));
                    //没有内部防区
                    if (HdlSafeguardLogic.Current.IsHadInternalDefenseArea() == false)
                    {
@@ -890,7 +910,7 @@
            if (data.Result == 0)
            {
                //已执行
                recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted);
                recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted));
                //撤防
                recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uWithdrawGarrison);
            }
@@ -916,7 +936,7 @@
            //类型:逻辑名字
            recordInfo.MsgObjectText = receiveData["Data"]["LogicName"].ToString();
            //已执行
            recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted);
            recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted));
        }
        #endregion
@@ -934,7 +954,7 @@
            //类型:场景名字
            recordInfo.MsgObjectText = receiveData["Data"]["ScenesName"].ToString();
            //已执行
            recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted);
            recordInfo.listMsg.Add(Language.StringByID(R.MyInternationalizationString.uExecuted));
        }
        #endregion
@@ -946,7 +966,8 @@
        /// </summary>
        public override void CloseFormBefore()
        {
            if (UserCenterResourse.DicActionForm.ContainsKey("UserMainForm") == false)
            var userPageForm = UserView.UserPage.Instance.GetNowActionForm();
            if (userPageForm != null && userPageForm.FormID == "UserMainForm")
            {
                Common.CommonPage.Instance.IsDrawerLockMode = false;
            }