Ejemplo n.º 1
0
 public void SetAutoVacuum(AUTOVACUUMMODE mode)
 {
     // changes the auto vacuum pragma
     // command requires a VACUUM of the database to change layout
     // CAUTION: this requires time and disk space!
     try
     {
         Execute("PRAGMA auto_vacuum = " + ((int)mode).ToString() + "; VACUUM");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Ejemplo n.º 2
0
        public AircraftPositionDatabase()
        {
            UserVersion = 1;
            Name        = "AirScout Aircraft Position Database";
            Description = "Holds aircraft position history.";
            db          = OpenDatabase("aircraftpositions.db3", DefaultDatabaseDirectory(), Properties.Settings.Default.Database_InMemory);
            // set auto vacuum mode to "Full" to allow database to reduce size on disk
            // requires a vacuum command to change database layout
            AUTOVACUUMMODE mode = db.GetAutoVacuum();

            if (mode != AUTOVACUUMMODE.FULL)
            {
                if (MessageBox.Show("A major database layout change is necessary to run this version of AirScout. Older versions of AirScout are not compatible anymore and will cause errors. \n\nPress >OK< to start upgrade now (this will take some minutes). \nPress >Cancel< to leave.", "Database Upgrade of " + Path.GetFileName(db.DBLocation), MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    Environment.Exit(-1);                 //  exit immediately
                }
                db.SetAutoVacuum(AUTOVACUUMMODE.FULL);
            }
            // create tables with schemas if not exist
            if (!AircraftPositionTableExists())
            {
                AircraftPositionCreateTable();
            }
        }