C# Class Shared.Data.DatabaseImplementation

This is the implementation of the database with all queries, commands, etc.
Inheritance: IDisposable
Afficher le fichier Open project: sealuzh/PersonalAnalytics Class Usage Examples

Méthodes publiques

Свойство Type Description
CurrentDatabaseDumpFile string

Méthodes publiques

Méthode Description
Connect ( ) : void

Opens a connection to the database with the current database save path

CreateLogTable ( ) : void

Creates a table for the log inputs (if it doesn't yet exist)

CreateSettingsTable ( ) : void

Creates a table for the settings (keys) (if it doesn't yet exist)

CreateTimeZoneTable ( ) : void

Creates a table for the time zone (if it doesn't yet exist)

DatabaseImplementation ( string dbFilePath ) : System
Disconnect ( ) : void

Closes the connection to the database.

Dispose ( ) : void
ExecuteDefaultQuery ( string query ) : int

Executes a query (given as parameter). Also logs the query.

ExecuteQueryWithTransaction ( List commands ) : void
ExecuteReadQuery ( string query ) : DataTable

Executes a query (given as a parameter).

ExecuteScalar ( string query ) : int

Executes a query scalar. Return 1 in case of an entry, or 0 in case of no entry or an error

ExecuteScalar2 ( string query ) : object

Executes a query scalar and returns null if there was an error (or no entry) used for settings. Somehow strange?

GetDateFilteringStringForQuery ( VisType type, DateTimeOffset date, string datePropertyName = "time" ) : string
GetDbPragmaVersion ( ) : int

Get the actual database version

GetLastTimeZoneEntry ( ) : TimeZoneInfo
GetSettingsBool ( string key, bool byDefault ) : bool

Gets the stored setting value for a given key

GetSettingsDate ( string key, DateTimeOffset byDefault ) : DateTimeOffset
GetSettingsInt ( string key, int byDefault ) : int

Gets the stored setting value for a given key

GetSettingsString ( string key, string byDefault ) : string

gets the stored setting value for a given key

GetUserWorkEnd ( DateTimeOffset date ) : DateTime
GetUserWorkStart ( DateTimeOffset date ) : DateTime
HasSetting ( string key ) : bool

Checks if a settings for a given key is stored. returns false in case of an error

LogError ( string message ) : void

Inserts the message (given as a parameter) into the log-database-table (flag: Error).

LogErrorUnknown ( string tracker ) : void

Inserts an unknown error with the name of the tracker into the log-database-table (flag: Error). Also logs the query.

LogInfo ( string message ) : void

Inserts the message (given as a parameter) into the log-database-table (flag: Info). Also logs the query.

LogTimeZoneChange ( TimeZoneInfo currentTimeZone ) : void
LogWarning ( string message ) : void

Inserts the message (given as a parameter) into the log-database-table (flag: Warning). Also logs the query.

Q ( bool str ) : string

Q is the James-Bond guy. But for bools.

Q ( int str ) : string

Q is the James-Bond guy. But for ints.

Q ( long str ) : string

Q is the James-Bond guy. But for longs.

Q ( string str ) : string

Q is the James-Bond guy. Improves the string characters not to mess it up in the query string.

QDate ( DateTime dateTime ) : string

Formats and magicifies a datetime '%Y-%m-%d'

QTime ( DateTime dateTime ) : string

Formats and magicifies a datetime '%Y-%m-%d %H:%M:%S'

Reconnect ( ) : void
SetSettings ( string key, bool value ) : void

Saves a setting with a given key or value. Inserts new entry if nothing is yet stored or updates the value.

SetSettings ( string key, string value ) : void

Saves a setting with a given key or value. Inserts new entry if nothing is yet stored or updates the value.

UpdateDbPragmaVersion ( int version ) : void

Update the database version when an existing table changes

Private Methods

Méthode Description
WriteQueryToLog ( string query, bool force = false ) : void

Logs the query if the global setting allows it and it's not enforced my the calling method.

Method Details

Connect() public méthode

Opens a connection to the database with the current database save path
public Connect ( ) : void
Résultat void

CreateLogTable() public méthode

Creates a table for the log inputs (if it doesn't yet exist)
public CreateLogTable ( ) : void
Résultat void

CreateSettingsTable() public méthode

Creates a table for the settings (keys) (if it doesn't yet exist)
public CreateSettingsTable ( ) : void
Résultat void

CreateTimeZoneTable() public méthode

Creates a table for the time zone (if it doesn't yet exist)
public CreateTimeZoneTable ( ) : void
Résultat void

DatabaseImplementation() public méthode

public DatabaseImplementation ( string dbFilePath ) : System
dbFilePath string
Résultat System

Disconnect() public méthode

Closes the connection to the database.
public Disconnect ( ) : void
Résultat void

Dispose() public méthode

public Dispose ( ) : void
Résultat void

ExecuteDefaultQuery() public méthode

Executes a query (given as parameter). Also logs the query.
public ExecuteDefaultQuery ( string query ) : int
query string
Résultat int

ExecuteQueryWithTransaction() public méthode

public ExecuteQueryWithTransaction ( List commands ) : void
commands List
Résultat void

ExecuteReadQuery() public méthode

Executes a query (given as a parameter).
public ExecuteReadQuery ( string query ) : DataTable
query string
Résultat DataTable

ExecuteScalar() public méthode

Executes a query scalar. Return 1 in case of an entry, or 0 in case of no entry or an error
public ExecuteScalar ( string query ) : int
query string
Résultat int

ExecuteScalar2() public méthode

Executes a query scalar and returns null if there was an error (or no entry) used for settings. Somehow strange?
public ExecuteScalar2 ( string query ) : object
query string
Résultat object

GetDateFilteringStringForQuery() public méthode

public GetDateFilteringStringForQuery ( VisType type, DateTimeOffset date, string datePropertyName = "time" ) : string
type VisType
date DateTimeOffset
datePropertyName string
Résultat string

GetDbPragmaVersion() public méthode

Get the actual database version
public GetDbPragmaVersion ( ) : int
Résultat int

GetLastTimeZoneEntry() public méthode

public GetLastTimeZoneEntry ( ) : TimeZoneInfo
Résultat TimeZoneInfo

GetSettingsBool() public méthode

Gets the stored setting value for a given key
public GetSettingsBool ( string key, bool byDefault ) : bool
key string
byDefault bool
Résultat bool

GetSettingsDate() public méthode

public GetSettingsDate ( string key, DateTimeOffset byDefault ) : DateTimeOffset
key string
byDefault DateTimeOffset
Résultat DateTimeOffset

GetSettingsInt() public méthode

Gets the stored setting value for a given key
public GetSettingsInt ( string key, int byDefault ) : int
key string
byDefault int
Résultat int

GetSettingsString() public méthode

gets the stored setting value for a given key
public GetSettingsString ( string key, string byDefault ) : string
key string
byDefault string
Résultat string

GetUserWorkEnd() public méthode

public GetUserWorkEnd ( DateTimeOffset date ) : DateTime
date DateTimeOffset
Résultat DateTime

GetUserWorkStart() public méthode

public GetUserWorkStart ( DateTimeOffset date ) : DateTime
date DateTimeOffset
Résultat DateTime

HasSetting() public méthode

Checks if a settings for a given key is stored. returns false in case of an error
public HasSetting ( string key ) : bool
key string
Résultat bool

LogError() public méthode

Inserts the message (given as a parameter) into the log-database-table (flag: Error).
public LogError ( string message ) : void
message string
Résultat void

LogErrorUnknown() public méthode

Inserts an unknown error with the name of the tracker into the log-database-table (flag: Error). Also logs the query.
public LogErrorUnknown ( string tracker ) : void
tracker string
Résultat void

LogInfo() public méthode

Inserts the message (given as a parameter) into the log-database-table (flag: Info). Also logs the query.
public LogInfo ( string message ) : void
message string
Résultat void

LogTimeZoneChange() public méthode

public LogTimeZoneChange ( TimeZoneInfo currentTimeZone ) : void
currentTimeZone TimeZoneInfo
Résultat void

LogWarning() public méthode

Inserts the message (given as a parameter) into the log-database-table (flag: Warning). Also logs the query.
public LogWarning ( string message ) : void
message string
Résultat void

Q() public méthode

Q is the James-Bond guy. But for bools.
public Q ( bool str ) : string
str bool
Résultat string

Q() public méthode

Q is the James-Bond guy. But for ints.
public Q ( int str ) : string
str int
Résultat string

Q() public méthode

Q is the James-Bond guy. But for longs.
public Q ( long str ) : string
str long
Résultat string

Q() public méthode

Q is the James-Bond guy. Improves the string characters not to mess it up in the query string.
public Q ( string str ) : string
str string
Résultat string

QDate() public méthode

Formats and magicifies a datetime '%Y-%m-%d'
public QDate ( DateTime dateTime ) : string
dateTime DateTime
Résultat string

QTime() public méthode

Formats and magicifies a datetime '%Y-%m-%d %H:%M:%S'
public QTime ( DateTime dateTime ) : string
dateTime DateTime
Résultat string

Reconnect() public méthode

public Reconnect ( ) : void
Résultat void

SetSettings() public méthode

Saves a setting with a given key or value. Inserts new entry if nothing is yet stored or updates the value.
public SetSettings ( string key, bool value ) : void
key string
value bool
Résultat void

SetSettings() public méthode

Saves a setting with a given key or value. Inserts new entry if nothing is yet stored or updates the value.
public SetSettings ( string key, string value ) : void
key string
value string
Résultat void

UpdateDbPragmaVersion() public méthode

Update the database version when an existing table changes
public UpdateDbPragmaVersion ( int version ) : void
version int
Résultat void

Property Details

CurrentDatabaseDumpFile public_oe property

public string CurrentDatabaseDumpFile
Résultat string