private async void loadFile_Click(object sender, RoutedEventArgs e) { FileOpenPicker openPicker = new FileOpenPicker { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, ViewMode = PickerViewMode.Thumbnail }; openPicker.FileTypeFilter.Add(".csv"); openPicker.FileTypeFilter.Add(".txt"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file == null) { return; } string text = await FileIO.ReadTextAsync(file); if (this.summaryTextBox.Text == "Summary") { CovidCsvParser parser = new CovidCsvParser(); this.currentStatistics = parser.ParseText(text).ToList(); this.errorsFound = parser.Errors.ToList(); this.setCovidDataToSummaryBox(); } else { this.incomingStatistics.Clear(); this.duplicatesFound.Clear(); CovidCsvParser parser = new CovidCsvParser(); this.incomingStatistics = parser.ParseText(text).ToList(); this.errorsFound = parser.Errors.ToList(); this.displayMergeOption(); } }
/// <summary>Loads the covid data from text.</summary> /// <param name="textContent">Content of the text.</param> /// <exception cref="ArgumentNullException">textContent</exception> public void LoadCovidData(string textContent) { textContent = textContent ?? throw new ArgumentNullException(nameof(textContent)); var parser = new CovidCsvParser(textContent); this.covidErrorLogger = parser.CovidErrorLogger; this.FilteredCovidDataCollection = parser.GenerateCovidDataCollection(); this.AllCovidData = this.FilteredCovidDataCollection.Clone(); this.IsCovidDataLoaded = true; this.buildCovidSummary(); }
/// <summary> /// Merges the and loads the covid data using csv content. /// </summary> /// <param name="textContent">Content of the text.</param> /// <param name="mergeAllStates">if set to <c>true</c> [merge all states].</param> /// <exception cref="ArgumentNullException">textContent</exception> public void MergeAndLoadCovidData(string textContent, bool mergeAllStates) { textContent = textContent ?? throw new ArgumentNullException(nameof(textContent)); var parser = new CovidCsvParser(textContent); var newCovidDataCollection = parser.GenerateCovidDataCollection(); this.covidErrorLogger = parser.CovidErrorLogger; if (mergeAllStates) { this.FilteredCovidDataCollection = this.AllCovidData.Clone(); } this.mergeController = new CovidDataMergeController(this.FilteredCovidDataCollection, newCovidDataCollection); this.mergeController.AddAllNonDuplicates(); this.mergeAndRebuildAllCovidData(); }