private async void DownloadPublicationImages() { foreach (var pub in WolLibrary.GetAllPublications(await GetLibraryXML()).Where(p => !p.ImageAsset.Contains("null"))) { //GemWriteLine(pub.Title); await DownloadImage(pub.ImageAsset, pub.ImageAsset.Split('/').Last()); } }
public override async void Init(object initData) { //Publications = new GEMObservableCollection<object>(); //PublicationGroups = new GEMObservableCollection<object>(); //Publications.ReplaceRange(WolLibrary.GetAllPublications().Where(p => p.Language == Language.English).Select((p, index) => new PublicationGroup() //{ // KeySymbol = p.KeySymbol, // PublicationRootKeyId = p.PublicationRootKeyId.ToString(), // PubType = p.Type, // Title = p.Title, // ShortTitle = p.ShortTitle, // Description = p.ShortTitle, // PublicationImage = p.ImageAsset, // Type = p.Type.ToString() //})); //PublicationGroups.ReplaceRange(Publications.Cast<PublicationGroup>().GroupBy(p => p.Type)); Publications = new ObservableCollection <PublicationGroup>(); PublicationGroups = new ObservableCollection <IGrouping <string, PublicationGroup> >(); Language langid = (Settings.PrimaryLanguage == LPLanguage.English.GetName()) ? Language.English : Language.Chinese; Publications = WolLibrary.GetAllPublications(await App.GetLibraryXML()).Where(p => p.Language == langid).Select((p, index) => new PublicationGroup() { KeySymbol = p.KeySymbol, PublicationRootKeyId = p.PublicationRootKeyId.ToString(), Category = p.Category, Title = p.Title, ShortTitle = p.ShortTitle, Description = p.ShortTitle, PublicationImage = p.ImageAsset, CategoryName = p.Category.ToString() }).ToObservableCollection(); PublicationGroups = Publications.GroupBy(u => u.CategoryName).ToObservableCollection(); Title = App.GetLanguageValue("Publications", "出版物"); //Pubs = WolLibrary.GetAllPublications().Where(p => p.Language == Language.English).Select(p => p.ToPublication()).ToObservableCollection(); }
private async void DownloadArticlesToStorehouse(bool updateMonthly = false, List <ArticleType> types = null, List <string> pubs = null) { Debug.WriteLine("START => " + DateTime.Now); if (updateMonthly) { await UpdateMonthlyPublications(); } if (pubs != null) { foreach (string pub in pubs) { await DownloadPublication(pub, ArticleType.Publication); } } if (types != null) { foreach (ArticleType code in types) { if (code == ArticleType.Publication) { // Download Books, Brochures, and Tracts foreach (var pub in WolLibrary.GetAllPublications(await GetLibraryXML()) .Where(p => p.Language == Language.English) .Where(p => (p.KeySymbol != "es") && (p.KeySymbol != "it") && !p.KeySymbol.StartsWith("mwb-") && !p.KeySymbol.StartsWith("w-") && !p.KeySymbol.StartsWith("wp-") && !p.KeySymbol.StartsWith("g-"))) { await DownloadPublication(pub.KeySymbol, ArticleType.Publication); GemWriteLine(pub.KeySymbol); } } if (code == ArticleType.DailyText) { // Download Daily Text await DownloadPublication("es", ArticleType.DailyText); } if (code == ArticleType.Insight) { // Download Insight Book await DownloadPublication("it", ArticleType.Insight); } if (code == ArticleType.Bible) { // Download Bible await DownloadPublication("nwt", ArticleType.Bible); } if (code == ArticleType.Monthly) { // Download meeting Workbook await DownloadPublication("mwb", ArticleType.Monthly); // Download Watchtower Study Edition await DownloadPublication("w", ArticleType.Monthly); // Download Watchtower Public await DownloadPublication("wp", ArticleType.Monthly); // Download Awake! await DownloadPublication("g", ArticleType.Monthly); } } } Debug.WriteLine("END => " + DateTime.Now); }