Exemple #1
0
 internal DbFile(DbTransaction transaction, string fileName, IDataFile parent)
 {
     this.transaction = transaction;
     this.fileName = fileName;
     this.parent = parent;
 }
        internal void ReplayTableLogEntry(string entry, DbTransaction srcTransaction, bool historicChanges)
        {
            char t = entry[0];
            char op = entry[1];
            String name = entry.Substring(2);
            // If this is a table operation,
            if (t != 'T')
                throw new ApplicationException("Transaction log entry error: " + entry);

            if (op == 'C') {
                CreateTable(name);
            } else if (op == 'D') {
                DeleteTable(name);
            } else if (op == 'M' || op == 'S') {
                // If it's a TS event (a structural change to the table), we need to
                // pass this to the table merge function.
                bool structuralChange = (op == 'S');
                // To replay a table modification
                if (tableCopySet == null)
                    tableCopySet = new List<string>();

                if (!tableCopySet.Contains(name)) {
                    DbTable st = srcTransaction.GetTable(name);
                    DbTable dt = GetTable(name);
                    // Merge the source table into the destination table,
                    dt.MergeFrom(st, structuralChange, historicChanges);
                    tableCopySet.Add(name);
                }
                // Make sure to copy this event into the log in this transaction,
                log.Add(entry);
            } else {
                throw new ApplicationException("Transaction log entry error: " + entry);
            }
        }
        internal void ReplayFileLogEntry(string entry, DbTransaction srcTransaction)
        {
            // Get the operation type and operation code,
            char t = entry[0];
            char op = entry[1];
            string name = entry.Substring(2);
            // If this is a file operation,
            if (t != 'F')
                throw new ApplicationException("Transaction log entry error: " + entry);

            if (op == 'C') {
                CreateFile(name);
            } else if (op == 'D') {
                DeleteFile(name);
            } else if (op == 'M') {
                if (fileCopySet == null)
                    fileCopySet = new List<string>();

                // Copy the contents from the source if it hasn't already been
                // copied.
                if (!fileCopySet.Contains(name)) {
                    srcTransaction.fileSet.CopyTo(name, fileSet);
                    fileCopySet.Add(name);
                }
                // Make sure to copy this event into the log in this transaction,
                log.Add(entry);
            } else {
                throw new ApplicationException("Transaction log entry error: " + entry);
            }
        }