| | |
| | | using System;
|
| | | using Newtonsoft.Json.Linq;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using System.Threading.Tasks;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.UserMain
|
| | | {
|
| | |
| | | /// </summary>
|
| | | public void ShowForm()
|
| | | {
|
| | | Common.CommonPage.Instance.IsDrawerLockMode = true;
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uMessageCenter));
|
| | |
|
| | |
| | | {
|
| | | //获取数据
|
| | | var dicData = await this.GetMessageData();
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(dicData == null && showReload == true ? ShowReLoadMode.YES : ShowReLoadMode.NO);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //关闭刷新特效
|
| | | listView?.EndHeaderRefreshing();
|
| | | });
|
| | | if (dicData == null)
|
| | | {
|
| | | if (showReload == true)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | }
|
| | | else
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //关闭刷新特效
|
| | | listView?.EndHeaderRefreshing();
|
| | | //清空
|
| | | listView.RemoveAll();
|
| | | });
|
| | | //数据异常
|
| | | return;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame(dicData);
|
| | | });
|
| | |
|
| | | //初始化中部控件
|
| | | 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 = 1000;
|
| | | 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.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(listGroup[0][0].CreatedOnUtc).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 (countIndex == maxCount)
|
| | | {
|
| | | //调整桌布
|
| | | listView.AdjustTableHeight();
|
| | | //关闭刷新特效
|
| | | listView.EndHeaderRefreshing();
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | }
|
| | | });
|
| | | //第一次的时候,等待的时候久一点
|
| | | System.Threading.Thread.Sleep(waiTime);
|
| | | waiTime = 500;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | /// </summary>
|
| | | private void ShowBottomMenu()
|
| | | {
|
| | | bool authority = UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.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
|
| | |
| | | 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.MsgText, 600, 60);
|
| | | btnMsg.TextColor = UserCenterColor.Current.TextGrayColor3;
|
| | | btnMsg.Y = Application.GetRealHeight(5) + rowControl.frameTable.chidrenYaxis;
|
| | | rowControl.frameTable.AddChidren(btnMsg, ChidrenBindMode.BindEventOnly);
|
| | | //时间
|
| | | 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:mm");
|
| | | btnTime.Text = Convert.ToDateTime(recordInfo.CreatedOnUtc).ToString("HH:mm");
|
| | | rowControl.frameTable.AddChidren(btnTime, ChidrenBindMode.BindEventOnly);
|
| | | //底线
|
| | | if (addLine == true)
|
| | |
| | | rowControl.frameTable.AddBottomLine();
|
| | | }
|
| | | //已读
|
| | | if (recordInfo.IsRead == 1)
|
| | | if (recordInfo.IsReading == true)
|
| | | {
|
| | | rowControl.frameTable.UseClickStatu = false;
|
| | | //消息类型
|
| | |
| | | //消息
|
| | | btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | }
|
| | | //删除
|
| | | var btnDelete = rowControl.AddDeleteControl();
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | //调整宽度
|
| | | btnMsgObject.Width = btnMsgObject.GetRealWidthByText();
|
| | |
|
| | | //新消息
|
| | | PicViewControl btnNewTip = null;
|
| | | if (recordInfo.IsReading == 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.BindEventOnly);
|
| | | }
|
| | |
|
| | | //主要主人和管理员能够删除
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.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, async () =>
|
| | | {
|
| | | await this.DeleteMsg(recordInfo.Id, frameList, rowControl);
|
| | | });
|
| | | };
|
| | | }
|
| | |
|
| | | //点击
|
| | | rowControl.frameTable.ButtonClickEvent += async (sender, e) =>
|
| | | {
|
| | | if (recordInfo.IsRead == 1)
|
| | | if (recordInfo.IsReading == true)
|
| | | {
|
| | | return;
|
| | | }
|
| | | recordInfo.IsRead = 1;
|
| | | recordInfo.IsReading = true;
|
| | | rowControl.frameTable.UseClickStatu = false;
|
| | | //消息类型
|
| | | btnMsgObject.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | |
| | | /// <param name="strId"></param>
|
| | | private async System.Threading.Tasks.Task<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;
|
| | | var pra = new MessageReadStatuPra();
|
| | | pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | | pra.Id = strId;
|
| | | var result = await UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/TagMessageMessageCenterItem", true, pra);
|
| | | return result;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="rowContr"></param>
|
| | | private async System.Threading.Tasks.Task<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 pra = new MessageReadStatuPra();
|
| | | pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | | pra.Id = strId;
|
| | | var result = await UserCenterLogic.GetResultStatuByRequestHttps("MessageCenter/DelMessageCenterItem", true, pra);
|
| | | if (result == false)
|
| | | {
|
| | | return UserCenterLogic.CheckNotEorrorMsg(null, "ZigbeeUsers/DeletePushMessage", null, null);
|
| | | return false;
|
| | | }
|
| | |
|
| | | //云端是不会返回东西的
|
| | | if (frameList != null)
|
| | | {
|
| | |
| | | /// 获取消息记录
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private async System.Threading.Tasks.Task<Dictionary<string, List<MessageRecordInfo>>> GetMessageData()
|
| | | private async Task<Dictionary<string, List<List<MessageRecordInfo>>>> GetMessageData()
|
| | | {
|
| | | this.dicAllRow = new Dictionary<string, RowLayoutControl>();
|
| | | var allListData = new List<MessageRecordInfo>();
|
| | |
|
| | | var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetPushMessageRecord", false, "");
|
| | | var pra = new MessageInfoPra();
|
| | | pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | |
|
| | | //传感器上报
|
| | | pra.Topic = "/IASInfoReport";
|
| | | var dataInfo = await this.GetMessageDataFromDb(pra);
|
| | | if (dataInfo == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | allListData.AddRange(dataInfo);
|
| | |
|
| | | //门锁上报
|
| | | pra.Topic = "/Alarms/SendAlarmInform";
|
| | | dataInfo = await this.GetMessageDataFromDb(pra);
|
| | | if (dataInfo == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | allListData.AddRange(dataInfo);
|
| | |
|
| | | //撤防
|
| | | pra.Topic = "/Security/WithdrawMode_Respon";
|
| | | dataInfo = await this.GetMessageDataFromDb(pra);
|
| | | if (dataInfo == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | allListData.AddRange(dataInfo);
|
| | |
|
| | | //布防
|
| | | pra.Topic = "/Security/EnableMode_Respon";
|
| | | dataInfo = await this.GetMessageDataFromDb(pra);
|
| | | if (dataInfo == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | allListData.AddRange(dataInfo);
|
| | |
|
| | | //逻辑触发上报
|
| | | pra.Topic = "/Logic/Execute_Respon";
|
| | | dataInfo = await this.GetMessageDataFromDb(pra);
|
| | | if (dataInfo == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | allListData.AddRange(dataInfo);
|
| | |
|
| | | //场景触发上报
|
| | | pra.Topic = "/Scene/Exec_Respon";
|
| | | dataInfo = await this.GetMessageDataFromDb(pra);
|
| | | if (dataInfo == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | allListData.AddRange(dataInfo);
|
| | |
|
| | | //合并数据
|
| | | return this.MergeMessageRecordData(allListData);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 从云端获取数据
|
| | | /// </summary>
|
| | | /// <param name="pra"></param>
|
| | | /// <returns></returns>
|
| | | private async Task<List<MessageRecordInfo>> GetMessageDataFromDb(MessageInfoPra pra)
|
| | | {
|
| | | var result = await UserCenterLogic.GetResponseDataByRequestHttps("MessageCenter/GetMessageCenterPagger", true, pra);
|
| | | if (result == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MessageRecordInfo>>(result);
|
| | | //合并数据
|
| | | return this.MergeMessageRecordData(dataInfo);
|
| | | var dataInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageCentetInfo>(result);
|
| | |
|
| | | var listData = new List<MessageRecordInfo>();
|
| | | for (int i = 0; i < dataInfo.PageData.Count; i++)
|
| | | {
|
| | | try
|
| | | {
|
| | | var data = dataInfo.PageData[i];
|
| | | //处理消息类型
|
| | | this.AdjustMsgContent(ref data);
|
| | |
|
| | | listData.Add(data);
|
| | | }
|
| | | catch { continue; }
|
| | | }
|
| | |
|
| | | return 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.CreatedOnUtc) == false)
|
| | | {
|
| | | dicTemp[data.MsgTime] = new List<MessageRecordInfo>();
|
| | | listSortKeys.Add(data.MsgTime);
|
| | | dicTemp[data.CreatedOnUtc] = new List<MessageRecordInfo>();
|
| | | listSortKeys.Add(data.CreatedOnUtc);
|
| | | }
|
| | | dicTemp[data.MsgTime].Add(data);
|
| | | dicTemp[data.CreatedOnUtc].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 (data2.Topic == "/DoorLock/DoorLockOperatingEventNotificationCommand")
|
| | | {
|
| | | //暂时不处理这个主题
|
| | | continue;
|
| | | }
|
| | | string[] myArry = data2.CreatedOnUtc.Split(new string[] { "T" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | if (myArry.Length != 2)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (dicData.ContainsKey(myArry[0]) == false)
|
| | | string dicKeys = myArry[0];//日期
|
| | | if (dicData.ContainsKey(dicKeys) == false)
|
| | | {
|
| | | dicData[myArry[0]] = new List<MessageRecordInfo>();
|
| | | listGroup = new List<MessageRecordInfo>();
|
| | | dicData[dicKeys] = new List<List<MessageRecordInfo>>();
|
| | | dicData[dicKeys].Add(listGroup);
|
| | | }
|
| | | dicData[myArry[0]].Add(data2);
|
| | | if (listGroup.Count > 20)
|
| | | {
|
| | | //每20个一组
|
| | | listGroup = new List<MessageRecordInfo>();
|
| | | dicData[dicKeys].Add(listGroup);
|
| | | }
|
| | | listGroup.Add(data2);
|
| | | }
|
| | | }
|
| | | return dicData;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 处理消息类型_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 处理消息类型
|
| | | /// </summary>
|
| | | /// <param name="recordInfo">消息数据</param>
|
| | | private void AdjustMsgContent(ref MessageRecordInfo recordInfo)
|
| | | {
|
| | | var jobject = JObject.Parse(recordInfo.PayloadJson);
|
| | | //传感器上报
|
| | | if (recordInfo.Topic == "/IASInfoReport")
|
| | | {
|
| | | this.SensorDeviceReportPush(jobject, ref recordInfo);
|
| | | }
|
| | | //门锁上报
|
| | | else if (recordInfo.Topic == "/Alarms/SendAlarmInform")
|
| | | {
|
| | | this.DoorLockDeviceReportPush(jobject, ref recordInfo);
|
| | | }
|
| | | //撤防
|
| | | else if (recordInfo.Topic == "/Security/WithdrawMode_Respon")
|
| | | {
|
| | | this.RemoveSafetyGarrisonPush(jobject, ref recordInfo);
|
| | | }
|
| | | //布防
|
| | | else if (recordInfo.Topic == "/Security/EnableMode_Respon")
|
| | | {
|
| | | this.SetSafetyGarrisonPush(jobject, ref recordInfo);
|
| | | }
|
| | | //逻辑触发上报
|
| | | else if (recordInfo.Topic == "/Logic/Execute_Respon")
|
| | | {
|
| | | this.LogicExecutePush(jobject, ref recordInfo);
|
| | | }
|
| | | //场景触发上报
|
| | | else if (recordInfo.Topic == "/Scene/Exec_Respon")
|
| | | {
|
| | | this.SceneExecPush(jobject, ref recordInfo);
|
| | | }
|
| | | }
|
| | |
|
| | | #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 = Common.LocalDevice.Current.GetDevice(ias.DeviceAddr, ias.DeviceEpoint);
|
| | | if (localDevice == null)
|
| | | {
|
| | | recordInfo.IconPath = "Device/Sensor.png";
|
| | | //消息类型:传感器
|
| | | recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId1200);
|
| | | }
|
| | | else
|
| | | {
|
| | | string selectPath = string.Empty;
|
| | | string unselecPath = string.Empty;
|
| | | Common.LocalDevice.Current.GetDeviceIcon(localDevice, ref unselecPath, ref selectPath);
|
| | | recordInfo.IconPath = unselecPath;
|
| | | //消息类型
|
| | | recordInfo.MsgObjectText = Common.LocalDevice.Current.GetDeviceEpointName(localDevice);
|
| | | }
|
| | |
|
| | | //消息
|
| | | var info = HdlAlarmsLogic.Current.GetSensorAlarmInfo(ias);
|
| | | if (info == null)
|
| | | {
|
| | | //非在册的消息记录
|
| | | recordInfo.MsgText = Language.StringByID(R.MyInternationalizationString.uSensorAlarmHadTriggered);
|
| | | }
|
| | | else if (info.BatteryMsg != null)
|
| | | {
|
| | | recordInfo.MsgText = info.BatteryMsg;
|
| | | }
|
| | | else if (info.DemolishmenMsg != null)
|
| | | {
|
| | | recordInfo.MsgText = info.DemolishmenMsg;
|
| | | }
|
| | | else
|
| | | {
|
| | | recordInfo.MsgText = string.IsNullOrEmpty(info.AlarmMsg) == false ? info.AlarmMsg : 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 = Common.LocalDevice.Current.GetDevice(receiveData.Value<string>("DeviceAddr"), receiveData.Value<int>("Epoint"));
|
| | | if (device == null)
|
| | | {
|
| | | recordInfo.IconPath = "Device/IntelligentLocks.png";
|
| | | //消息类型:智能门锁
|
| | | recordInfo.MsgObjectText = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2800);
|
| | | }
|
| | | else
|
| | | {
|
| | | string selectPath = string.Empty;
|
| | | string unselecPath = string.Empty;
|
| | | Common.LocalDevice.Current.GetDeviceIcon(device, ref unselecPath, ref selectPath);
|
| | | recordInfo.IconPath = unselecPath;
|
| | | //消息类型
|
| | | recordInfo.MsgObjectText = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | }
|
| | | //消息
|
| | | var msgInfo = HdlAlarmsLogic.Current.GetDoorLockAlarmInfo(receiveData);
|
| | | recordInfo.MsgText = msgInfo != null ? msgInfo.AlarmMsg : Language.StringByID(R.MyInternationalizationString.uDoorLocksAlarmHadTriggered);
|
| | | }
|
| | |
|
| | | #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.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted);
|
| | | }
|
| | | else
|
| | | {
|
| | | //已执行
|
| | | recordInfo.MsgText = 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.MsgText = 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.MsgText = 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.MsgText = Language.StringByID(R.MyInternationalizationString.uExecuted);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 界面关闭___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面关闭
|
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | if (UserCenterResourse.DicActionForm.ContainsKey("UserMainForm") == false)
|
| | | {
|
| | | Common.CommonPage.Instance.IsDrawerLockMode = false;
|
| | | }
|
| | | base.CloseFormBefore();
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|