コード例 #1
0
        public async Task AddNewsGeneralListNews()
        {
            try
            {
                var resultNews_S13 = await _parser_S13.GetNewsFromUrl();

                if (resultNews_S13 != null)
                {
                    foreach (var news in resultNews_S13)
                    {
                        if (await DoesThisNewsAlreadyExistOnTheList(news) != null)
                        {
                            AllNewsList.Add(news);
                        }
                    }
                }
                var result_onliner = await _parser_Onliner.GetNewsFromUrl();

                if (result_onliner != null)
                {
                    foreach (var news in result_onliner)
                    {
                        if (await DoesThisNewsAlreadyExistOnTheList(news) != null)
                        {
                            AllNewsList.Add(news);
                        }
                    }
                }

                var result_TutBy = await _parser_TutBy.GetNewsFromUrl();

                if (result_TutBy != null)
                {
                    foreach (var news in result_TutBy)
                    {
                        if (await DoesThisNewsAlreadyExistOnTheList(news) != null)
                        {
                            AllNewsList.Add(news);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"AddNewsGeneralListNews => {ex.Message}");
            }
        }
コード例 #2
0
        public async Task <IEnumerable <News> > AddNewsGeneralListNews()
        {
            List <News> AllNewsList = new List <News>();

            Parallel.Invoke(
                () => {
                var result_onliner = _parser_Onliner.GetNewsFromUrl();

                if (result_onliner != null)
                {
                    foreach (var news in result_onliner)
                    {
                        if (AllNewsList.Count(n => n.Header.Equals(news.Header)) == 0 && news != null)
                        {
                            AllNewsList.Add(news);
                        }
                    }
                }
            },
                //()=>AddNewsTytBy(),
                () => {
                var resultNews_S13 = _parser_S13.GetNewsFromUrl();

                if (resultNews_S13 != null)
                {
                    foreach (var news in resultNews_S13)
                    {
                        if (AllNewsList.Count(n => n.Header.Equals(news.Header)) == 0 && news != null)
                        {
                            AllNewsList.Add(news);
                        }
                    }
                }
            });

            return(AllNewsList);
        }