Esempio n. 1
0
        //--------------------------------------------------------------------------
        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);
                }
            }));
        }
Esempio n. 2
0
        //--------------------------------------------------------------------------
        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);
                }
            }));
        }
Esempio n. 3
0
        //--------------------------------------------------------------------------
        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);
                }
            }));
        }