using System; using System.Collections.Generic; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class ArmSensorHistroyPaging { Function device; public ArmSensorHistroyPaging(Function function) { device = function; } public void InitFrame(FrameLayout FrameWhiteCentet2) { Button btnTitle = new Button() { X = Application.GetRealWidth(16), Width = Application.GetRealWidth(220), Height = Application.GetRealHeight(65), TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel, TextColor = CSS_Color.FirstLevelTitleColor, IsBold = true, TextID = StringId.Log, }; FrameWhiteCentet2.AddChidren(btnTitle); VerticalScrolViewLayout histroyView = new VerticalScrolViewLayout() { Y = btnTitle.Bottom, Height = Application.GetRealHeight(450), }; FrameWhiteCentet2.AddChidren(histroyView); var waitPage = new Loading(); FrameWhiteCentet2.AddChidren(waitPage); waitPage.Start(Language.StringByID(StringId.PleaseWait)); new System.Threading.Thread(() => { try { int pageCount = 1; var pm = new DAL.Server.HttpServerRequest(); var pack = pm.GetArmSensorHistory(device.deviceId, "20", "1"); var revData = Newtonsoft.Json.JsonConvert.DeserializeObject(pack.Data.ToString()); List years = new List(); Application.RunOnMainThread(() => { var startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区 foreach (var data in revData.list) { var yearString = startTime.AddMilliseconds(Convert.ToDouble(data.createTime)).ToString("yyyy") + Language.StringByID(StringId.Years); var monthString = startTime.AddMilliseconds(Convert.ToDouble(data.createTime)).ToString("m"); var timeString = startTime.AddMilliseconds(Convert.ToDouble(data.createTime)).ToString("HH:mm:ss"); var dateString = monthString + " " + timeString; if (!years.Contains(yearString)) { years.Add(yearString); Button btnYear = new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(46), Width = Application.GetRealWidth(220), TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.SubheadingFontSize, TextColor = CSS_Color.FirstLevelTitleColor, IsBold = true, Text = yearString, }; histroyView.AddChidren(btnYear); } var cell = new ArmSensorHistoryMsgCell() { Height = Application.GetRealHeight(50), }; histroyView.AddChidren(cell); cell.InitControl(data.content, dateString); } }); } catch { } finally { Application.RunOnMainThread(() => { waitPage.Hide(); }); } }) { IsBackground = true }.Start(); } } public class ArmSensorHistoryMsgCell : FrameLayout { Button btnMsg; Button btnTime; public void InitControl(string msg, string time) { btnMsg = new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(40), Width = Application.GetRealWidth(300), //Width = Application.GetRealWidth(220), TextAlignment = TextAlignment.CenterLeft, TextSize = CSS_FontSize.TextFontSize, TextColor = CSS_Color.FirstLevelTitleColor, Text = msg, }; this.AddChidren(btnMsg); btnTime = new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(35), Width = Application.GetRealWidth(295), //Width = Application.GetRealWidth(80), Height = Application.GetRealHeight(15), TextAlignment = TextAlignment.CenterRight, TextSize = CSS_FontSize.PromptFontSize_FirstLevel, TextColor = CSS_Color.PromptingColor1, Text = time, IsMoreLines = true }; this.AddChidren(btnTime); AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Width = Application.GetRealWidth(295), Height = 1, BackgroundColor = CSS_Color.DividingLineColor, }); } } /// /// 云端api接口返回的安防传感器历史数据对象 /// public class Cloud_ArmSensorHistory { public string totalCount = ""; public string totalPage = ""; public string pageNo = ""; public string pageSize = ""; public List list = new List(); } public class ArmSensorHistory { public string title = ""; public string content = ""; public string level = ""; public string createTime = ""; } }