//BalanceChecker private void BalanceCheckToastPart(string Title, string Content) { //规则 每天在6点(start)到23点(end)之间进行余额提醒 // 每次间隔为sep的值(小时) // 打开应用时会进行提醒不会受这里影响(因为在正常打开应用界面时会将设置里的stamp重置) var today = DateTime.Now; int sep = 3; int start = 6, end = 23; var today_stamp = (today.Day * (end - start) / sep + (today.Hour - start) / ((end - start) / sep)).ToString(); SettingSaver_Local temp = new SettingSaver_Local(); string BalanceCheckerResult = ""; temp.GetRecordString(NameManager.BalanceChecker, ref BalanceCheckerResult); if (HasWindow || BalanceCheckerResult != today_stamp && today.Hour < end && today.Hour > start) { temp.AlterRecordString(NameManager.BalanceChecker, today_stamp); Toasts.ToastsDef.SendNotification_TwoString(Title, Content, "BalanceReminder", null); } }
public void FindIfNewNotice(Pages PageType, bool Hresult, ReturnData HArgs) { if (PageType != Pages.GetNotice) { return; } if (HArgs.ReturnCodeMeaning != ReturnDataCodeMeaning.Success) { return; } Debug.WriteLine("|检查Notice是否有新的"); //比较通知是否有变化 var Recorder = new SettingSaver_Local(); string b_notice = ""; Recorder.GetRecordString(NameManager.LastTimeNotice, ref b_notice); if (UserConfig.notice == null) { Debug.WriteLine("|当前没有通知."); return; } if (b_notice != RecentInfo) { Recorder.AlterRecordString(NameManager.LastTimeNotice, RecentInfo); if (b_notice.Length == 0) { foreach (var m in UserConfig.notice) { Debug.WriteLine("|出现新通知,发送Notification."); SendNotification("于 " + DistTime2String(m.disttime), m.title, m.url); } } else { var serializer = new DataContractJsonSerializer(typeof(NoticeConfig)); var b_mStream = new MemoryStream(Encoding.UTF8.GetBytes(b_notice)); var b_UserConfig = (NoticeConfig)serializer.ReadObject(b_mStream); foreach (var m in UserConfig.notice) { bool HasThisNotice = false; foreach (var n in b_UserConfig.notice) { if (m.title == n.title && m.url == n.url && m.disttime == n.disttime) { HasThisNotice = true; break; } } if (HasThisNotice) { continue; } Debug.WriteLine("|出现新通知,发送Notification."); SendNotification("于 " + DistTime2String(m.disttime), m.title, m.url); } } } }
public UserPassSaver_Local() { SaverUsing = new SettingSaver_Local(); }