tzy
2021-05-25 65bcedda4d8e3ff6500dbf59a4e607d96e469375
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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<Cloud_ArmSensorHistory>(pack.Data.ToString());
                    List<string> years = new List<string>();
                    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,
            });
        }
 
 
    }
 
    /// <summary>
    /// 云端api接口返回的安防传感器历史数据对象
    /// </summary>
    public class Cloud_ArmSensorHistory
    {
        public string totalCount = "";
        public string totalPage = "";
        public string pageNo = "";
        public string pageSize = "";
        public List<ArmSensorHistory> list = new List<ArmSensorHistory>();
    }
 
    public class ArmSensorHistory
    {
        public string title = "";
        public string content = "";
        public string level = "";
        public string createTime = "";
    }
}