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

ImportPricesFromEDDBStrings() public method

Imports the prices from a list of csv-strings in EDDB format
public ImportPricesFromEDDBStrings ( String CSV_Strings, enImportBehaviour importBehaviour, enDataSource dataSource, PriceImportParameters importParams ) : void
CSV_Strings String data to import
importBehaviour enImportBehaviour filter, which prices to import
dataSource enDataSource if data has no information about the datasource, this setting will count
importParams IBE.Enums_and_Utility_Classes.PriceImportParameters
return void
        public void ImportPricesFromEDDBStrings(String[] CSV_Strings, enImportBehaviour importBehaviour, enDataSource dataSource, PriceImportParameters importParams)
        {
            List<EDStation> StationData;
            Boolean updateTables = false;
            ProgressEventArgs eva=new ProgressEventArgs();
            Int32 initialSize=0;

            try
            {
                StationData = fromCSV_EDDB(CSV_Strings);

                if(importParams != null)
                {
                    DataTable data = Program.Data.GetNeighbourSystems(importParams.SystemID, importParams.Radius);

                    String info = "filter data to the bubble (radius " + importParams.Radius+ " ly) : " + data.Rows.Count +" systems...";
                    eva = new ProgressEventArgs() { Info=info, NewLine=true};      

                    if(!sendProgressEvent(eva))
                    {
                       if(data.Rows.Count > 0)
                       {
                           updateTables = true;

                            initialSize = StationData.Count();

                            for (int i = StationData.Count()-1 ; i >= 0 ; i--)
                           {
                               if(data.Rows.Find(StationData[i].SystemId) == null)    
                               {
                                   // system is not in the bubble
                                   StationData.Remove(StationData[i]);
                               }
                               else
                               { 
                                      // system is in the bubble - set as visited
                                   Program.Data.checkPotentiallyNewSystemOrStation(StationData[i].SystemName, StationData[i].Name, null, true);
                               }

                               eva = new ProgressEventArgs() { Info=info, CurrentValue=initialSize-i, TotalValue=initialSize };
                               sendProgressEvent(eva);
                               if(eva.Cancelled)
                                   break;

                           }

                       }
                       else
                           StationData.Clear();
                    }

                    eva = new ProgressEventArgs() { Info=info, CurrentValue=initialSize, TotalValue=initialSize, ForceRefresh=true };
                    sendProgressEvent(eva);
                }

                if((!eva.Cancelled) && (updateTables))
                { 
                    eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", NewLine=true };
                    sendProgressEvent(eva);

                    if(!eva.Cancelled)
                    {
                        Program.Data.updateVisitedFlagsFromBase();
                        eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", CurrentValue=25, TotalValue=100, ForceRefresh=true };
                        sendProgressEvent(eva);
                    }
                    if(!eva.Cancelled)
                    {
                        Program.Data.PrepareBaseTables(Program.Data.BaseData.tbsystems.TableName);
                        eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", CurrentValue=50, TotalValue=100, ForceRefresh=true };
                        sendProgressEvent(eva);
                    }
                    if(!eva.Cancelled)
                    {
                        Program.Data.PrepareBaseTables(Program.Data.BaseData.tbstations.TableName);
                        eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", CurrentValue=75, TotalValue=100, ForceRefresh=true };
                        sendProgressEvent(eva);
                    }
                    if(!eva.Cancelled)
                    {
                        Program.Data.PrepareBaseTables(Program.Data.BaseData.visystemsandstations.TableName);
                        eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", CurrentValue=100, TotalValue=100, ForceRefresh=true };
                        sendProgressEvent(eva);
                    }
                }

                // now import the prices
                if(!eva.Cancelled)
                { 
                   ImportPrices(StationData, importBehaviour, dataSource);
                }



            }
            catch (Exception ex)
            {
                throw new Exception("Error while importing self collected price data", ex);
            }
        }