//-------------------------------------------------------------------------- public bool Import(FileInfo filename, ExportImportCallback callback) { if (callback == null) { return(false); } return(_workerThread.PostTask(_ => { try { GlobalParamatersService.Delegate.OnDatabaseImportStatusChanged( "Dropping tables ..."); DatabaseConnectionService.Instance.DropTables(); GlobalParamatersService.Delegate.OnDatabaseImportStatusChanged( "Creating new tables ..."); DatabaseConnectionService.Instance.CreateTables(); // zero them all _statsUpdate.CollectStats(); DatabaseConnectionService.Instance.ImportDatabase(filename, _statsUpdate); callback(true, null); } catch (Exception e) { callback(false, e.Message); } })); }
//-------------------------------------------------------------------------- public bool ResetDB(ExportImportCallback callback) { if (callback == null) { return(false); } return(_workerThread.PostTask(_ => { try { GlobalParamatersService.Delegate.OnDatabaseImportStatusChanged( "Dropping tables ..."); try { DatabaseConnectionService.Instance.DropTables(); } catch (Exception) { } GlobalParamatersService.Delegate.OnDatabaseImportStatusChanged( "Creating tables ..."); DatabaseConnectionService.Instance.CreateTables(); _statsUpdate.CollectStats(); callback(true, null); } catch (Exception e) { callback(false, e.Message); } })); }
//-------------------------------------------------------------------------- public bool Export(FileInfo filename, ExportImportCallback callback) { if (callback == null) { return(false); } return(_workerThread.PostTask(_ => { try { DatabaseConnectionService.Instance.ExportDatabase(filename); callback(true, null); } catch (Exception e) { callback(false, e.Message); } })); }