using System; using System.Collections.Generic; using Shared.SimpleControl; namespace Shared { [System.Serializable] public class RemoteInfo { static RemoteInfo () { Current = Newtonsoft.Json.JsonConvert.DeserializeObject (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile ("RemoteInfoMsgList"))); if (Current == null) Current = new RemoteInfo (); } RemoteInfo () { } /// /// 从服务器读取相应数目的数据 /// /// 手机ID 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 RemoteInfoList = new List (); 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 ( 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; } }