Example #1
0
        private void getarticle()
        {
            newstory = manageArticle.GetMainStory(mainstory);
            article  = newstory.FullArticle;

            imageq.Source = mainstory.Photo;



            foreach (var item in article)
            {
                Paragraph paragraph = new Paragraph();
                Run       run       = new Run();
                run.Text = item;
                paragraph.Inlines.Add(run);
                richTextBlock.Blocks.Add(paragraph);
            }



            richTextBlock.TextAlignment = TextAlignment.Justify;

            written.Children.Add(richTextBlock);

            string head = newstory.newsItem.Headline.ToUpper();

            byline.Text = "Placeholder";

            while (head.ElementAt(0).Equals(" "))
            {
                //head.PadRight(4);
                head.Substring(1, head.Length - 1);
                byline.Text = "Place";
            }

            byline.Text = newstory.lead;
            lead.Text   = newstory.byline;

            //head =head.Remove()

            Headliner.Text = head;
        }
Example #2
0
        public async Task <IClientArticle> GetByUrl(string url)
        {
            var articleDetails = await articleDetailsStorage.Value;
            var qry            = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, WebUtility.UrlEncode(url));
            // The url is UrlEncoded when stored as the rowkey Ensures we don;t hit any fucnny characters when storing the string
            var urlKey = (await articleDetails.Query <ArticleDetailsUrlId>(qry, 1)).ToList();

            if (urlKey.Count > 0)
            {
                var urlData = urlKey.First();
                var details = await articleDetails.Get <ArticleDetails>(urlData.Id, urlData.Url);

                var jsonBlob = await(await articleBlobStorage.Value).GetStringBlob($"{details.Id}.json");
                var article  = JsonConvert.DeserializeObject <ArticleFileData>(jsonBlob);
                return(new CompleteArticle(article, details));
            }
            else
            {
                return(CompleteArticle.Empty());
            }
        }
        private void downloadCallback(string url, string filename, object obj)
        {
            var file_seg = (EmiliaFileSegment)obj;

            CompleteFile?.Invoke(null, file_seg);
            dispatcher_dictionary[file_seg.SeriesIndex].CompleteFile.Invoke(file_seg);

            lock (complete_lock)
            {
                int article_status = downloaded_count_dictionary[file_seg.SeriesIndex][file_seg.ArticleIndex] += 1;
                check_dictionary[file_seg.SeriesIndex][file_seg.ArticleIndex][file_seg.Index] = true;

                // 아티클 다운로드 완료
                if (article_status == series_dictionary[file_seg.SeriesIndex].Articles[file_seg.ArticleIndex].Files.Count)
                {
                    int series_status = downloaded_articles_count_dictionary[file_seg.SeriesIndex] += 1;
                    dispatcher_dictionary[file_seg.SeriesIndex].CompleteArticle.Invoke(series_dictionary[file_seg.SeriesIndex].Articles[file_seg.ArticleIndex]);
                    CompleteArticle?.Invoke(null, series_dictionary[file_seg.SeriesIndex].Articles[file_seg.ArticleIndex]);

                    // 시리즈 다운로드 완료
                    if (series_status == series_dictionary[file_seg.SeriesIndex].Articles.Count)
                    {
                        dispatcher_dictionary[file_seg.SeriesIndex].CompleteSeries();
                        CompleteSeries?.Invoke(null, series_dictionary[file_seg.SeriesIndex]);
                    }
                }
            }

            lock (add_lock)
            {
                remain_contents--;
                if (remain_contents == 0 && DownloadComplete != null)
                {
                    DownloadComplete.Invoke(null, null);
                }
            }
        }