private void ValidateDataFile(string sourceName, bool isUnsearchable, bool isPublicFolder) { string text = string.Empty; if (isPublicFolder) { text = this.GetPFPstFilePath(isUnsearchable, 1); } else { text = this.GetPstFilePath(sourceName, isUnsearchable, 1); } if (File.Exists(text)) { try { PstWriter.CreatePstSession(text).Close(); } catch (ExportException ex) { Tracer.TraceError("PstTarget.ValidateDateFile: Failed to create PST session. Exception: {0}", new object[] { ex }); throw new ExportException(ExportErrorType.FailedToOpenExistingPstFile, text); } } }
private void CreatePstFile(string filePath) { PstWriter.CreatePstSession(filePath).Close(); ProgressRecord progressRecord = new ProgressRecord(); ExportRecord exportRecord = new ExportRecord { ExportFile = new ExportFile { Name = Path.GetFileName(filePath), Path = filePath }, SourceId = null, Id = Path.GetFileNameWithoutExtension(filePath), OriginalPath = null, Parent = null, Title = null, DocumentType = "File", RelationshipType = "None", IsUnsearchable = this.dataContext.IsUnsearchable }; if (this.dataContext.IsPublicFolder) { this.currentPFRecord = exportRecord; if (this.dataContext.IsUnsearchable) { this.pfUnsearchableExportResult = this.currentPFRecord; } else { this.pfExportResult = this.currentPFRecord; } progressRecord.ReportRootRecord(this.currentPFRecord); } else { this.currentRootRecord = exportRecord; if (this.dataContext.IsUnsearchable) { this.rootUnsearchableExportResult = this.currentRootRecord; } else { this.rootExportResult = this.currentRootRecord; } progressRecord.ReportRootRecord(this.currentRootRecord); } this.progressController.ReportProgress(progressRecord); }
public void ReOpenPFDataContext() { Tracer.TraceInformation("PstWriter.ReOpenPFDataContext: SourceId:{0}", new object[] { this.dataContext.SourceId }); if (this.pstPFSession != null) { Tracer.TraceInformation("PstWriter.ReOpenPFDataContext: Closing public folder PST session", new object[0]); this.pstPFSession.Close(); this.pstPFSession = null; Tracer.TraceInformation("PstWriter.ReOpenPFDataContext: PST public folder session closed", new object[0]); } if (this.currentPFRecord != null) { this.ReportFileInformation(this.currentPFRecord); this.currentPFRecord = null; if (!this.dataContext.IsUnsearchable) { this.pfExportResult = null; } else { this.pfUnsearchableExportResult = null; } } this.currentPFRecord = (this.dataContext.IsUnsearchable ? this.pfUnsearchableExportResult : this.pfExportResult); if (this.currentPFRecord == null && this.dataContext.ItemCount > 0) { this.EnsurePFPstFileCreated(); } if (this.currentPFRecord != null && this.pstPFSession == null) { this.pstPFSession = PstWriter.CreatePstSession(this.currentPFRecord.ExportFile.Path); this.targetFolderProvider.Reset(this.dataContext); Tracer.TraceInformation("PstWriter.ReOpenPFDataContext: PST pf session created.", new object[0]); } }
public void EnterDataContext(DataContext context) { Tracer.TraceInformation("PstWriter.EnterDataContext: {0}", new object[] { context.SourceId }); LocalFileHelper.CallFileOperation(delegate { string path = context.IsUnsearchable ? this.target.ExportContext.TargetLocation.UnsearchableExportLocation : this.target.ExportContext.TargetLocation.ExportLocation; DirectoryInfo directoryInfo = new DirectoryInfo(path); if (!directoryInfo.Exists) { Tracer.TraceInformation("PstWriter.EnterDataContext: Creating directory '{0}'", new object[] { directoryInfo.FullName }); Directory.CreateDirectory(directoryInfo.FullName); } }, ExportErrorType.FailedToCreateExportLocation); this.dataContext = context; this.timer.Restart(); this.targetFolderProvider.Reset(this.dataContext); if (this.dataContext.IsPublicFolder) { long num = 0L; foreach (ItemId itemId in this.dataContext.ItemIdList.ReadItemIds()) { num += (long)((ulong)itemId.Size); } if (this.dataContext.IsUnsearchable) { if (this.unsearchablePFTotalSize > 0L && this.unsearchablePFTotalSize + num > ConstantProvider.PSTSizeLimitInBytes && num < ConstantProvider.PSTSizeLimitInBytes) { this.ReOpenPFDataContext(); this.unsearchablePFTotalSize = 0L; } } else if (this.searchablePFTotalSize > 0L && this.searchablePFTotalSize + num > ConstantProvider.PSTSizeLimitInBytes && num < ConstantProvider.PSTSizeLimitInBytes) { this.ReOpenPFDataContext(); this.searchablePFTotalSize = 0L; } this.currentPFRecord = (this.dataContext.IsUnsearchable ? this.pfUnsearchableExportResult : this.pfExportResult); if (this.currentPFRecord == null && this.dataContext.ItemCount > 0) { this.EnsurePFPstFileCreated(); } if (this.currentPFRecord != null && this.pstPFSession == null) { this.pstPFSession = PstWriter.CreatePstSession(this.currentPFRecord.ExportFile.Path); Tracer.TraceInformation("PstWriter.EnterDataContext: PST pf session created.", new object[0]); return; } } else { this.pstMBFileCount = 1; this.unsearchableMBTotalSize = 0L; this.searchableMBTotalSize = 0L; this.currentRootRecord = (this.dataContext.IsUnsearchable ? this.rootUnsearchableExportResult : this.rootExportResult); if (this.currentRootRecord == null && this.dataContext.ItemCount > 0) { this.EnsurePstFileCreated(); } if (this.currentRootRecord != null) { this.pstSession = PstWriter.CreatePstSession(this.currentRootRecord.ExportFile.Path); Tracer.TraceInformation("PstWriter.EnterDataContext: PST session created.", new object[0]); } } }