/// <summary> /// Определение url с максималоьным числом ссылок /// </summary> private async Task SelectMaxReferenceResult() { UrlReportViewModel maxReferenceUrl = await Task.Run(() => { List <UrlReportViewModel> urls = ReportCollection.ToList(); return(urls.FirstOrDefault(x => x.IsMaxReference)); }); if (maxReferenceUrl != null) { maxReferenceUrl.IsMaxReference = false; } maxReferenceUrl = await Task.Run(() => { List <UrlReportViewModel> urlsWithValue = ReportCollection.ToList().Where(x => x.ReferenceCount.HasValue).ToList(); if (!urlsWithValue.Any()) { return(null); } return(urlsWithValue.Aggregate(urlsWithValue.First(), (curr, next) => next.ReferenceCount > curr.ReferenceCount ? next : curr)); }); if (maxReferenceUrl != null) { maxReferenceUrl.IsMaxReference = true; } }
/// <summary> /// Обработка нажатия кнопки "НАЧАТЬ" /// </summary> /// <param name="parameter"></param> /// <returns></returns> private async Task StartProcessingCommandHandler(object parameter) { ReportCollection.ToList().ForEach(async x => await x.CancelRequest()); ReportCollection.Clear(); IEnumerable <UrlReportViewModel> urls = await mUrlReportBuilder.GetUrlReportsAsync(UrlFilePath, mUrlRequestService, mUrlParseService, SelectMaxReferenceResult); List <UrlReportViewModel> urlList = urls as List <UrlReportViewModel> ?? urls.ToList(); urlList.ForEach(async x => { ReportCollection.Add(x); await x.RequestUrl(); }); }