| | |
| | | using System.Collections.Generic; |
| | | using System.Threading; |
| | | using HDL_ON.DAL.Server; |
| | | |
| | | #if DEBUG |
| | | using Xamarin.Essentials; |
| | | #endif |
| | | namespace HDL_ON.UI |
| | | { |
| | | /// <summary> |
| | |
| | | /// <summary> |
| | | /// 内容为空提示View |
| | | /// </summary> |
| | | EmptyTipView emptyTipView; |
| | | FrameLayout emptyTipView; |
| | | |
| | | /// <summary> |
| | | /// menuView |
| | |
| | | /// </summary> |
| | | List<PushMessageInfo> PushMessageInfoList = new List<PushMessageInfo>(); |
| | | |
| | | /// <summary> |
| | | /// 页面关闭时间 |
| | | /// </summary> |
| | | Action backAction; |
| | | |
| | | public override void RemoveFromParent() |
| | | { |
| | | UnregisterGetPushMessageAction(); |
| | | base.RemoveFromParent(); |
| | | backAction?.Invoke(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public void LoadPage() |
| | | /// <param name="backAction"></param> |
| | | public void LoadPage(Action backAction) |
| | | { |
| | | this.backAction = backAction; |
| | | new TopViewDiv(bodyView, Language.StringByID(StringId.MessageCenter)).LoadTopView(); |
| | | |
| | | AddTopMenuView(); |
| | | AddMessageView(); |
| | | MenuButtonSelect(showMesType); |
| | | RegisterGetPushMessageAction(); |
| | | //测试代码 |
| | | //AddEmptyTipView(); |
| | | //TestLoad(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | MenuButtonSelect(0); |
| | | }; |
| | | allMenuButton.SelectAction = allAction; |
| | | |
| | | #if DEBUG |
| | | //测试提前当前推送ID |
| | | allMenuButton.ImageButton.MouseLongEventHandler = (sender, e) => |
| | | { |
| | | CopyToClipboard("推送ID:" + OnAppConfig.Instance.PushId); |
| | | }; |
| | | #endif |
| | | #endregion |
| | | |
| | | #region 分享与功能 |
| | |
| | | /// </summary> |
| | | void AddEmptyTipView() |
| | | { |
| | | emptyTipView = new EmptyTipView() |
| | | emptyTipView = new FrameLayout() |
| | | { |
| | | Height = bodyScrolView.Height, |
| | | Width = bodyScrolView.Width, |
| | | }; |
| | | bodyScrolView.AddChidren(emptyTipView); |
| | | |
| | | var tipView = new EmptyTipView() |
| | | { |
| | | Gravity = Gravity.Center |
| | | }; |
| | | messageView.AddChidren(emptyTipView); |
| | | emptyTipView.AddChidren(tipView); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 年份标记 |
| | | /// </summary> |
| | | string YearMark = ""; |
| | | /// <summary> |
| | | /// 加载报警信息RowView |
| | | /// </summary> |
| | |
| | | }; |
| | | rowView.AddChidren(btnDatetime); |
| | | |
| | | var lineView = new LineView(rowView.Height); |
| | | var lineView = new LineView(rowView.Height - Application.GetRealHeight(1)); |
| | | rowView.AddChidren(lineView); |
| | | |
| | | //删除按钮 |
| | |
| | | }; |
| | | |
| | | |
| | | btnDatetime.Text = Utlis.UnixToDateTime(pushMessageInfo.createTime).ToString("yyyy/MM/dd HH:mm:ss"); |
| | | //EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | //{ |
| | | //}; |
| | | btnDatetime.Text = GetUnixToDateTime(pushMessageInfo.createTime); |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | | { |
| | | new Alert(pushMessageInfo.messageTitle, pushMessageInfo.messageContent, Language.StringByID(StringId.Close)).Show(); |
| | | }; |
| | | rowView.MouseUpEventHandler = eventHandler; |
| | | btnTilte.MouseUpEventHandler = eventHandler; |
| | | btnSubtitle.MouseUpEventHandler = eventHandler; |
| | | } |
| | | |
| | | //btnTilte.MouseUpEventHandler = eventHandler; |
| | | //btnSubtitle.MouseUpEventHandler = eventHandler; |
| | | /// <summary> |
| | | /// 时间格式转换处理 |
| | | /// </summary> |
| | | /// <param name="time">毫秒时间戳</param> |
| | | /// <returns></returns> |
| | | string GetUnixToDateTime(long time) |
| | | { |
| | | try |
| | | { |
| | | return Utlis.UnixToDateTimeWithFormatMS(time, "MM/dd HH:mm"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | void DeleteThePush(PushMessageInfo pushMessageInfo, RowLayout rowView) |
| | | { |
| | | var waitPage = new Loading(); |
| | | bodyView.AddChidren(waitPage); |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | |
| | | new Thread(() => |
| | |
| | | /// <param name="queryType"></param> |
| | | void GetPushMessageList(int queryType = 0) |
| | | { |
| | | var waitPage = new Loading(); |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | bodyScrolView.RemoveAll(); |
| | | PushMessageInfoList.Clear(); |
| | | YearMark = "";//标记清空 |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) |
| | | { |
| | | AddEmptyTipView(); |
| | | return; |
| | | } |
| | | |
| | | var waitPage = new Loading(); |
| | | bodyView.AddChidren(waitPage); |
| | | waitPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | |
| | | new Thread(() => |
| | | { |
| | |
| | | { |
| | | |
| | | ParseAndDisplayPushList(); |
| | | PushSerivceMarkAllMessageRead(); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | foreach (var info in PushMessageInfoList) |
| | | { |
| | | //年份解析 判断是否需要添加年份标题 |
| | | var mesYear = Utlis.UnixToDateTimeYearMS(info.createTime); |
| | | if (string.IsNullOrEmpty(YearMark)) |
| | | { |
| | | //刚开始YearMark标记为空,添加第一个年份标题 |
| | | YearMark = mesYear; |
| | | AddYearRowView(bodyScrolView, YearMark); |
| | | } |
| | | else if (YearMark != mesYear) |
| | | { |
| | | //当前信息年份和之前的不一样,重新添加一个年份标题 |
| | | YearMark = mesYear; |
| | | AddYearRowView(bodyScrolView, YearMark); |
| | | } |
| | | |
| | | AddRowView(bodyScrolView, info); |
| | | } |
| | | } |
| | | |
| | | #region 测试 |
| | | #if DEBUG |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | |
| | | { |
| | | messageTitle = "报警信息", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1606895454, |
| | | createTime = 1606900275, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | |
| | | createTime = 1606895454, |
| | | }); |
| | | |
| | | AddYearRowView(bodyScrolView, "2020年"); |
| | | foreach (var info in PushMessageInfoList) |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | AddRowView(bodyScrolView, info); |
| | | } |
| | | messageTitle = "报警信息2019", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1575277874, |
| | | }); |
| | | |
| | | AddYearRowView(bodyScrolView, "2019年"); |
| | | foreach (var info in PushMessageInfoList) |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | AddRowView(bodyScrolView, info); |
| | | } |
| | | messageTitle = "报警信息2019", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1572685874, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | messageTitle = "报警信息2018", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1541149874, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | messageTitle = "报警信息2017", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1509613874, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | messageTitle = "报警信息2017", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1509613874, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | messageTitle = "报警信息2017", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1506935474, |
| | | }); |
| | | |
| | | ParseAndDisplayPushList(); |
| | | } |
| | | |
| | | #endif |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 标记所有推送消息已读 |
| | | /// </summary> |
| | | void PushSerivceMarkAllMessageRead() |
| | | { |
| | | new Thread(() => |
| | | { |
| | | var result = new HttpServerRequest().PushSerivceMarkAllMessageRead(); |
| | | if (result) |
| | | { |
| | | Utlis.WriteLine("标记成功"); |
| | | } |
| | | else |
| | | { |
| | | Utlis.WriteLine("标记失败"); |
| | | } |
| | | |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 注册收到推送监听 |
| | | /// </summary> |
| | | void RegisterGetPushMessageAction() |
| | | { |
| | | HDLCommon.GetPushMessageAction = () => |
| | | { |
| | | if (bodyView != null) |
| | | { |
| | | //Utlis.WriteLine("GetPushMessageAction M收到推送"); |
| | | GetPushMessageList(showMesType); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 取消收到推送监听 |
| | | /// </summary> |
| | | void UnregisterGetPushMessageAction() |
| | | { |
| | | HDLCommon.GetPushMessageAction = null; |
| | | } |
| | | |
| | | #if DEBUG |
| | | |
| | | /// <summary> |
| | | /// 复制到剪切板 |
| | | /// </summary> |
| | | /// <param name="text"></param> |
| | | void CopyToClipboard(string text) |
| | | { |
| | | Clipboard.SetTextAsync(text); |
| | | Utlis.ShowTip(text + "\n" + Language.StringByID(StringId.CopySuccess)); |
| | | } |
| | | #endif |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// |
| | | /// Default:分享与功能;Alarm:报警类;Prompt:系统消息 |
| | | /// </summary> |
| | | public int pushType; |
| | | public string pushType; |
| | | /// <summary> |
| | | /// 消息主题 |
| | | /// </summary> |
| | |
| | | /// 消息内容 |
| | | /// </summary> |
| | | public string messageContent; |
| | | /// <summary> |
| | | /// 扩展数据 |
| | | /// </summary> |
| | | public string messageExpand; |
| | | /// <summary> |
| | | /// 消息类型;0:提示;1:报警;2:丰林可是对讲呼叫;3:强制下线推送 |
| | | /// </summary> |
| | | public string messageType; |
| | | ///// <summary> |
| | | ///// 扩展数据 |
| | | ///// </summary> |
| | | //public string messageExpand; |
| | | ///// <summary> |
| | | ///// 消息类型;0:提示;1:报警;2:丰林可是对讲呼叫;3:强制下线推送 |
| | | ///// </summary> |
| | | //public string messageType; |
| | | /// <summary> |
| | | /// 是否已读 |
| | | /// </summary> |