C# Class IBE.SQL.EliteDBIO

Inheritance: IDisposable
Mostra file Open project: Duke-Jones/ED-IBE Class Usage Examples

Public Methods

Method Description
BaseTableIDToName ( String Tablename, int id, String column = "" ) : object

looks for the name of a id from a base table

BaseTableNameToID ( String Tablename, String Name, System.Boolean insertUnknown = false ) : object

looks for the id of a name from a base table

CorrectMisspelledCommodities ( ) : Int32

Checks the commodity names with reference to table tbDNMap_Commodity. Correct misspellings if some found.

DeleteMarketData ( Int32 days ) : void

delete all market data older than x days

DeleteMultiplePrices ( List idList = null ) : void

function deletes all exept the newest price for a commodity on a station, if there exists more than one.

DeleteNoLongerExistingMarketData ( int days, int singleStationID = null ) : void

delete all data for every station, older than "youngest update" - "n days"

Dispose ( ) : void
EliteDBIO ( ) : System

constructor

ExportLocalizationDataToCSV ( string fileName, enLocalizationType activeSetting ) : void
ExportMarketDataToCSV ( string fileName, System.Boolean inCurrentLanguage, System.Boolean extendedFormat ) : void

exports the market data to a file

GetLogByTimestamp ( System.DateTime timeStamp ) : dsEliteDB.vilogRow

returns a single log entry identified by its timestamp

GetNeighbourSystems ( Int32 stationId, Double maxDistance ) : DataTable

gets all neighbours in a bubble around a system

GetStationnameFromStationID ( int stationID ) : String

returns the name of a system through a given station-id

GetSystemnameFromStation ( int stationID ) : String

returns the name of a system through a given station-id

ImportCommandersLog ( String Filename ) : Int32

imports the "Commander's Log" into the database

ImportEDCDData ( frmDataIO enImportTypes, String importFile ) : void
ImportLocalizationDataFromCSV ( string fileName, EliteDBIO activeSetting, enLocalisationImportType importType = enLocalisationImportType.onlyNew ) : void
ImportPrices ( Newtonsoft companionData ) : Int32

imports prices from a JSON companion data object

ImportPricesFromCSVFile ( String filename, enImportBehaviour importBehaviour, enDataSource dataSource, PriceImportParameters importParams = null ) : Int32

Imports the prices from a file with csv-strings (e.g. the old autosave-file)

ImportPricesFromCSVStrings ( String CSV_Strings, enImportBehaviour importBehaviour, enDataSource dataSource ) : List

Imports the prices from a list of csv-strings

ImportPricesFromEDDBStrings ( String CSV_Strings, enImportBehaviour importBehaviour, enDataSource dataSource, PriceImportParameters importParams ) : void

Imports the prices from a list of csv-strings in EDDB format

ImportStations ( String Filename, System.Boolean addPrices ) : void

imports the data from the file into the database (only newer data will be imported)

ImportStations_Own ( EDStation Station, System.Boolean OnlyAddUnknown = false, System.Boolean setVisitedFlag = false ) : void

imports the "own" station data from the list of stations

ImportStations_Own ( List Stations, Int32>.Dictionary changedSystemIDs, System.Boolean OnlyAddUnknown = false, System.Boolean setVisitedFlag = false ) : void

imports the "own" station data into the database

ImportStations_Own ( String Filename, System.Boolean OnlyAddUnknown = false ) : void

imports the "own" station data from the file into the database (only initially once needed)

ImportStations_Own ( String Filename, Int32>.Dictionary changedSystemIDs, System.Boolean OnlyAddUnknown = false ) : void

imports the "own" station data from the list of stations

ImportSystems ( String Filename ) : void

imports the data from the file into the database (only newer data will be imported)

ImportSystems_Own ( EDSystem System, System.Boolean OnlyAddUnknown = false, System.Boolean setVisitedFlag = false ) : Int32>.Dictionary

imports the data from the list of systems

ImportSystems_Own ( List &Systems, System.Boolean OnlyAddUnknown = false, System.Boolean setVisitedFlag = false ) : Int32>.Dictionary

imports the data from the list of systems

ImportSystems_Own ( String Filename, System.Boolean OnlyAddUnknown = false ) : Int32>.Dictionary

imports the own data from the file into the database (only initially once needed)

ImportVisitedStations ( string Filename ) : void

imports the old list of visited stations to the database

InsertColumnDefinition ( string iniGroup, string iniKey, int newColumnIndex, int newViewIndex, string newColumnDefinition ) : void

Inserts data for new columns in existing definitions of datagrids

checkPotentiallyNewSystemOrStation ( String newSystemName, String newStationName, Point3Dbl coordinates = null, System.Boolean setVisitedFlag = true ) : void

Checks if the system is existing and adds it, if not. Also sets the visited-flag if not set.

fromCSV ( String CSV_Strings, List &foundSystems, List &csvRowList ) : List

creates a list of "EDStations" with price listings from csv-array

fromCSV_EDDB ( String CSV_Strings ) : List

creates a list of "EDStations" with price listings from csv-array in EDDB format

getStations ( string System ) : string[]

retrieves all stationnames in the system in a array

switchLanguage ( String Language ) : void

Switch the language, updating the loccommodity-string in tbCommodities.

updateTranslation ( ) : void

updates the localization of all commodities for the current language

updateVisitedBaseFromLog ( enVisitType Refresh ) : void

Specifies all systems/stations from the Commander's Log as "visited". Necessary/recommended after a import of old "Commander's Log" files.

updateVisitedFlagsFromBase ( System.Boolean newSystem = true, System.Boolean newStation = true ) : void

Update the visited-flag in the stations- and systems-tables from the visited-basetables (tbVisitedStations/tbVistitedSystems).

Protected Methods

Method Description
Dispose ( bool disposing ) : void
OnProgress ( ProgressEventArgs e ) : void

Private Methods

Method Description
AddMissingLocalizationEntries ( ) : void

adds for all items (commodities, levels, categories) the missing entries in the localization tables

ClearAll ( ) : void
CopyEDStationCommodityToDataRow ( EDStation StationObject, dsEliteDB Data, UInt32 &AutoIndex ) : void

copies the commodities data from a "EDStation"-object to "tb_______Commodity"-table

CopyEDStationEconomiesToDataRows ( EDStation StationObject, System EconomyTable ) : void

copies the economies data from a "EDStation"-object to "tbStationEconomy"-table

CopyEDStationToDataRow ( EDStation StationObject, DataRow StationRow, System.Boolean OwnData = false, int StationID = null, System.Boolean insertUnknown = false ) : void

copies the data from a "EDStation"-object to a Datarow from table "tbStations"

CopyEDSystemToDataRow ( EDSystem SystemObject, DataRow SystemRow, System.Boolean OwnData = false, int SystemID = null, System.Boolean insertUnknown = false ) : void

copies the data from a "EDSystem"-object to a Datarow from table "tbSystems"

GetCoordinates ( String systemName ) : Point3Dbl

returns the coordinates of the system

GetMapping ( string mappingTable, string idString1, System.Boolean throwException = true ) : string
GetMapping ( string mappingTable, string idString1, string idString2, System.Boolean throwException = true ) : string
GetMappingT ( string mappingTable, string idString1, System.Boolean throwException = true ) : String>.Tuple
GetMappingT ( string mappingTable, string idString1, string idString2, System.Boolean throwException = true ) : String>.Tuple
ImportCommodities ( List Commodities ) : void

imports the data from the list (only newer data will be imported)

ImportCommoditiesFromFile ( String fileName ) : void

imports the data from the file into the database (only newer data will be imported)

ImportCommodityLocalizations ( DataSet DataNames, enLocalisationImportType importType = enLocalisationImportType.onlyNew ) : void

loads the localized commodity names and check if the self added names now included in the official dictionary

ImportCommodityLocalizations ( String Filename ) : void

loads the localized commodity names and check if the self added names now included in the official dictionary

ImportCommodityPriceWarnLevels ( String Filename ) : void

loads the existing price-warnlevel data

ImportEconomyLevelLocalizations ( String Filename ) : void

loads the localized economy level names and check

ImportPrices ( List Stations, enImportBehaviour importBehaviour, enDataSource dataSource ) : void

Imports the prices from the list of stations. It's clever firstly to import the stations from the same file.

PrepareBaseTables ( String TableName = "", System.Boolean saveChanged = false ) : void

loads the data from the basetables into memory. For correct initialization it is necessary to call this fuction with a unset tableName

RecalcJumpDistancesInLog ( System.DateTime maxAge ) : void

recalculates distances in the tbLog-table

RecalcJumpDistancesInLog ( System.DateTime startTime, System.DateTime endTime ) : void

recalculates distances in the tbLog-table

SendLogToEDSM ( List timeStamps ) : void
getCommodityNames ( ) : List

retrieves all known commodity names in the current language

getDistanceBetween ( Int32 System_1, Int32 System_2 ) : double?

returns the distance between two systems (given by id)

getDistanceBetween ( string System_1, string System_2 ) : double?

retrun the distance between two systems (given by name)

getEconomyLevels ( ) : string>.Dictionary

retrieves all known economylevels as original string in capitals and in the current language

getFreeIndex ( String TableName ) : UInt32

get the next free index for the table (positive only)

getLevels ( int &DemandLevel, int &SupplyLevel, int?>.Dictionary Levels, Listing StationListing ) : void
getNextOwnSystemIndex ( ) : int

gets the next free system-id for user added systems

sendProgressEvent ( ProgressEventArgs pEArgs ) : System.Boolean

fires the progress event if necessary

Method Details

BaseTableIDToName() public method

looks for the name of a id from a base table
public BaseTableIDToName ( String Tablename, int id, String column = "" ) : object
Tablename String name of the basetable WITHOUT leading 'tb'
id int
column String
return object

BaseTableNameToID() public method

looks for the id of a name from a base table
public BaseTableNameToID ( String Tablename, String Name, System.Boolean insertUnknown = false ) : object
Tablename String name of the basetable WITHOUT leading 'tb'
Name String
insertUnknown System.Boolean
return object

CorrectMisspelledCommodities() public method

Checks the commodity names with reference to table tbDNMap_Commodity. Correct misspellings if some found.
public CorrectMisspelledCommodities ( ) : Int32
return System.Int32

DeleteMarketData() public method

delete all market data older than x days
public DeleteMarketData ( Int32 days ) : void
days System.Int32
return void

DeleteMultiplePrices() public method

function deletes all exept the newest price for a commodity on a station, if there exists more than one.
public DeleteMultiplePrices ( List idList = null ) : void
idList List if not null the function only examines the given commodity-ids /// (for improving performance)
return void

DeleteNoLongerExistingMarketData() public method

delete all data for every station, older than "youngest update" - "n days"
public DeleteNoLongerExistingMarketData ( int days, int singleStationID = null ) : void
days int
singleStationID int
return void

Dispose() public method

public Dispose ( ) : void
return void

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void

EliteDBIO() public method

constructor
public EliteDBIO ( ) : System
return System

ExportLocalizationDataToCSV() public method

public ExportLocalizationDataToCSV ( string fileName, enLocalizationType activeSetting ) : void
fileName string
activeSetting enLocalizationType
return void

ExportMarketDataToCSV() public method

exports the market data to a file
public ExportMarketDataToCSV ( string fileName, System.Boolean inCurrentLanguage, System.Boolean extendedFormat ) : void
fileName string
inCurrentLanguage System.Boolean
extendedFormat System.Boolean
return void

GetLogByTimestamp() public method

returns a single log entry identified by its timestamp
public GetLogByTimestamp ( System.DateTime timeStamp ) : dsEliteDB.vilogRow
timeStamp System.DateTime
return dsEliteDB.vilogRow

GetNeighbourSystems() public method

gets all neighbours in a bubble around a system
public GetNeighbourSystems ( Int32 stationId, Double maxDistance ) : DataTable
stationId System.Int32 system in the center of the bubble
maxDistance Double radius of the bubble
return System.Data.DataTable

GetStationnameFromStationID() public method

returns the name of a system through a given station-id
public GetStationnameFromStationID ( int stationID ) : String
stationID int
return String

GetSystemnameFromStation() public method

returns the name of a system through a given station-id
public GetSystemnameFromStation ( int stationID ) : String
stationID int
return String

ImportCommandersLog() public method

imports the "Commander's Log" into the database
public ImportCommandersLog ( String Filename ) : Int32
Filename String
return System.Int32

ImportEDCDData() public method

public ImportEDCDData ( frmDataIO enImportTypes, String importFile ) : void
enImportTypes frmDataIO
importFile String
return void

ImportLocalizationDataFromCSV() public method

public ImportLocalizationDataFromCSV ( string fileName, EliteDBIO activeSetting, enLocalisationImportType importType = enLocalisationImportType.onlyNew ) : void
fileName string
activeSetting EliteDBIO
importType enLocalisationImportType
return void

ImportPrices() public method

imports prices from a JSON companion data object
public ImportPrices ( Newtonsoft companionData ) : Int32
companionData Newtonsoft JSON object with companion data
return System.Int32

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

ImportPricesFromCSVStrings() public method

Imports the prices from a list of csv-strings
public ImportPricesFromCSVStrings ( String CSV_Strings, enImportBehaviour importBehaviour, enDataSource dataSource ) : List
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
return List

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

ImportStations() public method

imports the data from the file into the database (only newer data will be imported)
public ImportStations ( String Filename, System.Boolean addPrices ) : void
Filename String
addPrices System.Boolean
return void

ImportStations_Own() public method

imports the "own" station data from the list of stations
public ImportStations_Own ( EDStation Station, System.Boolean OnlyAddUnknown = false, System.Boolean setVisitedFlag = false ) : void
Station IBE.EDDB_Data.EDStation
OnlyAddUnknown System.Boolean
setVisitedFlag System.Boolean
return void

ImportStations_Own() public method

imports the "own" station data into the database
public ImportStations_Own ( List Stations, Int32>.Dictionary changedSystemIDs, System.Boolean OnlyAddUnknown = false, System.Boolean setVisitedFlag = false ) : void
Stations List
changedSystemIDs Int32>.Dictionary
OnlyAddUnknown System.Boolean
setVisitedFlag System.Boolean
return void

ImportStations_Own() public method

imports the "own" station data from the file into the database (only initially once needed)
public ImportStations_Own ( String Filename, System.Boolean OnlyAddUnknown = false ) : void
Filename String
OnlyAddUnknown System.Boolean
return void

ImportStations_Own() public method

imports the "own" station data from the list of stations
public ImportStations_Own ( String Filename, Int32>.Dictionary changedSystemIDs, System.Boolean OnlyAddUnknown = false ) : void
Filename String
changedSystemIDs Int32>.Dictionary
OnlyAddUnknown System.Boolean
return void

ImportSystems() public method

imports the data from the file into the database (only newer data will be imported)
public ImportSystems ( String Filename ) : void
Filename String
return void

ImportSystems_Own() public method

imports the data from the list of systems
public ImportSystems_Own ( EDSystem System, System.Boolean OnlyAddUnknown = false, System.Boolean setVisitedFlag = false ) : Int32>.Dictionary
System IBE.EDDB_Data.EDSystem
OnlyAddUnknown System.Boolean
setVisitedFlag System.Boolean
return Int32>.Dictionary

ImportSystems_Own() public method

imports the data from the list of systems
public ImportSystems_Own ( List &Systems, System.Boolean OnlyAddUnknown = false, System.Boolean setVisitedFlag = false ) : Int32>.Dictionary
Systems List
OnlyAddUnknown System.Boolean
setVisitedFlag System.Boolean
return Int32>.Dictionary

ImportSystems_Own() public method

imports the own data from the file into the database (only initially once needed)
public ImportSystems_Own ( String Filename, System.Boolean OnlyAddUnknown = false ) : Int32>.Dictionary
Filename String
OnlyAddUnknown System.Boolean
return Int32>.Dictionary

ImportVisitedStations() public method

imports the old list of visited stations to the database
public ImportVisitedStations ( string Filename ) : void
Filename string
return void

InsertColumnDefinition() public static method

Inserts data for new columns in existing definitions of datagrids
public static InsertColumnDefinition ( string iniGroup, string iniKey, int newColumnIndex, int newViewIndex, string newColumnDefinition ) : void
iniGroup string
iniKey string
newColumnIndex int
newViewIndex int
newColumnDefinition string
return void

OnProgress() protected method

protected OnProgress ( ProgressEventArgs e ) : void
e ProgressEventArgs
return void

checkPotentiallyNewSystemOrStation() public method

Checks if the system is existing and adds it, if not. Also sets the visited-flag if not set.
public checkPotentiallyNewSystemOrStation ( String newSystemName, String newStationName, Point3Dbl coordinates = null, System.Boolean setVisitedFlag = true ) : void
newSystemName String
newStationName String
coordinates IBE.Enums_and_Utility_Classes.Point3Dbl
setVisitedFlag System.Boolean
return void

fromCSV() public method

creates a list of "EDStations" with price listings from csv-array
public fromCSV ( String CSV_Strings, List &foundSystems, List &csvRowList ) : List
CSV_Strings String String to be converted
foundSystems List
csvRowList List for optional processing outside: a list of the data converted to CsvRow-objects
return List

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

getStations() public method

retrieves all stationnames in the system in a array
public getStations ( string System ) : string[]
System string
return string[]

switchLanguage() public method

Switch the language, updating the loccommodity-string in tbCommodities.
public switchLanguage ( String Language ) : void
Language String new language for viewing
return void

updateTranslation() public method

updates the localization of all commodities for the current language
public updateTranslation ( ) : void
return void

updateVisitedBaseFromLog() public method

Specifies all systems/stations from the Commander's Log as "visited". Necessary/recommended after a import of old "Commander's Log" files.
public updateVisitedBaseFromLog ( enVisitType Refresh ) : void
Refresh enVisitType
return void

updateVisitedFlagsFromBase() public method

Update the visited-flag in the stations- and systems-tables from the visited-basetables (tbVisitedStations/tbVistitedSystems).
public updateVisitedFlagsFromBase ( System.Boolean newSystem = true, System.Boolean newStation = true ) : void
newSystem System.Boolean
newStation System.Boolean
return void