private void OpenFile() { try { string name = this._database.GetPath() + ".lobs"; bool rdy = this._database.IsReadOnly(); this._file = ScaledRAFile.NewScaledRAFile(this._database, name, rdy, this._database.IsFilesInAssembly()); } catch (Exception exception) { throw Error.GetError(0x1d2, exception); } }
public override void Open(bool rdy) { try { base.DataFile = ScaledRAFile.NewScaledRAFile(base.database, base.DataFileName, rdy, base.database.IsFilesInAssembly()); base.FileFreePosition = 0x20L; this.InitBuffers(); base.FreeBlocks = new DataFileBlockManager(0, base.CacheFileScale, 0L); } catch (Exception exception) { base.database.logger.LogWarningEvent(FwNs.Core.LC.cResources.SR.DataFileCacheSession_Open_Failed_to_open_RA_file, exception); this.Close(false); object[] add = new object[] { exception.Message, base.DataFileName }; throw Error.GetError(exception, 0x1c4, 0x34, add); } }
public static void RestoreFile(Database database, string sourceName, string destName) { using (IScaledRAInterface interface2 = ScaledRAFile.NewScaledRAFile(database, sourceName, true, database.IsFilesInAssembly())) { using (IScaledRAInterface interface3 = ScaledRAFile.NewScaledRAFile(database, destName, false, database.IsFilesInAssembly())) { while (interface2.GetFilePointer() != interface2.Length()) { int length = interface2.ReadInt(); long position = interface2.ReadLong(); byte[] b = new byte[length]; interface2.Read(b, 0, length); interface3.Seek(position); interface3.Write(b, 0, length); } } } }
public void Process() { bool flag = false; Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_Defrag_process_begins); this._transactionRowLookup = this._database.TxManager.GetTransactionIDList(); Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_transaction_count__ + this._transactionRowLookup.Size()); List <Table> allTables = this._database.schemaManager.GetAllTables(); this._rootsList = new int[allTables.Count][]; IScaledRAInterface interface2 = null; try { Stream stream = this._database.logger.GetFileAccess().OpenOutputStreamElement(this._dataFileName + ".new"); this._fileStreamOut = new BufferedStream(stream, 0x1000); for (int i = 0; i < this._cache.InitialFreePos; i++) { this._fileStreamOut.WriteByte(0); } this._fileOffset = this._cache.InitialFreePos; int index = 0; int count = allTables.Count; while (index < count) { Table table = allTables[index]; if (table.GetTableType() == 5) { this._rootsList[index] = this.WriteTableToDataFile(table); } else { this._rootsList[index] = null; } Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_WriteTableToDataFile_table__ + table.GetName().Name + FwNs.Core.LC.cResources.SR.DataFileDefrag_Process__complete); index++; } this._fileStreamOut.Flush(); this._fileStreamOut.Close(); this._fileStreamOut = null; interface2 = ScaledRAFile.NewScaledRAFile(this._database, this._dataFileName + ".new", false, this._database.IsFilesInAssembly()); interface2.Seek(12L); interface2.WriteLong(this._fileOffset); int map = 0; if (this._database.logger.PropIncrementBackup) { map = BitMap.Set(map, 1); } map = BitMap.Set(BitMap.Set(map, 4), 2); interface2.Seek(0x1cL); interface2.WriteInt(map); int num4 = 0; int length = this._rootsList.Length; while (num4 < length) { int[] s = this._rootsList[num4]; if (s != null) { Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_roots__ + StringUtil.GetList(s, ",", "")); } num4++; } flag = true; } catch (IOException exception) { throw Error.GetError(0x1c4, exception); } catch (OutOfMemoryException exception2) { throw Error.GetError(460, exception2); } catch (Exception exception3) { throw Error.GetError(0x1ca, exception3); } finally { try { if (this._fileStreamOut != null) { this._fileStreamOut.Close(); } if (interface2 != null) { interface2.Dispose(); } } catch (Exception exception4) { this._database.logger.LogSevereEvent(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_backupFile_failed, exception4); } if (!flag) { this._database.logger.GetFileAccess().RemoveElement(this._dataFileName + ".new"); } } Error.PrintSystemOut(FwNs.Core.LC.cResources.SR.DataFileDefrag_Process_Defrag_transfer_complete__ + this._stopw.ElapsedTime()); }
public virtual void Open(bool rdy) { this.FileFreePosition = 0L; this.database.logger.LogInfoEvent(FwNs.Core.LC.cResources.SR.DataFileCache_Open_open_start); try { if (rdy || this.database.IsFilesInAssembly()) { this.DataFile = ScaledRAFile.NewScaledRAFile(this.database, this.DataFileName, rdy, this.database.IsFilesInAssembly()); this.InitBuffers(); } else { bool flag = false; long lostSize = 0L; if (this.Fa.IsStreamElement(this.DataFileName)) { flag = true; } this.DataFile = ScaledRAFile.NewScaledRAFile(this.database, this.DataFileName, rdy, this.database.IsFilesInAssembly()); if (flag) { this.DataFile.Seek(0x1cL); int map = this.DataFile.ReadInt(); this.database.logger.PropIncrementBackup = BitMap.IsSet(map, 1); if (!BitMap.IsSet(map, 2)) { bool flag2; this.DataFile.Close(); if (this.database.logger.PropIncrementBackup) { flag2 = this.RestoreBackupIncremental(); } else { flag2 = this.RestoreBackup(); } this.DataFile = ScaledRAFile.NewScaledRAFile(this.database, this.DataFileName, rdy, this.database.IsFilesInAssembly()); if (!flag2) { this.InitNewFile(); } } this.DataFile.Seek(4L); lostSize = this.DataFile.ReadLong(); this.DataFile.Seek(12L); this.FileFreePosition = this.DataFile.ReadLong(); if (this.FileFreePosition < this.InitialFreePos) { this.FileFreePosition = this.InitialFreePos; } if (this.database.logger.PropIncrementBackup && (this.FileFreePosition != this.InitialFreePos)) { this._shadowFile = new RAShadowFile(this.database, this.DataFile, this.BackupFileName, this.FileFreePosition, 0x4000); } } else { this.InitNewFile(); } this.InitBuffers(); this.FileModified = false; this.FreeBlocks = new DataFileBlockManager(this.MaxFreeBlocks, this.CacheFileScale, lostSize); this.database.logger.LogInfoEvent(FwNs.Core.LC.cResources.SR.DataFileCache_Open_open_end); } } catch (Exception exception) { this.database.logger.LogSevereEvent(FwNs.Core.LC.cResources.SR.DataFileCache_Open_open_failed, exception); this.Close(false); object[] add = new object[] { exception.Message, this.DataFileName }; throw Error.GetError(exception, 0x1c4, 0x34, add); } }
private void Open() { this._dest = ScaledRAFile.NewScaledRAFile(this._database, this._pathName, false, this._database.IsFilesInAssembly()); }