C# Class Business.DatabaseHandler

Ensures server and database are up and running.
Show file Open project: mysteryx93/NaturalGroundingPlayer Class Usage Examples

Public Methods

Method Description
CopyFileAsync ( string sourcePath, string destinationPath ) : Task
DatabaseHandler ( Window owner ) : System
EnsureAvailableAsync ( ) : Task

Checks server and database availability. If there is no database file, copy and attach initial database. Update database if it is outdated.

If connection fails, the exception must be handled by the caller.

LogException ( Exception ex ) : void

Writes exception details into a log file.

UpdateDatabaseAsync ( ) : Task

Updates database if needed.

Private Methods

Method Description
CreateNewDatabaseAsync ( ) : Task

Creates a new database.

GetUpdateScript ( string name ) : string

Returns the update script with specified name.

RunScript ( string scriptFile ) : void

Runs the specified database script.

TryUntilTimeout ( System.Action action, int timeout ) : Task
UpdateDatabaseToVersion ( bool backupBeforeUpdate, int major, int minor, int build, int revision ) : void

Updates database by running a script, after making an optional backup.

Method Details

CopyFileAsync() public method

public CopyFileAsync ( string sourcePath, string destinationPath ) : Task
sourcePath string
destinationPath string
return Task

DatabaseHandler() public method

public DatabaseHandler ( Window owner ) : System
owner Window
return System

EnsureAvailableAsync() public method

Checks server and database availability. If there is no database file, copy and attach initial database. Update database if it is outdated.
If connection fails, the exception must be handled by the caller.
public EnsureAvailableAsync ( ) : Task
return Task

LogException() public method

Writes exception details into a log file.
public LogException ( Exception ex ) : void
ex System.Exception The exception to log.
return void

UpdateDatabaseAsync() public method

Updates database if needed.
public UpdateDatabaseAsync ( ) : Task
return Task