Beispiel #1
0
        public void Diagnose(RepairProgressEventHandler progress)
        {
            ResourceStoreRepair rsRepair = new ResourceStoreRepair(_database);

            rsRepair.FixErrors       = false;
            rsRepair.DumpStructure   = false;
            rsRepair.RepairProgress += progress;
            rsRepair.Run();
            rsRepair.RepairProgress -= progress;
        }
Beispiel #2
0
        private void ProcessDB()
        {
            if (!DBHelper.DatabaseExists(MyPalStorage.DBPath, "MyPal"))
            {
                Console.WriteLine("Omea database not found");
                return;
            }

            DBStructure dbStructure = new DBStructure(MyPalStorage.DBPath, "MyPal");

            dbStructure.ProgressListenerEvent += new DBStructure.ProgressEventHandler(dbStructure_ProgressListenerEvent);

            Console.WriteLine("Loading database...");

            bool structureCorrupted = false;

            try
            {
                dbStructure.LoadStructure(true);
            }
            catch (Exception)
            {
                structureCorrupted = true;
            }

            if (structureCorrupted || !AllTablesExist(dbStructure))
            {
                Console.WriteLine("Rebuilding database structure...");
                dbStructure.Shutdown();

                MyPalStorage.CreateDatabase();
                dbStructure = new DBStructure(MyPalStorage.DBPath, "MyPal");
                dbStructure.LoadStructure(true);
                _forceRebuild = true;
            }

            if (_defrag)
            {
                Console.WriteLine("Defragmenting database...");
                dbStructure.Defragment();
            }
            else if (!dbStructure.IsDatabaseCorrect())
            {
                Console.WriteLine("Database indexes are corrupt. Rebuilding...");
                dbStructure.RebuildIndexes();
            }
            else if (_forceRebuild)
            {
                Console.WriteLine("Performing forced rebuild of database indexes...");
                dbStructure.RebuildIndexes(true);
            }
            else if (_lowCheck)
            {
                dbStructure.LowLevelCheck( );
                return;
            }

            if (_dbdump)
            {
                Console.WriteLine("Dumping database...");
                dbStructure.Dump();
            }

            IDatabase db = dbStructure.OpenDatabase();

            if (_calcSpace)
            {
                CalcSpace(db, "ResourceTypes");
                CalcSpace(db, "PropTypes");
                CalcSpace(db, "IntProps");
                CalcSpace(db, "StringProps");
                CalcSpace(db, "LongStringProps");
                CalcSpace(db, "StringListProps");
                CalcSpace(db, "DateProps");
                CalcSpace(db, "BlobProps");
                CalcSpace(db, "DoubleProps");
                CalcSpace(db, "Resources");
                CalcSpace(db, "Links");
                return;
            }

            ResourceStoreRepair rsRepair = new ResourceStoreRepair(db);

            rsRepair.FixErrors       = _fixErrors;
            rsRepair.DumpStructure   = _dump;
            rsRepair.RepairProgress += new RepairProgressEventHandler(RsRepair_OnRepairProgress);
            rsRepair.Run();
        }