C# Class BF2Statistics.Database.StatsDatabase

A class to provide common tasks against the Stats Database
Inheritance: BF2Statistics.Database.DatabaseDriver, IDisposable
Show file Open project: BF2Statistics/ControlCenter Class Usage Examples

Public Properties

Property Type Description
LatestVersion System.Version
PlayerTables string[]
StatsTables string[]
VersionList System.Version[]

Public Methods

Method Description
CreateSqlTables ( IProgress TaskProgress = null ) : void

Tells the Database to install the Stats tables into the database

DeletePlayer ( int Pid, IProgress TaskProgress = null ) : void

Removes a player, based on pid, from the stats database

GetPlayerAwards ( int Pid ) : object>>.List

Returns a list of awards a player has earned

MigrateTables ( ) : void

If there is any table updates that need to be applied, calling this method will apply each update until the current database version is up to date

MigrateTables ( System.Version ToVersion ) : void

If there is any table updates that need to be applied, calling this method will apply each update until the specifed update version

PlayerExists ( int Pid ) : bool

Returns whether or not a player exists in the "player" table

StatsDatabase ( ) : System

Creates a connection to the Stats Database

Truncate ( ) : void

Clears all stats data from the stats database

Protected Methods

Method Description
GetTablesVersion ( ) : void

Fetches the current tables version

We have this in a seperate method because the table migration fetches the the version everytime an update is applied

Private Methods

Method Description
CreateMysqlTables ( IProgress TaskProgress ) : void

On a new Mysql database, this method will create the default tables

CreateSqliteTables ( IProgress TaskProgress ) : void

On a new Sqlite database, this method will create the default tables

Method Details

CreateSqlTables() public method

Tells the Database to install the Stats tables into the database
public CreateSqlTables ( IProgress TaskProgress = null ) : void
TaskProgress IProgress
return void

DeletePlayer() public method

Removes a player, based on pid, from the stats database
public DeletePlayer ( int Pid, IProgress TaskProgress = null ) : void
Pid int The players Id
TaskProgress IProgress The progress object to report to.
return void

GetPlayerAwards() public method

Returns a list of awards a player has earned
public GetPlayerAwards ( int Pid ) : object>>.List
Pid int The Player ID
return object>>.List

GetTablesVersion() protected method

Fetches the current tables version
We have this in a seperate method because the table migration fetches the the version everytime an update is applied
protected GetTablesVersion ( ) : void
return void

MigrateTables() public method

If there is any table updates that need to be applied, calling this method will apply each update until the current database version is up to date
public MigrateTables ( ) : void
return void

MigrateTables() public method

If there is any table updates that need to be applied, calling this method will apply each update until the specifed update version
public MigrateTables ( System.Version ToVersion ) : void
ToVersion System.Version
return void

PlayerExists() public method

Returns whether or not a player exists in the "player" table
public PlayerExists ( int Pid ) : bool
Pid int The Player ID
return bool

StatsDatabase() public method

Creates a connection to the Stats Database
public StatsDatabase ( ) : System
return System

Truncate() public method

Clears all stats data from the stats database
public Truncate ( ) : void
return void

Property Details

LatestVersion public static property

Indicates the most up to date database table version
public static Version,System LatestVersion
return System.Version

PlayerTables public static property

An array of Table names that contain only player data
public static string[] PlayerTables
return string[]

StatsTables public static property

An array of all Stats specific table names
public static string[] StatsTables
return string[]

VersionList public static property

An array of all table versions that we can migrate from if updating from an old database tables version
public static Version[],System VersionList
return System.Version[]