1
wxr
2023-03-31 7e42cc13a14b7de31c9f5d5c61cdf24f3246335d
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
using System;
using System.Collections.Generic;
using Shared.SimpleControl;
 
namespace Shared
{
    [System.Serializable]
    public class RemoteInfo
    {
        static RemoteInfo ()
        {
            Current = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoteInfo> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile ("RemoteInfoMsgList")));
            if (Current == null)
                Current = new RemoteInfo ();
        }
 
        RemoteInfo ()
        {
 
        }
 
        /// <summary>
        /// 从服务器读取相应数目的数据
        /// </summary>
        /// <param name="rsgID">手机ID</param>
        public void ReadMsgList (string rsgID, bool needTip)
        {
            if (MainPage.LoginUser == null)
                return;
#if HDL
            System.Threading.Tasks.Task.Run (() => {
                var se = new service.hdlcontrol.com_push.WebServicePush ();
                var msgList = se.MsgList (rsgID);
                foreach (var msg in msgList) {
                    Current.RemoteInfoList.Add (new RemoteInfoMsg () { Msg = msg.Msg, MsgID = msg.MsgID, MsgTime = msg.MsgTime, MsgType = msg.MsgType });
                }
                Current.Save ();
                if (msgList.Length > 0) {
                    Application.RunOnMainThread (() => {
                        string tipMsg = Language.StringByID (SimpleControl.R.MyInternationalizationString.NewMessageReceived);
 
                        if (needTip) {
                            Alert alert = new Alert (Language.StringByID (SimpleControl.R.MyInternationalizationString.Tip),
                                                     tipMsg ,
                                                     Language.StringByID (SimpleControl.R.MyInternationalizationString.Close),
                                                     Language.StringByID (SimpleControl.R.MyInternationalizationString.Read));
                            alert.Show ();
                            alert.ResultEventHandler += (sender, e) => {
                                if (e) {
                                    if (Shared.Application.IsPad) {
                                        //SimpleControl.Pad.WarningList.ShowWarningListPage ();
                                    } else {
                                        SimpleControl.Phone.UserMiddle.ShowSettingView ();
                                        var msgView = new SimpleControl.Phone.WarningList ();
                                        SimpleControl.Phone.UserMiddle.SettingPageView.AddChidren (msgView);
                                        msgView.ShowWarningListPage ();
                                        SimpleControl.Phone.UserMiddle.SettingPageView.PageIndex = 1;
                                    }
                                }
                            };
                        } else {
                            if (Shared.Application.IsPad) {
                                //SimpleControl.Pad.WarningList.ShowWarningListPage ();
                            } else {
                                SimpleControl.Phone.UserMiddle.ShowSettingView ();
                                var msgView = new SimpleControl.Phone.WarningList ();
                                SimpleControl.Phone.UserMiddle.SettingPageView.AddChidren (msgView);
                                msgView.ShowWarningListPage ();
                                SimpleControl.Phone.UserMiddle.SettingPageView.PageIndex = 1;
                            }
                        }
                    });
                }
            });
#endif
        }
 
        public static RemoteInfo Current {
            get;
            private set;
        }
 
        public List<RemoteInfoMsg> RemoteInfoList = new List<RemoteInfoMsg> ();
 
        public void Add (RemoteInfoMsg msg)
        {
            RemoteInfoList.Add (msg);
            Save ();
        }
 
        public void Del (RemoteInfoMsg msg)
        {
            RemoteInfoList.Remove (msg);
            Save ();
        }
 
        public void CleanAll ()
        {
            Current.RemoteInfoList.Clear ();
            var saveBytes = CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (Current));
            IO.FileUtils.WriteFileByBytes ("RemoteInfoMsgList", saveBytes);
        }
 
        public void Save ()
        {
            var saveBytes = CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (Current));
            IO.FileUtils.WriteFileByBytes ("RemoteInfoMsgList", saveBytes);
        }
 
        public RemoteInfo Get ()
        {
            var remoteInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoteInfo> (
                CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile ("RemoteInfoMsgList")));
            //this = remoteInfo;
            if (remoteInfo == null)
                return new RemoteInfo ();
            else
                return remoteInfo;
        }
    }
 
    [System.Serializable]
    public class RemoteInfoMsg
    {
        public long MsgID;
 
        public string Msg;
 
        public string MsgType;
 
        public DateTime MsgTime;
 
    }
}