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

fromCSV_EDDB() public method

creates a list of "EDStations" with price listings from csv-array in EDDB format
public fromCSV_EDDB ( String CSV_Strings ) : List
CSV_Strings String String to be converted
return List
        public List<EDStation> fromCSV_EDDB(String[] CSV_Strings)
        {
            List<EDStation> foundValues                     = new List<EDStation>();
            Dictionary<Int32, Int32> foundIndex             = new Dictionary<Int32, Int32>();
            Dictionary<String, Int32> foundSystemIndex      = new Dictionary<String, Int32>();
            Int32 LastID                                    = 0;
            EDSystem LastSystem                             = null;
            Int32 currentID                                 = 0;
            EDStation currentStation                        = null;
            Int32 Index                                     = 0;
            Dictionary<String, Int32> commodityIDCache      = new Dictionary<string,Int32>();            // quick cache for finding commodity names
            Int32 currentItem                               = 0;
            ProgressEventArgs eva;

            try
            {
                eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0), NewLine= true};
                sendProgressEvent(eva);

                foreach (String CSV_String in CSV_Strings)
	            {

                    if(!String.IsNullOrEmpty(CSV_String.Trim()))
                    {
		                Listing currentRow           = new Listing(CSV_String);

                        currentID = currentRow.StationId;

                        if(LastID != currentID)
                        {
                            if(currentStation != null)
                                currentStation.ListingExtendMode = false;

                            if(foundIndex.TryGetValue(currentID, out Index))
                                currentStation = foundValues[Index];
                            else
                            {
                                currentStation  = new EDStation(currentRow);

                                foundValues.Add(currentStation);
                                foundIndex.Add(currentID, foundValues.Count-1);
                            }
                            LastID = currentRow.StationId;

                            currentStation.ListingExtendMode = true;

                        }

                        currentStation.addListing(currentRow);
                    }
                
                    eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0)};
                    sendProgressEvent(eva);

                    if(eva.Cancelled)
                        break;

                    currentItem++;
	            }

                if(currentStation != null)
                    currentStation.ListingExtendMode = false;

                eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0), ForceRefresh=true};
                sendProgressEvent(eva);

                return foundValues;

            }
            catch (Exception ex)
            {
                throw new Exception("Error while getting station values from CSV-String", ex);
            }
        }