Exemplo n.º 1
0
        private async void Dupe_Click(object sender, RoutedEventArgs e)
        {
            this.StatusText.Text = "Starting...";

            try
            {
                string sourceFile = this.DupeSourceFileBox.Text;
                string targetFile = this.DupeTargetFileBox.Text;

                // Parse result rows from the CSV
                this.StatusText.Text = "Parsing Source rows";
                (List <ResultRow> rows, List <string> headers) = await CsvParsingHelper.GetResultRows(sourceFile);

                this.StatusText.Text = "Finding duplicate rows";
                List <ResultRow> duplicates = CsvParsingHelper.FindDuplicates(rows);

                this.StatusText.Text = "Outputting target rows";
                await CsvParsingHelper.WriteResultRows(targetFile, duplicates, headers);

                this.StatusText.Text = $"Completed writing to {targetFile}";
            }
            catch (SeatcardSorterException ex)
            {
                this.StatusText.Text = $"Failed to write file: {ex.Message}";
            }
        }
Exemplo n.º 2
0
        public List <CurrencyRatesDto> ParseResultFromApiToObject(string targetCurrencyCode, List <string> sourceCurrencyCodes, string result)
        {
            foreach (var singleCurrencyCode in sourceCurrencyCodes)
            {
                _logger.LogInformation($"Fetched data for {singleCurrencyCode}.{targetCurrencyCode} from API");
            }
            List <CurrencyRatesDto> parsedResult = CsvParsingHelper.ParseCsvResultToCurrencyRatesDtoList(result);

            _logger.LogInformation($"Parsed fetched data to object");
            return(parsedResult);
        }
Exemplo n.º 3
0
        private async void Map_Click(object sender, RoutedEventArgs e)
        {
            this.StatusText.Text = "Starting...";

            try
            {
                string sourceFile          = this.MapSourceFileBox.Text;
                string targetFile          = this.MapTargetFileBox.Text;
                string listVersionNameFile = this.MapVersionNameFileBox.Text;
                string versionMappingFile  = this.MapVersionMappingFileBox.Text;

                // Parse list version-name file:
                List <string> listVersions = CsvParsingHelper.DefaultListVersions;
                if (!string.IsNullOrEmpty(listVersionNameFile))
                {
                    this.StatusText.Text = "Parsing Version names";
                    listVersions         = await CsvParsingHelper.GetListVersions(listVersionNameFile);
                }

                // Parse version mapping file:
                Dictionary <string, Dictionary <DateTime, string> > versionMapping = null;
                List <string> versionColumnsPresent = null;
                if (!string.IsNullOrEmpty(versionMappingFile))
                {
                    this.StatusText.Text = "Parsing Version mappings";
                    (versionMapping, versionColumnsPresent) = await CsvParsingHelper.GetVersionMappings(versionMappingFile, listVersions);
                }

                // Parse source rows from the CSV
                this.StatusText.Text = "Parsing Source rows";
                List <SourceRow> sourceRows = await CsvParsingHelper.GetSourceRows(sourceFile);

                this.StatusText.Text = "Mapping and sorting rows";
                (List <ResultRow> rows, List <string> headers) = CsvParsingHelper.MapSourceRowsToTargetRows(listVersions, versionMapping, versionColumnsPresent, sourceRows);

                this.StatusText.Text = "Outputting target rows";
                await CsvParsingHelper.WriteResultRows(targetFile, rows, headers);

                this.StatusText.Text = $"Completed writing to {targetFile}";
            }
            catch (SeatcardSorterException ex)
            {
                this.StatusText.Text = $"Failed to write file: {ex.Message}";
            }
        }