IBE.SQL.EliteDBIO.ImportPricesFromCSVFile C# (CSharp) Method

ImportPricesFromCSVFile() public method

Imports the prices from a file with csv-strings (e.g. the old autosave-file)
public ImportPricesFromCSVFile ( String filename, enImportBehaviour importBehaviour, enDataSource dataSource, PriceImportParameters importParams = null ) : Int32
filename String
importBehaviour enImportBehaviour
dataSource enDataSource
importParams IBE.Enums_and_Utility_Classes.PriceImportParameters only for control import behaviour from EDDB files, can be null
return System.Int32
        public Int32 ImportPricesFromCSVFile(String filename, enImportBehaviour importBehaviour, enDataSource dataSource, PriceImportParameters importParams = null)
        {
            try
            {
                List<String> CSV_Strings    = new List<string>();
                ProgressEventArgs eva;

                var reader              = new StreamReader(File.OpenRead(filename));
                Int32 counter           = 0;

                string header = reader.ReadLine();

                sendProgressEvent(new ProgressEventArgs() { Info="reading data from file ...", AddSeparator=true });
              
                if(header.StartsWith("System;Station;Commodity;Sell;Buy;Demand;;Supply"))
                {
                    // old RN format
                    do
                    {
                        CSV_Strings.Add(reader.ReadLine());
                        counter ++;


                        if(sendProgressEvent(new ProgressEventArgs() { Info="reading data from file ...", CurrentValue=counter}))
                            break;

                    } while (!reader.EndOfStream);

                    reader.Close();

                    if(!sendProgressEvent(new ProgressEventArgs() { Info="reading data from file ...", CurrentValue=counter, TotalValue=counter, ForceRefresh = true})) 
                       ImportPricesFromCSVStrings(CSV_Strings.ToArray(), importBehaviour, dataSource);

                }
                else if(header.StartsWith("id,station_id,commodity_id,supply,buy_price,sell_price,demand"))
                {
                    // EDDB format
                    do
                    {
                        CSV_Strings.Add(reader.ReadLine());
                        counter ++;

                        if(sendProgressEvent(new ProgressEventArgs() { Info="reading data from file ...", CurrentValue=counter}))
                            break;

                    } while (!reader.EndOfStream);

                    reader.Close();

                    if(!sendProgressEvent(new ProgressEventArgs() { Info="reading data from file ...", CurrentValue=counter, TotalValue=counter, ForceRefresh = true}))
                        ImportPricesFromEDDBStrings(CSV_Strings.ToArray(), importBehaviour, dataSource, importParams);
                }
                return CSV_Strings.Count();
            }
            catch (Exception ex)
            {
                throw new Exception("Error while importing self collected price data", ex);
            }
        }