public DBKeyIndexer GetKeyIndexer(uint idTable) { Assert(m_tblManager.Tables[idTable] != null); DBKeyIndexer ndxer = m_keysIndexers.Find(x => x.Source.DataSource.ID == idTable); if (ndxer == null) { ndxer = new DBKeyIndexer(m_tblManager, idTable); m_keysIndexers.Add(ndxer); } if (!ndxer.IsConnected) { ndxer.Connect(); } return(ndxer); }
static void ApplyUpdate(string updateFile) { IEnumerable <TableUpdate> updates = UpdateEngin.LoadTablesUpdate(updateFile, Program.TablesManager.DataFactory); foreach (TableUpdate update in updates) { IDBTable table = Program.TablesManager.Tables[update.TableID]; //TODO: traiter le cas ou une version de table est manquante ex: 1,2 ,4 if (table.Version != update.PreGeneration) { continue; } using (new AutoReleaser(() => EndTableUpdate?.Invoke(table.ID))) { BeginTableUpdate?.Invoke(table.ID); if (update.DatumMaxSize > table.DatumSize) { Program.TablesManager.ResizeTable(table.ID, update.DatumMaxSize); } using (var ndxer = new DBKeyIndexer(Program.TablesManager, update.TableID)) { ndxer.Connect(); foreach (IUpdateAction action in update.Actions) { ApplyAction(action, ndxer); } } table.Version = update.PostGeneration; } } }
//private; static void ApplyAction(IUpdateAction action, DBKeyIndexer ndxer) { switch (action.Code) { case ActionCode_t.DeleteRow: var delAct = action as DeleteRow; ndxer.Source.Delete(ndxer.IndexOf(delAct.RowID)); break; case ActionCode_t.ReplaceRow: var replaceAct = action as ReplaceRow; ndxer.Source.Replace(ndxer.IndexOf(replaceAct.RowID), replaceAct.Datum); break; case ActionCode_t.AddRow: var addAct = action as AddRow; ndxer.Source.Insert(addAct.Datum); break; default: Assert(false); break; } }