| | |
| | | using System.Collections.Generic; |
| | | using System.Threading; |
| | | using HDL_ON.DAL.Server; |
| | | //#if DEBUG |
| | | //using Xamarin.Essentials; |
| | | //#endif |
| | | |
| | | namespace HDL_ON.UI |
| | | { |
| | | /// <summary> |
| | |
| | | AddMessageView(); |
| | | MenuButtonSelect(showMesType); |
| | | RegisterGetPushMessageAction(); |
| | | //测试代码 |
| | | //AddEmptyTipView(); |
| | | //TestLoad(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | void AddTopMenuView() |
| | | { |
| | | |
| | | menuView = new HorizontalScrolViewLayout() |
| | | { |
| | | Y = Application.GetRealHeight(64+10), |
| | | Y = Application.GetRealHeight(64 + 10), |
| | | Height = Application.GetRealWidth(117), |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | HorizontalScrollBarEnabled = false//隐藏滚动条 |
| | |
| | | //测试提前当前推送ID |
| | | allMenuButton.ImageButton.MouseLongEventHandler = (sender, e) => |
| | | { |
| | | //#if DEBUG |
| | | //#if DEBUG |
| | | |
| | | // CopyToClipboard("推送ID:" + OnAppConfig.Instance.PushId); |
| | | //#else |
| | | // CopyToClipboard("推送ID:" + OnAppConfig.Instance.PushId); |
| | | //#else |
| | | //检测是否获取推送ID成功,提示推送注册是否正常 |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) |
| | | { |
| | |
| | | { |
| | | Utlis.ShowTip(Language.StringByID(StringId.PushNormal)); |
| | | } |
| | | //#endif |
| | | //#endif |
| | | |
| | | }; |
| | | #endregion |
| | |
| | | X = systemMenuButton.Right, |
| | | Y = Application.GetRealWidth(16), |
| | | }; |
| | | menuView.AddChidren(propertyMenuButton); |
| | | menuView.AddChidren(propertyMenuButton); |
| | | propertyMenuButton.ImageButton.SelectedImagePath = "Collection/MesCenter/PropertyOn.png"; |
| | | propertyMenuButton.ImageButton.UnSelectedImagePath = "Collection/MesCenter/Property.png"; |
| | | propertyMenuButton.TextButton.TextID = StringId.Propertynotice; |
| | |
| | | GetPushMessageList(showMesType); |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 添加内容为空提示页面 |
| | | /// </summary> |
| | |
| | | { |
| | | var rowView = new RowLayout() |
| | | { |
| | | Height = Application.GetRealHeight(65), |
| | | Height = Application.GetRealWidth(76), |
| | | LineColor = CSS_Color.MainBackgroundColor, |
| | | }; |
| | | VerticalScrolViewMiddle.AddChidren(rowView); |
| | |
| | | var btnTilte = new TextButton() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = Application.GetRealHeight(12), |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealWidth(20), |
| | | Width = Application.GetRealWidth(258), |
| | | Height = Application.GetRealWidth(20 + 23), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | Text = pushMessageInfo.messageContent, |
| | | //IsMoreLines = true, |
| | | IsMoreLines = true, |
| | | }; |
| | | rowView.AddChidren(btnTilte); |
| | | // |
| | | var needHeight = btnTilte.GetMoreLineNeedHeight(); |
| | | btnTilte.IsMoreLines = true; |
| | | btnTilte.Height = needHeight; |
| | | rowView.Height = Application.GetRealHeight(45) + needHeight; |
| | | |
| | | //var needHeight = btnTilte.GetMoreLineNeedHeight(); |
| | | //btnTilte.IsMoreLines = true; |
| | | //btnTilte.Height = needHeight; |
| | | //rowView.Height = Application.GetRealWidth(45) + needHeight; |
| | | |
| | | |
| | | //副标题 |
| | | var btnSubtitle = new TextButton() |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Y = btnTilte.Bottom + Application.GetRealHeight(4), |
| | | Width = Application.GetRealWidth(240), |
| | | Height = Application.GetRealHeight(17), |
| | | Y = btnTilte.Bottom + Application.GetRealWidth(4), |
| | | Width = Application.GetRealWidth(258), |
| | | Height = Application.GetRealWidth(17), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.PromptFontSize_FirstLevel, |
| | |
| | | { |
| | | DeleteThePush(pushMessageInfo, rowView); |
| | | }; |
| | | |
| | | |
| | | btnDatetime.Text = GetUnixToDateTime2(pushMessageInfo.createTime); |
| | | |
| | | EventHandler<MouseEventArgs> eventHandler = (sender, e) => |
| | |
| | | btnTilte.MouseUpEventHandler = eventHandler; |
| | | btnSubtitle.MouseUpEventHandler = eventHandler; |
| | | |
| | | if (!string.IsNullOrEmpty(pushMessageInfo.messageExpandInfo.ExpantContentInfo.picUrl) && |
| | | pushMessageInfo.messageExpandInfo.ExpantContentInfo.picUrl != "null") |
| | | { |
| | | ImageView imageView = new ImageView() |
| | | { |
| | | X = Application.GetRealWidth(291), |
| | | Y = Application.GetRealWidth(8), |
| | | Width = Application.GetRealWidth(52), |
| | | Height = Application.GetRealWidth(32), |
| | | Radius = (uint)Application.GetRealWidth(4), |
| | | BorderColor = 0x00FFFFFF, |
| | | BorderWidth = 1, |
| | | ImagePath = "Collection/MesCenter/default_image.png" |
| | | }; |
| | | rowView.AddChidren(imageView); |
| | | |
| | | imageView.MouseUpEventHandler = (sender, e) => { |
| | | Dialog dialog = new Dialog(); |
| | | |
| | | var dialogView = new FrameLayout(); |
| | | dialog.AddChidren(dialogView); |
| | | dialogView.MouseUpEventHandler = (sender, e) => { |
| | | dialog.Close(); |
| | | }; |
| | | var dialogContentView = new ImageView() |
| | | { |
| | | Width = Application.GetRealWidth(375), |
| | | Height = Application.GetRealWidth(211), |
| | | ImageBytes = imageView.ImageBytes, |
| | | Gravity = Gravity.Center, |
| | | }; |
| | | dialogView.AddChidren(dialogContentView); |
| | | |
| | | dialog.Show(); |
| | | }; |
| | | |
| | | new Thread(() => { |
| | | var headImageBytes = HttpUtil.HttpsDownload(pushMessageInfo.messageExpandInfo.ExpantContentInfo.picUrl); |
| | | if (headImageBytes != null && headImageBytes.Length > 0) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | imageView.ImageBytes = headImageBytes; |
| | | }); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | { |
| | | //PushMessageInfoList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PushMessageInfo>>(result.Data.ToString()); |
| | | //2021-08-28 改为分页接口 |
| | | MainPage.Log(result.Data.ToString()); |
| | | var mPushMesList = Newtonsoft.Json.JsonConvert.DeserializeObject<PushMessageInfoList>(result.Data.ToString()); |
| | | if (mPushMesList != null) |
| | | { |
| | |
| | | { |
| | | if (PushMessageInfoList != null && PushMessageInfoList.Count > 0) |
| | | { |
| | | |
| | | ParseAndDisplayPushList(); |
| | | PushSerivceMarkAllMessageRead(); |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log("Error", $"获取推送消息列表异常:{ex.StackTrace}"); |
| | | } |
| | | finally |
| | | { |
| | |
| | | /// </summary> |
| | | void ParseAndDisplayPushList() |
| | | { |
| | | bodyScrolView.RemoveAll(); |
| | | foreach (var info in PushMessageInfoList) |
| | | { |
| | | //年份解析 判断是否需要添加年份标题 |
| | |
| | | /// <param name="pushMessageInfo"></param> |
| | | void OnClickPushMessageInfo(PushMessageInfo pushMessageInfo) |
| | | { |
| | | |
| | | if (pushMessageInfo.pushType == PushType.Notice.ToString()) |
| | | { |
| | | //Utlis.WriteLine("物业通知"); |
| | | string noticeId = GetNoticeId(pushMessageInfo.messageExpand); |
| | | if (!string.IsNullOrEmpty(noticeId)) |
| | | try |
| | | { |
| | | GetPropertyNoticeDetails(noticeId); |
| | | //Utlis.WriteLine("物业通知"); |
| | | if (!string.IsNullOrEmpty(pushMessageInfo.messageExpand)) |
| | | { |
| | | GetPropertyNoticeDetails(pushMessageInfo.messageExpandInfo.targetId); |
| | | } |
| | | else |
| | | { |
| | | Utlis.WriteLine("noticeId null"); |
| | | } |
| | | } |
| | | else |
| | | catch (Exception ex) |
| | | { |
| | | Utlis.WriteLine("noticeId null"); |
| | | MainPage.Log("Error", $"通知信息点击事件:{ex.StackTrace}"); |
| | | } |
| | | } |
| | | else |
| | |
| | | Utlis.WriteLine("其它通知类型"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 解析messageExpand 提取targetId |
| | | /// </summary> |
| | | /// <param name="messageExpand"></param> |
| | | /// <returns></returns> |
| | | string GetNoticeId(string messageExpand) |
| | | { |
| | | try |
| | | { |
| | | if (!string.IsNullOrEmpty(messageExpand)) |
| | | { |
| | | var mMessageExpandInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageExpandInfo>(messageExpand); |
| | | if (mMessageExpandInfo != null) |
| | | { |
| | | var mExpantContentInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ExpantContentInfo>(mMessageExpandInfo.expantContent); |
| | | if(mExpantContentInfo != null) |
| | | { |
| | | return mExpantContentInfo.targetId; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | catch |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | #region 测试 |
| | | #if DEBUG |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | void TestLoad() |
| | | { |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | messageTitle = "报警信息", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1606900275, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | messageTitle = "报警信息1", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1606895454, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | messageTitle = "报警信息2", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1606895454, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | messageTitle = "报警信息2019", |
| | | messageContent = "门锁被打开", |
| | | createTime = 1575277874, |
| | | }); |
| | | |
| | | PushMessageInfoList.Add(new PushMessageInfo() |
| | | { |
| | | 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> |
| | | /// 标记所有推送消息已读 |
| | |
| | | { |
| | | Utlis.WriteLine("标记失败"); |
| | | } |
| | | |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | |
| | | { |
| | | if (bodyView != null) |
| | | { |
| | | |
| | | //Utlis.WriteLine("GetPushMessageAction M收到推送"); |
| | | GetPushMessageList(showMesType); |
| | | } |
| | |
| | | { |
| | | 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> |
| | | public string messageExpand; |
| | | MessageExpand _messageExpandInfo; |
| | | public MessageExpand messageExpandInfo |
| | | { |
| | | get |
| | | { |
| | | if (_messageExpandInfo == null) |
| | | { |
| | | if (!string.IsNullOrEmpty(messageExpand)) |
| | | { |
| | | _messageExpandInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<MessageExpand>(messageExpand); |
| | | } |
| | | else |
| | | { |
| | | _messageExpandInfo = new MessageExpand(); |
| | | } |
| | | } |
| | | return _messageExpandInfo; |
| | | } |
| | | } |
| | | ///// <summary> |
| | | ///// 消息类型;0:提示;1:报警;2:丰林可是对讲呼叫;3:强制下线推送 |
| | | ///// </summary> |
| | |
| | | public long createTime; |
| | | } |
| | | |
| | | [System.Serializable] |
| | | public class MessageExpand |
| | | { |
| | | /// <summary> |
| | | /// 扩展数据内容 |
| | | /// </summary> |
| | | public string expantContent; |
| | | private ExpantContent _expantContent; |
| | | public ExpantContent ExpantContentInfo |
| | | { |
| | | get |
| | | { |
| | | if (_expantContent == null) |
| | | { |
| | | if (!string.IsNullOrEmpty(expantContent)) |
| | | { |
| | | _expantContent = Newtonsoft.Json.JsonConvert.DeserializeObject<ExpantContent>(expantContent); |
| | | } |
| | | else |
| | | { |
| | | _expantContent = new ExpantContent(); |
| | | } |
| | | } |
| | | return _expantContent; |
| | | } |
| | | } |
| | | |
| | | public string homeId; |
| | | |
| | | public int messageLevel; |
| | | |
| | | public string messageType; |
| | | |
| | | public string targetId; |
| | | |
| | | } |
| | | |
| | | [System.Serializable] |
| | | public class ExpantContent |
| | | { |
| | | public string currentTime; |
| | | public string picUrl; |
| | | public string devSerial; |
| | | public string interphoneTypeEnum; |
| | | public string subToken; |
| | | public string deviceSid; |
| | | public string msgId; |
| | | public string type; |
| | | public string pushTime; |
| | | public string extDevId; |
| | | public string deviceId; |
| | | public string spk; |
| | | } |
| | | |
| | | /// <summary> |
| | | // 推送消息分页对象 |
| | |
| | | [System.Serializable] |
| | | public class MessageExpandInfo |
| | | { |
| | | /// <summary> |
| | | /// expantContent |
| | | /// </summary> |
| | | public string expantContent; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 推送扩展信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class ExpantContentInfo |
| | | { |
| | | /// <summary> |
| | | /// targetId |
| | | /// </summary> |
| | | public string targetId; |
| | | /// <summary> |
| | | /// messageType |
| | | /// </summary> |
| | | public string messageType; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |