private static void SimpleDefragmentationWithBackupLocation() { CreateAndFillDatabase(); // #example: Specify backup file explicitly Defragment.Defrag("database.db4o", "database.db4o.bak"); // #end example }
void DefragDatabase() { if (!File.Exists(DatabaseFile)) { return; } DateTime start = DateTime.UtcNow, stop; var backupFile = String.Format( "{0}.bak_{1}.{2}", DatabaseFile, Db4oVersion.Major, Db4oVersion.Minor ); var defragConfig = new DefragmentConfig( DatabaseFile, backupFile ); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); stop = DateTime.UtcNow; #if LOG4NET Logger.Debug( String.Format( "DefragDatabase(): defrag took: {0:0.0} ms", (stop - start).TotalMilliseconds ) ); #endif }
private static void SimplestPossibleDefragment() { CreateAndFillDatabase(); // #example: Simplest possible defragment use case Defragment.Defrag("database.db4o"); // #end example }
public void ConfigureBackupFile() { // #example: Configure the file and backup file DefragmentConfig config = new DefragmentConfig("database.db4o", "database.db4o.back"); Defragment.Defrag(config); // #end example }
public void ConfigureFile() { // #example: Configure the file DefragmentConfig config = new DefragmentConfig("database.db4o"); Defragment.Defrag(config); // #end example }
// #end example private static void DefragmentWithConfiguration() { CreateAndFillDatabase(); // #example: Defragment with configuration DefragmentConfig config = new DefragmentConfig("database.db4o"); Defragment.Defrag(config); // #end example }
public void SetMappingImplementation() { // #example: Choose a id mapping system IIdMapping mapping = new InMemoryIdMapping(); DefragmentConfig config = new DefragmentConfig("database.db4o", "database.db4o.back", mapping); Defragment.Defrag(config); // #end example }
public void DeleteBackup() { // #example: Delete the backup after the defragmentation process DefragmentConfig config = new DefragmentConfig("database.db4o"); config.ForceBackupDelete(true); Defragment.Defrag(config); // #end example }
public void ChangeBackupStorage() { // #example: Use a separate storage for the backup DefragmentConfig config = new DefragmentConfig("database.db4o"); config.BackupStorage(new FileStorage()); Defragment.Defrag(config); // #end example }
public void DisableReadOnlyForBackup() { // #example: Disable readonly on backup DefragmentConfig config = new DefragmentConfig("database.db4o"); config.ReadOnly(false); Defragment.Defrag(config); // #end example }
public void SetCommitFrequency() { // #example: Set the commit frequency DefragmentConfig config = new DefragmentConfig("database.db4o"); config.ObjectCommitFrequency(10000); Defragment.Defrag(config); // #end example }
public void UseAClassFilter() { // #example: Use class filter DefragmentConfig config = new DefragmentConfig("database.db4o"); config.StoredClassFilter(new AvailableTypeFilter()); Defragment.Defrag(config); // #end example }
public void UpgradeDb4OFile() { // #example: Upgrade database version DefragmentConfig config = new DefragmentConfig("database.db4o"); config.UpgradeFile(Environment.GetEnvironmentVariable("TEMP")); Defragment.Defrag(config); // #end example }
private void DefragFileDataBase() { EnsureCloseDb4OContainer(); var defragConfig = new DefragmentConfig(Db4oDataBaseFilePath); defragConfig.Db4oConfig(GetEmbeddedConfiguration()); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); }
private static void DefragmentationWithIdMissing() { CreateAndFillDatabase(); // #example: Use a defragmentation listener DefragmentConfig config = new DefragmentConfig("database.db4o"); Defragment.Defrag(config, new DefragmentListener()); // #end example }
public void SetDb4OConfiguration() { // #example: Use the database-configuration DefragmentConfig config = new DefragmentConfig("database.db4o"); // It's best to use the very same configuration you use for the regular database IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); config.Db4oConfig(configuration); Defragment.Defrag(config); // #end example }
private void ShowReport(Defragment defragger) { if (Dispatcher.Thread != Thread.CurrentThread) { Dispatcher.Invoke(new Action <Defragment>(ShowReport), defragger); return; } Report report = new Report(defragger); report.ShowDialog(); }
public Report(Defragment defragger) { InitializeComponent(); Units = new[] { "Bytes", "Kilobytes", "Megabytes", "Gigabytes" }; OnPropertyChanged("Units"); SelectedIndexUnit = 0; Defragger = defragger; DefragReport = defragger.Report; UpdateData(); }
/// <summary> /// Ejecuto el hilo que defragmentara la base de datos /// </summary> private void RunningDefrag() { try { Defragment.Defrag(base.sFile); if (bServerWasRunning) { servidor.Run(); } } catch (Exception ex) { Log.AddToLog(sJobName, ex.Message); } }
private void DefragFileDataBase() { CloseDb4OContainer(); var clientConfig = Db4oEmbedded.NewConfiguration(); SetCommonConfiguration(clientConfig.Common, false); var defragConfig = new DefragmentConfig(DataBaseFilePath); defragConfig.Db4oConfig(clientConfig); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); }
public void DefragmentDB() { if (server != null) { server.Close(); } if (!Directory.Exists(InfoUpdater.BackupsFolder)) { Directory.CreateDirectory(InfoUpdater.BackupsFolder); } string backup_file = string.Format("authors.{0}.db4o", InfoUpdater.TimeStamp); //DateTime.Now.ToString()).Replace(" ", "_").Replace(":", "_"); backup_file = Path.Combine(InfoUpdater.BackupsFolder, backup_file); // дефрагментируем БД MainWindow.MainForm.GetLogger().Add(DateTime.Now + " Дефрагментируется база данных...", true, false); Defragment.Defrag(db_name, backup_file); MainWindow.MainForm.GetLogger().Add(DateTime.Now + " Дефрагментация выполнена.", true, false); }
public void DefragmentDatabase() { bool defragmentError = false; try { CloseDatabase(); DefragmentConfig defragConfig = new DefragmentConfig( BookStoreGUI.Properties.Settings.Default.DatabaseFilePath, BookStoreGUI.Properties.Settings.Default.DatabaseBackupFilePath); defragConfig.Db4oConfig(DBConfiguration.Configuration); defragConfig.ForceBackupDelete(true); Defragment.Defrag(defragConfig); } catch (Exception ex) { defragmentError = true; throw new DatabaseException("Could not defragment the database.", ex); } finally { if (defragmentError == false) { try { if (File.Exists(BookStoreGUI.Properties.Settings.Default.DatabaseBackupFilePath) == true) { File.Delete(BookStoreGUI.Properties.Settings.Default.DatabaseBackupFilePath); } } catch (Exception) { } } } }