/// <summary> /// Gets the configuration metadata list. /// </summary> /// <typeparam name="T">The type of metadata.</typeparam> /// <param name="conditions">The conditions dictionary.</param> /// <returns></returns> public List <T> GetConfigMetadataList <T>(Dictionary <string, object> conditions) where T : ConfigMetadata, new() { DB.AutoBox db = GetDB <T>(); if (db != null) { Type type = typeof(T); string tableName = type.Name; string sql = "from " + tableName + " where"; int i = 0; int length = conditions.Keys.Count; foreach (string key in conditions.Keys) { sql += " " + key + "==?"; if (i < length - 1) { sql += " &"; } i++; } List <object> values = new List <object>(conditions.Values); IBEnumerable <T> items = db.Select <T>(sql, values.ToArray()); return(new List <T>(items)); } return(null); }
/// <summary> /// Gets the database. /// </summary> /// <typeparam name="T">The type of metadata. </typeparam> /// <returns>The database object. </returns> private DB.AutoBox GetDB <T>() where T : ConfigMetadata, new() { Type type = typeof(T); string tableName = type.Name; DB.AutoBox db = null; if (m_metadataDBMap.ContainsKey(type)) { db = m_metadataDBMap[type]; } else { long localAddress = GetTableLocalAddress <T>(); if (localAddress != -1) { DB server = new DB(localAddress); string primaryKey = GetPrimaryKey(); if (!string.IsNullOrEmpty(primaryKey)) { server.GetConfig().EnsureTable <T>(tableName, primaryKey); db = server.Open(); m_metadataDBMap.Add(type, db); } else { Debug.LogError("Table primary key can not be null or empty !"); } } } return(db); }
static public void InitDB() { string path = string.Empty; if (db != null) { return; } DB.Root(path); server = new DB(1); server.GetConfig().EnsureTable <Province>("Province", "ID"); //server.GetConfig().EnsureTable<Country>("Country", "ID"); server.GetConfig().EnsureTable <Item>("Item", "ID"); db = server.Open(); //using (var box = db.Cube()) //{ // foreach(var it in box.Select<Province>("from Province where 1==1")){ // box.Bind("Province", it.ID).Delete(); // } // box.Commit(); //} }
public iBoxDBBackedTest() { var server = new DB(); server.GetConfig().EnsureTable <Author>(DBTableNames.Authors, "Id"); _db = server.Open(); }
/// <summary> /// Opens this database. /// </summary> public void Open() { if (m_server != null) { m_db = m_server.Open(); } }
public static void init(String path, bool isVM) { Console.WriteLine("DBPath=" + path); DB.Root(path); DB server = new DB(1); if (isVM) { server.GetConfig().DBConfig.CacheLength = server.GetConfig().DBConfig.MB(16); } else { server.GetConfig().DBConfig.CacheLength = server.GetConfig().DBConfig.MB(512); } server.GetConfig().DBConfig.SwapFileBuffer = (int)server.GetConfig().DBConfig.MB(4); server.GetConfig().DBConfig.FileIncSize = (int)server.GetConfig().DBConfig.MB(16); new Engine().Config(server.GetConfig().DBConfig); server.GetConfig().EnsureTable <Page> ("Page", "id"); server.GetConfig().EnsureIndex <Page> ("Page", true, "url(" + Page.MAX_URL_LENGTH + ")"); search_db = server.Open(); }
public static void close() { if (search_db != null) { search_db.GetDatabase().Close(); } search_db = null; Console.WriteLine("DBClosed"); }
/// <summary> /// Disposes all databases. /// </summary> public void DisposeAllDB() { if (m_tableIndexDB != null) { m_tableIndexDB.GetDatabase().Dispose(); m_tableIndexDB = null; } DisposeAllMetadataDB(); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> public void Dispose() { Close(); if (m_server != null) { m_server.Dispose(); } m_server = null; m_db = null; }
/// <summary> /// Opens the database. /// </summary> /// <exception cref="ObjectDisposedException">database</exception> public void Open() { CheckIfDisposed(); if (Database == null) { return; } Box = Database.Open(); IsOpen = true; }
/// <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; } }
/// <summary> /// Destroys the database. /// </summary> private static void DestroyDatabase() { if (s_tableIndexDB != null) { s_tableIndexDB = null; } if (s_tableIndexServer != null) { s_tableIndexServer.Dispose(); s_tableIndexServer = null; } }
/// <summary> /// Gets the configuration metadata. /// </summary> /// <typeparam name="T">The type of metadata. </typeparam> /// <param name="id">The identifier.</param> /// <returns></returns> public T GetConfigMetadata <T>(long id) where T : ConfigMetadata, new() { DB.AutoBox db = GetDB <T>(); if (db != null) { Type type = typeof(T); string tableName = type.Name; T item = db.SelectKey <T>(tableName, id); return(item); } return(null); }
/// <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(); }
/// <summary> /// Creates the table index database. /// </summary> private void CreateTableIndexDB() { if (m_tableIndexDB == null) { DB server = new DB(ConfigMetadata.IndexTableLocalAddress); DatabaseConfig.Config serverConfig = server.GetConfig(); if (serverConfig != null) { serverConfig.EnsureTable <MetadataLocalAddress>(MetadataLocalAddress.TableName, MetadataLocalAddress.PrimaryKey); serverConfig.EnsureTable <ConfigParameter>(ConfigParameter.TableName, ConfigParameter.PrimaryKey); } m_tableIndexDB = server.Open(); } }
public DefaultServiceManager(ICache cache, ILogService logService, IEncryptionProvider encryptionProvider, IDiaryService diaryService, IDiaryCommentService diaryCommentService, IMovieCommentService movieCommentService, IAccountService accountService) { this._cache = cache; this._autoBox = null; this._logService = logService; this._encryptionProvider = encryptionProvider; this._diaryService = diaryService; this._diaryCommentService = diaryCommentService; this._movieCommentService = movieCommentService; this._accountService = accountService; }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { Box?.Dispose(); Box = null; Database?.Dispose(); Database = null; IsOpen = false; } disposed = true; }
public static void init(String path) { Console.WriteLine("DBPath=" + path); DB.Root(path); DB server = new DB(1); /* * server.GetConfig().DBConfig.CacheLength * = server.GetConfig().DBConfig.MB(8); */ server.GetConfig().DBConfig.SwapFileBuffer = (int)server.GetConfig().DBConfig.MB(2); new Engine().Config(server.GetConfig().DBConfig); server.GetConfig().EnsureTable <Page> ("Page", "id"); server.GetConfig().EnsureIndex <Page> ("Page", true, "url(100)"); search_db = server.Open(); }
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); } } }
public EditPostCommandInvoker(DB.AutoBox db) { _db = db; }
public ChangePasswordCommandInvoker(DB.AutoBox db) { _db = db; }
public iBoxDBBackedTest() { var server = new DB(); server.GetConfig().EnsureTable<Author>(DBTableNames.Authors, "Id"); _db = server.Open(); }
public AllBlogPostViewProjection(DB.AutoBox db) { _db = db; }
public DeleteCommentCommandInvoker(DB.AutoBox db) { _db = db; }
public SpamShieldService(DB.AutoBox db) { _db = db; }
public static void init(String path) { Console.WriteLine ("DBPath=" + path); DB.Root (path); DB server = new DB (1); /* server.GetConfig().DBConfig.CacheLength = server.GetConfig().DBConfig.MB(8); */ server.GetConfig ().DBConfig.SwapFileBuffer = (int)server.GetConfig ().DBConfig.MB (2); new Engine ().Config (server.GetConfig ().DBConfig); server.GetConfig ().EnsureTable<Page> ("Page", "id"); server.GetConfig ().EnsureIndex<Page> ("Page", true, "url(100)"); search_db = server.Open (); }
public static void close() { if (search_db != null) { search_db.GetDatabase ().Close (); } search_db = null; Console.WriteLine ("DBClosed"); }
public BlogCommentsViewProjection(DB.AutoBox db) { _db = db; }
public ChangeProfileCommandInvoker(DB.AutoBox db) { _db = db; }
public BlogPostEditViewProjection(DB.AutoBox db) { _db = db; }
public TaggedBlogPostsViewProjection(DB.AutoBox db) { _db = db; }
public AuthorProfileViewProjection(DB.AutoBox db) { _db = db; }
public static void init (String path, bool isVM) { Console.WriteLine ("DBPath=" + path); DB.Root (path); DB server = new DB (1); if (isVM) { server.GetConfig ().DBConfig.CacheLength = server.GetConfig ().DBConfig.MB (16); } else { server.GetConfig ().DBConfig.CacheLength = server.GetConfig ().DBConfig.MB (512); } server.GetConfig ().DBConfig.SwapFileBuffer = (int)server.GetConfig ().DBConfig.MB (4); server.GetConfig ().DBConfig.FileIncSize = (int)server.GetConfig ().DBConfig.MB (16); new Engine ().Config (server.GetConfig ().DBConfig); server.GetConfig ().EnsureTable<Page> ("Page", "id"); server.GetConfig ().EnsureIndex<Page> ("Page", true, "url(" + Page.MAX_URL_LENGTH + ")"); search_db = server.Open (); }
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)); }