void sendNotification(UrlContentSnap newOne) { // 有新的出现后发送通知 if (UrlContentSnapList.Count > 1) { ToastsDef.SendNotification_TwoString("关注的网站 [" + id + "] 内容更新了", newOne.Url, "Id=" + id); } }
public async Task <bool> CheckExistance() { var local = ApplicationData.Current.LocalFolder; try { localStorageFolder = await local.GetFolderAsync(id); } catch { localStorageFolder = await local.CreateFolderAsync(id); } if (localStorageFolder == null) { return(false); } var UrlInfo = await LoadUrlInfo(); if (UrlInfo == null) { return(false); } Updating = true; var FileList = await localStorageFolder.GetFilesAsync(); var FileList_Snaps = FileList.Where(a => { if (a.Name.EndsWith(".html") || (!a.Name.StartsWith("Snap"))) { return(false); } else { return(true); } }); var Tasks = new List <Task <bool> >(); foreach (var file in FileList_Snaps) { var Snap = new UrlContentSnap(); Snap.path = file.Path; Tasks.Add(Snap.LoadFromFile()); UrlContentSnapList.Insert(0, Snap); } foreach (var m in Tasks) { await m; } if (UrlContentSnapList.Count > 0) { recentStamp = UrlContentSnapList[0].TimeStamp[0].ToString(); } Updating = false; return(true); }
public async Task CheckNow() { if (localStorageFolder == null || webURL == null || IsActivated == false) { return; } Updating = true; //string Content = await GetFromUrl(webURL); string Content = await GetFromUrl(webURL); if (Content.Count() == 0) { Updating = false; return; } UrlContentSnap newOne = new UrlContentSnap(); newOne.Content = Content; newOne.TimeStamp.Add(DateTime.Now); newOne.Url = webURL.OriginalString; newOne.path = localStorageFolder.Path + "\\Snap_" + newOne.TimeStamp.Last().ToString("yyyyMMddHHmmss"); if (UrlContentSnapList.Count > 0 && CompareToRecentRecord(UrlContentSnapList.First(), newOne)) {//same UrlContentSnapList.First().TimeStamp.Insert(0, DateTime.Now); UrlContentSnapList.First().PropertyChangeEventHappen("TimeStampShowOut"); await UrlContentSnapList.First().SaveToFile(SaveMode.Update); } else { await newOne.SaveToFile(); UrlContentSnapList.Insert(0, newOne); sendNotification(newOne); } recentStamp = newOne.TimeStamp[0].ToString(); Updating = false; }
bool CompareToRecentRecord(UrlContentSnap RecentSnap, UrlContentSnap newOne) { return((RecentSnap.Content == newOne.Content) && (RecentSnap.Url == newOne.Url)); }