Beispiel #1
0
 public static void close()
 {
     if (search_db != null)
     {
         search_db.GetDatabase().Close();
     }
     search_db = null;
     Console.WriteLine("DBClosed");
 }
Beispiel #2
0
        /// <summary>
        /// Disposes all databases.
        /// </summary>
        public void DisposeAllDB()
        {
            if (m_tableIndexDB != null)
            {
                m_tableIndexDB.GetDatabase().Dispose();
                m_tableIndexDB = null;
            }

            DisposeAllMetadataDB();
        }
Beispiel #3
0
        /// <summary>
        /// Disposes the metadata database.
        /// </summary>
        /// <typeparam name="T">The type of metadata database.</typeparam>
        public void DisposeMetadataDB <T>()
        {
            Type type = typeof(T);

            DB.AutoBox db = m_metadataDBMap[type];

            if (db != null)
            {
                db.GetDatabase().Dispose();
                m_metadataDBMap.Remove(type);
                db = null;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Disposes all metadata databases.
        /// </summary>
        public void DisposeAllMetadataDB()
        {
            foreach (KeyValuePair <Type, DB.AutoBox> kvp in m_metadataDBMap)
            {
                DB.AutoBox db = kvp.Value;

                if (db != null)
                {
                    db.GetDatabase().Dispose();
                }
            }

            m_metadataDBMap.Clear();
        }
        private void BtnConnect_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.tbFilePath.Text))
            {
                System.Windows.MessageBox.Show("Please select iBoxDB file", "Warning");
                return;
            }
            if (db == null)
            {
                server = new DB(this.tbFilePath.Text);
                db     = server.Open();
            }
            var tables = db.GetDatabase().GetSchemata().Keys;

            foreach (string table in tables)
            {
                if (!table.StartsWith("__"))
                {
                    this.cbTable.Items.Add(table);
                }
            }
        }
Beispiel #6
0
        public static bool Test(bool background)
        {
            var bakAddr = 0 - Math.Abs(DateTime.Now.Ticks);

            DDebug.DeleteDBFiles(1);
            DB server = new DB(1);

            server.SetBoxRecycler(new FileBackupBoxRecycler());
            server.GetConfig().EnsureTable <DBObject>("DBObject", "ID");
            DB.AutoBox auto = server.Open();

            Parallel.For(0, 300, (i) =>
            {
                var obj   = new DBObject();
                obj.ID    = auto.NewId(0);
                obj.Value = "Value " + obj.ID;
                obj.DT    = DateTime.Now;
                auto.Insert("DBObject", obj);
            });


            // Export
            if (background)
            {
                Thread backupThread = new Thread(() =>
                {
                    ((FileBackupBoxRecycler)auto.GetDatabase().GetBoxRecycler()).Phase1(auto.GetDatabase(), bakAddr);
                });
                backupThread.Start();

                Parallel.For(0, 300, (i) =>
                {
                    var obj   = new DBObject();
                    obj.ID    = auto.NewId(0);
                    obj.Value = "Value " + obj.ID;
                    obj.DT    = DateTime.Now;
                    auto.Insert("DBObject", obj);
                });

                backupThread.Join();
                ((FileBackupBoxRecycler)auto.GetDatabase().GetBoxRecycler()).Phase2();
            }
            else
            {
                ((FileBackupBoxRecycler)auto.GetDatabase().GetBoxRecycler()).Backup(auto.GetDatabase(), bakAddr);
            }


            //Import
            DB bakserver = new DB(bakAddr);

            bakserver.GetConfig().DBConfig.SwapFileBuffer = 0;
            DB.AutoBox bakauto = bakserver.Open();

            DBObject[] s1 = auto.Select <DBObject>("from DBObject").ToArray();
            DBObject[] s2 = bakauto.Select <DBObject>("from DBObject").ToArray();

            server.Dispose();
            bakserver.Dispose();
            DDebug.DeleteDBFiles(bakAddr);
            return(s1.SequenceEqual(s2));
        }
Beispiel #7
0
 public void Dispose()
 {
     _db.GetDatabase().Dispose();
 }