Beispiel #1
0
        private async Task LoadArticlesIntoFeed(FeedModel feed, int max = -1)
        {
            if (max == -1)
            {
                max = 100;
            }
            for (int i = 0; i < max; i++)
            {
                if (feed.AllArticles.Count <= i)
                {
                    var stringGuid = feed.Guid.ToString();
                    var realmax    = max == 0 ? 0 : max - i;
                    var relations  = await _sqliteService.GetByCondition <FeedArticleRelationEntity>(s => s.FeedGuid == stringGuid, s => s.Index, false, realmax, i);

                    foreach (var feedArticleRelationEntity in relations)
                    {
                        var article = await LoadHelper.LoadForFeed(feedArticleRelationEntity.ArticleId, feed, _sqliteService, _imageDownloadService);

                        feed.AllArticles.Add(article);
                    }
                }

                _imageDownloadService.Download(feed);

                //no more entries
                if (feed.AllArticles.Count <= i)
                {
                    return;
                }
            }
        }
Beispiel #2
0
        public static async Task<ArticleModel> LoadForFeed(int id, FeedModel feed, ISqliteService sqliteService, IImageDownloadService imageDownloadService)
        {
            var arRepo = new GenericRepository<ArticleModel, ArticleEntity>(sqliteService);
            var imgRepo = new GenericRepository<ImageContentModel, ImageContentEntity>(sqliteService);

            var art = await arRepo.GetByIdAsync(id);
            var contents = await sqliteService.GetByCondition<ContentEntity>(s => s.ParentId == id && s.ContentType == (int)ContentType.LeadImage, s => s.Index, false, 1, 0);
            if (contents?.FirstOrDefault() != null)
            {
                var image = await imgRepo.GetByIdAsync(contents.FirstOrDefault().ContentId);
                art.LeadImage = image;

                if (art.LeadImage?.LoadingState < LoadingState.Loaded)
                    imageDownloadService.Download(art);
            }
            art.Feed = feed;
            return art;
        }
Beispiel #3
0
        public static async Task <ArticleModel> LoadForFeed(int id, FeedModel feed, ISqliteService sqliteService, IImageDownloadService imageDownloadService)
        {
            var arRepo  = new GenericRepository <ArticleModel, ArticleEntity>(sqliteService);
            var imgRepo = new GenericRepository <ImageContentModel, ImageContentEntity>(sqliteService);

            var art = await arRepo.GetByIdAsync(id);

            var contents = await sqliteService.GetByCondition <ContentEntity>(s => s.ParentId == id && s.ContentType == (int)ContentType.LeadImage, s => s.Index, false, 1, 0);

            if (contents?.FirstOrDefault() != null)
            {
                var image = await imgRepo.GetByIdAsync(contents.FirstOrDefault().ContentId);

                art.LeadImage = image;

                if (art.LeadImage?.LoadingState < LoadingState.Loaded)
                {
                    imageDownloadService.Download(art);
                }
            }
            art.Feed = feed;
            return(art);
        }