static BackupTools() { _backupDirectoryPath = StorageContext.Search.IndexDirectoryBackupPath; _zipFilePath = IO.Path.Combine(_backupDirectoryPath, BACKUPFILENAME); Progress = new IndexBackupProgress(); Progress.Changed += new EventHandler(Progress_Changed); }
protected internal override void StoreBackupStream(string backupFilePath, IndexBackup backup, IndexBackupProgress progress) { var fileLength = new FileInfo(backupFilePath).Length; using (var writeCommand = CreateWriteCommand(backup)) { using (var stream = new FileStream(backupFilePath, FileMode.Open)) { using (var reader = new BinaryReader(stream)) { InitializeNewStream(backup); progress.Type = IndexBackupProgressType.Storing; progress.Message = "Storing backup"; progress.MaxValue = fileLength; var timer = Stopwatch.StartNew(); var offset = 0L; while (offset < fileLength) { progress.Value = offset; progress.NotifyChanged(); var remnant = fileLength - offset; var length = remnant < BUFFERSIZE ? Convert.ToInt32(remnant) : BUFFERSIZE; var buffer = reader.ReadBytes(length); writeCommand.Parameters["@Buffer"].Value = buffer; writeCommand.Parameters["@Offset"].Value = offset; writeCommand.Parameters["@Length"].Value = length; writeCommand.ExecuteNonQuery(); offset += BUFFERSIZE; } //progress.FinishStoreIndexBackupToDb(); ////progress.Value = fileLength; ////progress.NotifyChanged(); } } } }
protected internal override void StoreBackupStream(string backupFilePath, IndexBackup backup, IndexBackupProgress progress) { WriteLog(MethodInfo.GetCurrentMethod(), backupFilePath, backup, progress); base.StoreBackupStream(backupFilePath, backup, progress); }
// ====================================================================== Index backup / restore operations public static Guid StoreIndexBackupToDb(string backupFilePath, IndexBackupProgress progress) { return(DataProvider.StoreIndexBackupToDb(backupFilePath, progress)); }