private void ReadDroppedTables()
        {
            lock (commitLock) {
                // The list of all dropped tables from the state file
                var tables = StateStore.GetDeleteList();

                // For each visible table
                foreach (var resource in tables)
                {
                    int    tableId   = resource.TableId;
                    string tableName = resource.SourceName;

                    // Load the master table from the resource information
                    var source = LoadTableSource(tableId, tableName);

                    // File wasn't found so remove from the delete resources
                    if (source == null)
                    {
                        StateStore.RemoveDeleteResource(tableName);
                    }
                    else
                    {
                        source.Open();

                        // Add the table to the table list
                        tableSources.Add(tableId, source);
                    }
                }

                StateStore.Flush();
            }
        }
        internal void CommitToTables(IEnumerable <int> createdTables, IEnumerable <int> droppedTables)
        {
            // Add created tables to the committed tables list.
            foreach (int createdTable in createdTables)
            {
                // For all created tables, add to the visible list and remove from the
                // delete list in the state store.
                var t        = GetTableSource(createdTable);
                var resource = new TableStateStore.TableState(t.TableId, t.SourceName);
                StateStore.AddVisibleResource(resource);
                StateStore.RemoveDeleteResource(resource.SourceName);
            }

            // Remove dropped tables from the committed tables list.
            foreach (int droppedTable in droppedTables)
            {
                // For all dropped tables, add to the delete list and remove from the
                // visible list in the state store.
                var t        = GetTableSource(droppedTable);
                var resource = new TableStateStore.TableState(t.TableId, t.SourceName);
                StateStore.AddDeleteResource(resource);
                StateStore.RemoveVisibleResource(resource.SourceName);
            }

            try {
                StateStore.Flush();
            } catch (IOException e) {
                throw new InvalidOperationException("IO Error: " + e.Message, e);
            }
        }
Beispiel #3
0
        private void CleanUp()
        {
            lock (commitLock) {
                if (IsClosed)
                {
                    return;
                }

                // If no open transactions on the database, then clean up.
                if (Database.OpenTransactions == null ||
                    Database.OpenTransactions.Count == 0)
                {
                    var deleteList = StateStore.GetDeleteList().ToArray();
                    if (deleteList.Length > 0)
                    {
                        int dropCount = 0;

                        for (int i = deleteList.Length - 1; i >= 0; --i)
                        {
                            var tableName = deleteList[i].SourceName;
                            CloseTable(tableName, true);
                        }

                        for (int i = deleteList.Length - 1; i >= 0; --i)
                        {
                            string tableName = deleteList[i].SourceName;
                            bool   dropped   = CloseAndDropTable(tableName);
                            // If we managed to drop the table, remove from the list.
                            if (dropped)
                            {
                                StateStore.RemoveDeleteResource(tableName);
                                ++dropCount;
                            }
                        }

                        // If we dropped a table, commit an update to the conglomerate state.
                        if (dropCount > 0)
                        {
                            StateStore.Flush();
                        }
                    }
                }
            }
        }