static void Main(string[] args) { //RssFeed feed; //feed = new RssFeed("https://www.heise.de/rss/heise-atom.xml", 7); //feed.Refresh(); //feed.MarkAllItemsAsRead(); //Print(feed.Items); //feed = new RssFeed("https://rss.golem.de/rss.php?feed=ATOM1.0", 7); //feed.Refresh(); //Print(feed.Items); Feeds feeds = new Feeds(); feeds.Add("https://www.heise.de/rss/heise-atom.xml"); feeds.Add("https://rss.golem.de/rss.php?feed=ATOM1.0"); foreach (RssFeed f in feeds.FeedList) { f.Refresh(); Print(f.Items); } Console.ReadLine(); }
public void AddCurrentFeed() { Feeds.Add(CurrentFeed); IsFeedAddedMessageShowing = true; DoAfterDelay(5000, () => IsFeedAddedMessageShowing = false); var withoutAwait = SaveFeedsAsync(); }
public FeedsSearchingPage() { Feeds.Add(new FeedViewModel("请输入要你需要订阅的网站", "", "", "NoPic")); AddPaperPage.isFeedsSearchingPageActive = true; AddPaperPage.isThereFeed = false; this.InitializeComponent(); }
private async Task Filter() { TokenSource.Cancel(); var query = from feed in await RSSDataService.GetFeedsDataAsync(0) select feed; if (FilterSelectedSource != null) { query = query.Where(x => x.PostSource.Id == FilterSelectedSource.Id); } if (!string.IsNullOrWhiteSpace(FilterTitle)) { query = query.Where(x => x.PostTitle.ToLower().Contains(FilterTitle.ToLower())); } if (!string.IsNullOrWhiteSpace(FilterCreator)) { query = query.Where(x => x.Authors.Any(x => x.Email.ToLower() == FilterCreator.ToLower())); } if (FilterIsUnreadOnly) { query = query.Where(x => x.IsRead == false); } Feeds.Clear(); foreach (var item in query) { Feeds.Add(item); } }
/// <summary> /// Adds the current feed (in the Add Feed view) to the list of saved feeds. /// </summary> public void AddCurrentFeed() { Feeds.Add(CurrentFeed); NameOfFeedJustAdded = CurrentFeed.Name; IsFeedAddedMessageShowing = true; Helpers.DoAfterDelay(5000, () => IsFeedAddedMessageShowing = false); }
public MainViewModel() { TorrentDropDirectory = DROP_FOLDER; if (!Directory.Exists(Path.GetDirectoryName(TorrentDropDirectory))) { Directory.CreateDirectory(Path.GetDirectoryName(TorrentDropDirectory)); } Feed tvFeed = new Feed() { Title = "TV Shows", URL = "https://kickass.to/tv/?rss=1" }; Feeds.Add(tvFeed); Feeds.Add(new Feed() { Title = "Movies", URL = "https://kickass.to/movies/?rss=1" }); Feeds.Add(new Feed() { Title = "Music", URL = "https://kickass.to/music/?rss=1" }); Filter tvFilter = new Filter() { Enabled = false, SearchInFeed = tvFeed, TitleFilter = "*", IgnoreCaps = true, Include = "", Exclude = "1080p;HDTV;", IsTV = false }; Filters.Add(tvFilter); SelectedFeed = tvFeed; SelectedFilter = tvFilter; }
public void AddNewFeed() { Feeds.Add(NewFeedBookmark); NewFeedBookmark = new FeedBookmarkItem(); HasChanges = true; Feeds.FireChange(); }
public void EnterModelContext(NavigationContext oldContext, NavigationContext newContext) { // Load settings NewsSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <NewsSettings>(); HasChanges = false; NewFeedBookmark = new FeedBookmarkItem(); Feeds.Clear(); lock (settings.FeedsList) { if (settings.FeedsList.Count == 0) { foreach (var feed in NewsSettings.GetDefaultRegionalFeeds()) { Feeds.Add(new FeedBookmarkItem { Name = feed.Name, Url = feed.Url }); } } else { foreach (var feed in settings.FeedsList) { Feeds.Add(new FeedBookmarkItem { Name = feed.Name, Url = feed.Url }); } } } }
public void ExecuteNewFeed(object parameter) { Feed f = new Feed(); Feeds.Add(f); SelectedFeed = f; tRSS.View.EditFeed edit = new tRSS.View.EditFeed(f); edit.Show(); onPropertyChanged("CountFeeds"); }
private void newFeedSaved(FeedVM.NewFeedSavedEvent e) { Feeds.Add(new FeedVM(e.Feed)); //Feeds = new ObservableCollection<FeedVM>(); //var feeds = Repository.Instance.GetAllFeeds(); //foreach (DAL.Feed item in feeds) //{ // var fvm = new FeedVM(item); // Feeds.Add(fvm); //} //NotifyPropertyChanged(nameof(Feeds)); }
public void AddFeed(IRSSFeed feed) { RssLock.EnterWriteLock(); try { Feeds.Add(feed); } finally { RssLock.ExitWriteLock(); } }
public async Task LoadFeedsAsync() { IsLoading = true; Feeds.Clear(); var results = await _feedService.GetFeeds(); foreach (var feedDto in results) { Feed feed = AutoMapper.Mapper.Map <Feed>(feedDto); Feeds.Add(feed); } IsLoading = false; }
public void Add() { var feed = new Feed(); if (Feeds.Count > 0) { feed.ID = Feeds.Select(f => f.ID).Max() + 1; } else { feed.ID = 0; } feed.Parent = this; Feeds.Add(feed); }
public void Merge(FeedManager secondFeedManager) { // TODO: secondFeedManager wins; improve Merge so that local offline changes are not lost. ItemLifetime = secondFeedManager.ItemLifetime; MaxItemsLimit = secondFeedManager.MaxItemsLimit; foreach (var feed in Feeds.ToArray()) { Feeds.Remove(feed); } foreach (var feed in secondFeedManager.Feeds) { Feeds.Add(feed); } }
private async void SearchButton_Click(object sender, RoutedEventArgs e) { searchingProgressRing.IsActive = true; Feeds.Clear(); List <Uri> feedUrls = new List <Uri>(); //Semaphore semaphore = new Semaphore(0, feedUrls.Count); try { if (((Button)sender).Content.ToString() == "Feedly") { feedUrls = await FeedsFinder.SearchFromFeedly(websiteTextBox.Text); } else { feedUrls = await FeedsFinder.GetFeedsFromUrl(new Uri(websiteTextBox.Text)); } var client = new SyndicationClient(); List <FeedViewModel> feeds = new List <FeedViewModel>(); Parallel.ForEach(feedUrls, async(url, loopstat) => { try { var feed = await client.RetrieveFeedAsync(url); lock (feeds) { Invoke(() => { Feeds.Add(new FeedViewModel(feed, url.AbsoluteUri)); }); System.Diagnostics.Debug.WriteLine("循环内"); } } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); } }); } catch (Exception) { Feeds.Add(new FeedViewModel("无结果或链接错误", "", "", "Nopic")); } System.Diagnostics.Debug.WriteLine("循环外"); Invoke(() => searchingProgressRing.IsActive = false); }
private async void ShowFeeds() { Feeds.Clear(); if (FeedURLs != null) { foreach (string url in FeedURLs.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) { var puri = new ParsedUri(url); var parsedDoc = await _sessionScope.GetDocument(puri); var feedViewModels = FeedViewModelFactory.GetFeedViewModels(parsedDoc); foreach (var viewModel in feedViewModels) { Feeds.Add(viewModel); } this.NotifyPropertyChanged("Feeds"); } } }
private void OnOnUpdateFeedList(object sender, EventArgs eventArgs) { Dispatcher.Invoke(new Action(() => { var realList = GameFeedManager.Get().GetFeeds().ToList(); foreach (var f in Feeds.ToArray()) { if (realList.All(x => x.Name != f.Name)) { Feeds.Remove(f); } } foreach (var f in realList) { if (this.Feeds.All(x => x.Name != f.Name)) { Feeds.Add(f); } } })); }
public void GetFeeds() { try { IsBusy = true; if (App.AppKey != string.Empty) { var json = Preferences.Get("AllFeeds", string.Empty); var result = JsonConvert.DeserializeObject <IEnumerable <Feeds> >(json); if (result != null) { foreach (var item in result) { if (item.type == "Video") { try { //item.VidImage = vconvert.GenerateThumbImage(item.mediaUrl, 1); item.VidImage = "https://investorpresentations.co.za/videos/placeholder_1080.jpg"; } catch (Exception ex) { } } Feeds.Add(item); } } } IsBusy = false; //await PopupNavigation.PopAsync(); } catch (Exception ex) { //await PopupNavigation.PopAsync(); IsBusy = false; MessageDialog.Show("Error!", "Error occured while getting feeds", "Cancel"); } }
public FeedHandlerConfigWindowViewModel(LogViewer logViewer) { AddItem = ReactiveCommand.Create(() => Feeds.Add( new FeedHandlerConfig { CheckEveryMinutes = 15, Regex = ".*" })); DelItem = ReactiveCommand.Create <string>(url => Feeds.Remove(Feeds.First(f => f.Url == url))); SaveItems = ReactiveCommand.Create(async() => { await Helpers.SaveConfigFile <FeedHandler>(Feeds.ToList()); CloseWindow.OnNext(true); }); Cancel = ReactiveCommand.Create(() => CloseWindow.OnNext(false)); ViewLogs = ReactiveCommand.Create(async() => { if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { var window = new Window { Height = 400, Width = 1200, Content = logViewer }; await window.ShowDialog(desktop.MainWindow); } }); var config = Helpers.GetConfig <FeedHandler, List <FeedHandlerConfig> >(); if (config.Count == 0) { AddItem.Execute().Subscribe(); } else { config.ForEach(c => Feeds.Add(c)); } }
private void UpdateFeeds(bool fromRepository) { var selectedFeed = SelectedFeed; Feeds.Where(f => f != _allFeeds).ToList().ForEach(f => Feeds.Remove(f)); if (fromRepository) { _realFeeds = _repository.GetFeeds().OrderBy(f => f.Title).ToList(); UpdatePosts(true); } _realFeeds.ForEach(f => Feeds.Add(f)); if (Feeds.Contains(selectedFeed)) { SelectedFeed = selectedFeed; } else { SelectedFeed = _allFeeds; } }
/// <summary> /// Populates the Feeds list and initializes the CurrentFeed and CurrentArticle properties. /// </summary> public async Task InitializeFeedsAsync() { Feeds.Clear(); (await FeedDataSource.GetFeedsAsync()).ForEach(feed => Feeds.Add(feed)); CurrentFeed = Feeds[Feeds.Count == 1 ? 0 : 1]; CurrentArticle = CurrentFeed.Articles.FirstOrDefault() ?? CurrentArticle; if (FavoritesFeed.Articles.Count == 0) { FavoritesFeed.ErrorMessage = NO_ARTICLES_MESSAGE; } FavoritesFeed.Articles.CollectionChanged += async(s, e) => { // This handles list saving for both newly-starred items and for // reordering of the Favorites list (which causes a Remove followed by an Add). // List saving for removals due to an unstarring are handled in FeedView.xaml.cs. if (e.Action == NotifyCollectionChangedAction.Add) { await SaveFavoritesAsync(); } FavoritesFeed.ErrorMessage = FavoritesFeed.Articles.Count > 0 ? null : NO_ARTICLES_MESSAGE; }; Initialized?.Invoke(this, EventArgs.Empty); }
public void LoadFeedsFromStorage() { Feeds.Clear(); Bookmarks.Clear(); if (Directory.Exists(FeedDirectory)) { foreach (var feed_file in Directory.GetFiles(FeedDirectory, "*.feed")) { Feed feed; using (var file = new StreamReader(feed_file)) feed = Feed.Deserialize(Path.GetFileNameWithoutExtension(feed_file), file.ReadToEnd()); foreach (var post_file in Directory.GetFiles(Path.Combine(FeedDirectory, feed.ID), "*.post")) { Feed.Post post; using (var file = new StreamReader(post_file)) post = Feed.Post.Deserialize(feed, Path.GetFileNameWithoutExtension(post_file), file.ReadToEnd()); feed.Posts.Add(post); } feed.Posts.Sort((x, y) => y.DatePublished.CompareTo(x.DatePublished)); Feeds.Add(feed); } foreach (var bookmark_file in Directory.GetFiles(Path.Combine(FeedDirectory, "bookmarks"), "*.bookmark")) { Bookmark bookmark; using (var file = new StreamReader(bookmark_file)) bookmark = Bookmark.Deserialize(Path.GetFileNameWithoutExtension(bookmark_file), file.ReadToEnd()); Bookmarks.Add(bookmark); } } else { Directory.CreateDirectory(Path.Combine(FeedDirectory, "bookmarks")); } }
private void CacheHamburgerMenuItems() { foreach (var item in Items) { HamburgerMenuItem menuItem = null; if (item is HamburgerMenuItem) { menuItem = item as HamburgerMenuItem; if ((int)menuItem.IconWidth == 0) { menuItem.IconWidth = CompactPaneWidth; } if (ItemsSource == null || !ItemsSource.GetEnumerator().MoveNext()) { var newFeed = new ItemFeed { Command = menuItem.Command, IconContent = menuItem.Content, Tooltip = menuItem.ToolTip, Label = menuItem.Text, Key = menuItem.GetHashCode() }; Feeds.Add(newFeed); } } else { menuItem = (HamburgerMenuItem)ItemContainerGenerator.ContainerFromItem(item); } menuItem.BarBrush = BarBrush; itemController.AddItem(menuItem); } }
public async Task AddFeedAsync(string feed_url) { var found_feed_urls = from url in await FeedReader.GetFeedUrlsFromUrlAsync(feed_url) select url.Url; if (found_feed_urls.Count() > 0) { var blog_url = found_feed_urls.First(); feed_url = blog_url.StartsWith('/') ? $"{feed_url.TrimEnd('/')}{blog_url}" : blog_url; } if (Feeds.Any(f => f.FeedLink == feed_url)) { throw new Exception("There's already a feed with that url."); } else { var parsed_feed = await FeedReader.ReadAsync(feed_url); var feed_uri = new Uri(parsed_feed.Link); var feed_title = string.IsNullOrWhiteSpace(parsed_feed.Title) ? feed_uri.Host : parsed_feed.Title; var feed_id = AvoidFeedIdCollision(MakeSafeId(feed_title)); string feed_image_path = await DownloadFeedImageAsync(feed_id, parsed_feed.ImageUrl, feed_uri.Host); var feed = new Feed(feed_id, feed_url) { Title = feed_title, Link = $"{feed_uri.Scheme}://{feed_uri.Host}", ImagePath = feed_image_path, DateLastUpdated = parsed_feed.LastUpdatedDate is null ? DateTime.Now : (DateTime)parsed_feed.LastUpdatedDate, Description = ExtractTextFromHtml(parsed_feed.Description) }; await WriteToFileAsync(Path.Combine(FeedDirectory, $"{feed_id}.feed"), feed.Serialize()); Directory.CreateDirectory(Path.Combine(FeedDirectory, feed_id)); await AddPostsToFeedAsync(feed, parsed_feed.Items); Feeds.Add(feed); } string AvoidFeedIdCollision(string id) { var pre_path = Path.Combine(FeedDirectory, id); if (Directory.Exists($"{pre_path}.feed")) { int suffix = 2; while (Directory.Exists($"{pre_path}_{suffix}.feed")) { suffix++; } id = $"{id}_{suffix}"; } return(id); } async Task <string> DownloadFeedImageAsync(string feed_id, string feed_image_url, string feed_host) { string feed_image_path = null; if (string.IsNullOrEmpty(feed_image_url)) { try { var web_client = new WebClient(); web_client.Headers.Add(HttpRequestHeader.UserAgent, "Fidd RSS Reader v1.0"); var favicon_api_response = await web_client.DownloadStringTaskAsync($"http://favicongrabber.com/api/grab/{feed_host}"); var deserialized_response = JsonConvert.DeserializeObject <FaviconGrabberResponse>(favicon_api_response); if (deserialized_response.Icons.Count > 0) { feed_image_url = deserialized_response.Icons.First().Source; } } catch (Exception e) {; } } if (!string.IsNullOrEmpty(feed_image_url)) { if (feed_image_url.StartsWith("data:image/")) { feed_image_url = feed_image_url.Substring(11); var image_extension = feed_image_url.Substring(0, feed_image_url.IndexOf(';')); feed_image_path = $"{feed_id}.{image_extension}"; var image_data_base64 = feed_image_url.Substring(feed_image_url.IndexOf(',') + 1); await File.WriteAllBytesAsync(Path.Combine(FeedDirectory, feed_image_path), Convert.FromBase64String(image_data_base64)); } else { var downloader = new WebClient(); string image_extension = ExtractExtensionFromUrl(feed_image_url); feed_image_path = $"{feed_id}{image_extension}"; await downloader.DownloadFileTaskAsync(feed_image_url, Path.Combine(FeedDirectory, feed_image_path)); } } return(feed_image_path); } }
private void cmdAddFeed_Click(object sender, EventArgs e) { oFeeds.Add(new Feed(txtNewLink.Text)); lvwFeeds.Items.Add(new ListViewItem(new[] { txtNewLink.Text })); }
/// <summary> /// Gets all the feeds from database (with-in limits in settings) /// the try to gets all the new stuff from your sources /// add the new ones to the database if there is any /// then show the latest (with-in limits in settings) /// </summary> /// <param name="progress"></param> /// <param name="token"></param> /// <returns>Task Type</returns> public async Task LoadDataAsync(IProgress <int> progress, CancellationToken token) { IsLoadingData = true; FilterSources.Clear(); Feeds.Clear(); ProgressCurrent = 0; bool hasLoadedFeedNewItems = false; // Shows the user what's new in this version await WhatsNewDisplayService.ShowIfAppropriateAsync(); // Set Httpclient userAgent to the user selected one await RssRequest.SetCustomUserAgentAsync(); foreach (var rss in await RSSDataService.GetFeedsDataAsync(await ApplicationData.Current.LocalSettings.ReadAsync <int>("FeedsLimit"))) { Feeds.Add(rss); } SyndicationFeed feed = null; var sourcesDataList = await SourceDataService.GetSourcesDataAsync(); ProgressMax = sourcesDataList.Count(); int progressCount = 0; foreach (var source in sourcesDataList) { FilterSources.Add(source); if (token.IsCancellationRequested) { IsLoadingData = false; TokenSource = new CancellationTokenSource(); MarkAsReadCommand.OnCanExecuteChanged(); return; } } // if there is no internet just cut our loses and get out of here we already loaded the local data if (!new NetworkInformationHelper().HasInternetAccess) { await new MessageDialog("CheckInternetMessageDialog".GetLocalized()).ShowAsync(); return; } var WaitAfterLastCheckInMinutes = await ApplicationData.Current.LocalSettings.ReadAsync <int>("WaitAfterLastCheck"); foreach (var sourceItem in FilterSources) { bool isFirstItemInFeed = true; if (token.IsCancellationRequested) { IsLoadingData = false; TokenSource = new CancellationTokenSource(); MarkAsReadCommand.OnCanExecuteChanged(); return; } // don't get source feed if x number of minutes haven't passed since the last one - default is 2 hours var checkSourceAfter = sourceItem.LastBuildCheck.AddMinutes(WaitAfterLastCheckInMinutes); if (checkSourceAfter >= DateTimeOffset.Now) { continue; } if (!new NetworkInformationHelper().HasInternetAccess) { continue; } progress.Report(++progressCount); //if getting the feed crushed for (internet - not xml rss - other reasons) //move to the next source on the list to try it instead of stopping every thing try { var feedString = await RssRequest.GetFeedAsStringAsync(sourceItem.RssUrl, token); feed = new SyndicationFeed(); if (string.IsNullOrWhiteSpace(feedString)) { continue; } else { feed.Load(feedString); // Saves rss items count and last check time to source sourceItem.CurrentRssItemsCount = feed.Items.Count; sourceItem.LastBuildCheck = DateTimeOffset.Now; await SourceDataService.UpdateSourceAsync(sourceItem); } } catch (Exception ex) { Debug.WriteLine(ex); continue; } // Iterate through each feed item. foreach (SyndicationItem syndicationItem in feed.Items) { if (token.IsCancellationRequested) { IsLoadingData = false; TokenSource = new CancellationTokenSource(); MarkAsReadCommand.OnCanExecuteChanged(); return; } //handle edge cases like when they don't send that stuff or misplace them like freaking reddit r/worldnews if (syndicationItem.Title == null) { syndicationItem.Title = new SyndicationText("MainViewModelNoTitleFound".GetLocalized()); } if (syndicationItem.Summary == null) { syndicationItem.Summary = new SyndicationText("MainViewModelNoSummaryFound".GetLocalized()); } if (syndicationItem.PublishedDate.Year < 2000) { syndicationItem.PublishedDate = syndicationItem.LastUpdatedTime.Year > 2000 ? syndicationItem.LastUpdatedTime : DateTimeOffset.Now; } Uri itemNewUri = syndicationItem.ItemUri; if (itemNewUri == null) { if (syndicationItem.Links.Count > 0) { itemNewUri = syndicationItem.Links.FirstOrDefault().Uri; } } if (string.IsNullOrWhiteSpace(syndicationItem.Id)) { syndicationItem.Id = itemNewUri.ToString(); } var rss = new RSS { PostTitle = syndicationItem.Title.Text, Description = syndicationItem.Summary.Text, Authors = new List <Author>(), URL = itemNewUri, CreatedAt = syndicationItem.PublishedDate.DateTime, Guid = syndicationItem.Id, PostSource = sourceItem }; foreach (var author in syndicationItem.Authors) { rss.Authors.Add(new Author { Name = author.Name, Email = author.Email, Uri = author.Uri }); } if (!await RSSDataService.FeedExistAsync(rss)) { var newRss = await RSSDataService.AddNewFeedAsync(rss); Feeds.Add(newRss); hasLoadedFeedNewItems = true; // Add first item in each source feed to Windows Live Tiles if (isFirstItemInFeed) { Singleton <LiveTileService> .Instance.SampleUpdate(newRss.PostSource.SiteTitle, ShortenText(newRss.PostTitle, 80), ShortenText(newRss.Description, 95)); } isFirstItemInFeed = false; } } } if (hasLoadedFeedNewItems) { Feeds.Clear(); foreach (var rss in await RSSDataService.GetFeedsDataAsync(await ApplicationData.Current.LocalSettings.ReadAsync <int>("FeedsLimit"))) { Feeds.Add(rss); } } IsLoadingData = false; MarkAsReadCommand.OnCanExecuteChanged(); }
private void OnAddFeedExecute() { Feeds.Add(new NuGetFeed(DefaultSourceName, DefaultFeed, true)); }
/// <summary> /// Gets all the feeds from database (with-in limits in settings) /// the try to gets all the new stuff from your sources /// add the new ones to the database if there is any /// then show the latest (with-in limits in settings) /// </summary> /// <param name="progress"></param> /// <param name="ct"></param> /// <returns>Task Type</returns> public async Task LoadDataAsync(IProgress <int> progress, CancellationToken token) { IsLoadingData = true; FilterSources.Clear(); Feeds.Clear(); bool hasLoadedFeedNewItems = false; foreach (var rss in await RSSDataService.GetFeedsDataAsync(await ApplicationData.Current.LocalSettings.ReadAsync <int>("FeedsLimit"))) { Feeds.Add(rss); } SyndicationFeed feed = new SyndicationFeed(); var sourcesDataList = await SourceDataService.GetSourcesDataAsync(); ProgressMax = sourcesDataList.Count(); ProgressCurrent = 0; int progressCount = 0; foreach (var source in sourcesDataList) { FilterSources.Add(source); if (token.IsCancellationRequested) { IsLoadingData = false; return; } } // if there is no internet just cut our loses and get out of here we already loaded the local data if (!new NetworkInformationHelper().HasInternetAccess) { await new MessageDialog("CheckInternetMessageDialog".GetLocalized()).ShowAsync(); return; } foreach (var sourceItem in FilterSources) { if (token.IsCancellationRequested) { IsLoadingData = false; return; } if (!new NetworkInformationHelper().HasInternetAccess) { continue; } progress.Report(++progressCount); //if getting the feed crushed for (internet - not xml rss - other reasons) //move to the next source on the list to try it instead of stoping every thing try { var feedString = await RssRequest.GetFeedAsStringAsync(sourceItem.RssUrl); if (string.IsNullOrWhiteSpace(feedString)) { continue; } else { var xmlFeed = feedString.TrimStart(); feed.Load(xmlFeed); } } catch (Exception ex) { Debug.WriteLine(ex); continue; } // Iterate through each feed item. foreach (SyndicationItem syndicationItem in feed.Items) { if (token.IsCancellationRequested) { IsLoadingData = false; return; } //handle edge cases like when they don't send that stuff or misplace them like freaking reddit r/worldnews if (syndicationItem.Title == null) { syndicationItem.Title = new SyndicationText("MainViewModelNoTitleFound".GetLocalized()); } if (syndicationItem.Summary == null) { syndicationItem.Summary = new SyndicationText("MainViewModelNoSummaryFound".GetLocalized()); } if (syndicationItem.PublishedDate.Year < 2000) { syndicationItem.PublishedDate = syndicationItem.LastUpdatedTime.Year > 2000 ? syndicationItem.LastUpdatedTime : DateTimeOffset.Now; } Uri itemNewUri = syndicationItem.ItemUri; if (itemNewUri == null) { if (syndicationItem.Links.Count > 0) { itemNewUri = syndicationItem.Links.FirstOrDefault().Uri; } } var rss = new RSS { PostTitle = syndicationItem.Title.Text, Description = syndicationItem.Summary.Text, Authors = new List <Author>(), URL = itemNewUri, CreatedAt = syndicationItem.PublishedDate.DateTime, Guid = syndicationItem.Id, PostSource = sourceItem }; foreach (var author in syndicationItem.Authors) { rss.Authors.Add(new Author { Name = author.Name, Email = author.Email, Uri = author.Uri }); } if (!await RSSDataService.FeedExistAsync(rss)) { var newRss = await RSSDataService.AddNewFeedAsync(rss); Feeds.Add(newRss); hasLoadedFeedNewItems = true; } } //shorten the text for windows 10 Live Tile Singleton <LiveTileService> .Instance.SampleUpdate(feed.Title.Text, ShortenText(feed.Items.FirstOrDefault()?.Title.Text, 80), ShortenText(feed.Items.FirstOrDefault()?.Summary.Text, 95)); } if (hasLoadedFeedNewItems) { Feeds.Clear(); foreach (var rss in await RSSDataService.GetFeedsDataAsync(await ApplicationData.Current.LocalSettings.ReadAsync <int>("FeedsLimit"))) { Feeds.Add(rss); } } MarkAsReadCommand.OnCanExecuteChanged(); IsLoadingData = false; }
protected /*override*/ void OnInitializing(ref ValidationContext validationContext) { //base.OnInitializing(ref validationContext); // Injects dependencies if (Sessions.Count > 0) { throw new Exception("Sessions already populated"); } ResetState(); // TODO: Verify state State = Execution.ExecutionStateEx.Starting; if ((Template.TradingOptions.AccountModes & AccountMode.Live) == AccountMode.Live) { foreach (var accountId in Template.LiveAccounts) { var feed = TradingTypeResolver.CreateAccount(accountId); if (feed is IAccount account) { LiveAccounts.Add(account); AddAccount(accountId, account); } Feeds.Add(feed); } } if ((Template.TradingOptions.AccountModes & AccountMode.Demo) == AccountMode.Demo) { foreach (var accountId in Template.DemoAccounts) { var feed = TradingTypeResolver.CreateAccount(accountId); if (feed is IAccount account) { DemoAccounts.Add(account); AddAccount(accountId, account); } Feeds.Add(feed); } } if ((TradingOptions.Features & ( TradingFeatures.Bots | TradingFeatures.Scanners )) != TradingFeatures.None) { foreach (var tSession in Template.Sessions) { var session = tSession.Create(); session.Workspace = this; //session.Initialize().ConfigureAwait(continueOnCapturedContext: false); // Loads child collections session.Initialize().Wait(); // Loads child collections; this.Sessions.Add(session); } } if (TradingOptions.Features.HasFlag(TradingFeatures.WorkspaceInterface)) { LoadWorkspaceItems(); } State = ExecutionStateEx.Ready; //return true; }
public void AddFeed() { Feeds.Add(new FeedItem { Id = Feeds.Count + 1 }); }